|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object uws.job.SerializableUWSObject uws.job.JobList<J>
public class JobList<J extends AbstractJob>
An instance of this class lets listing UWS jobs (possible actions: get, add and remove).
Note:This list implements the interface Iterable
which lets you iterating more easily among the jobs.
So that avoiding any user to interact on jobs of anybody else, it is possible (and strongly encouraged)
to get the list of jobs only of the current user. For that you must use the function getJobs(String)
with a owner ID.
At each request sent to any instance of AbstractUWS
the function UserIdentifier.extractUserId(uws.service.UWSUrl, javax.servlet.http.HttpServletRequest)
may extract the user ID. Thus the action GetJobList may know who is the current user. If the extracted owner ID is different from null
only the jobs of the current user will be returned.
However you need to find a way to identify for each UWS request the current user and then to override correctly the function
UserIdentifier.extractUserId(uws.service.UWSUrl, javax.servlet.http.HttpServletRequest)
.
Note: There are two special values for a owner ID:
AbstractJob.ANONYMOUS_OWNER
: the default value of an owner ID. It is set by default to a job if no owner is specified.
getJobs()
or iterator()
: to get all the jobs of this jobs list.getJob(String)
: to get the job that has the given jobID.searchJobs(String)
: to search all the jobs that have the given runID.getJobs(String)
: to get the jobs of the specified user.If you are interested in (probably for some statistics or for an administrator) you can ask the list of users
who have at least one job in this jobs list (getUsers()
) and known how many they are (getNbUsers()
).
A job has a field - destructionTime - which indicates the date at which it must destroyed.
Remember that destroying a job consists in removing it from its jobs list and then clearing all its resources (result files, threads, ...).
This task is done by an "instance" of the interface DestructionManager
. By default a jobs list has a default implementation of this interface: DefaultDestructionManager
.
However when added in a UWS, the jobs list inherits the destruction manager of its UWS. Thus all jobs list of a UWS have the same destruction manager.
To use a custom destruction manager, you can use the method setDestructionManager(DestructionManager)
if the jobs list is not managed by a UWS or AbstractUWS.setDestructionManager(DestructionManager)
otherwise.
AbstractJob
,
Serialized FormField Summary | |
---|---|
protected java.util.Map<java.lang.String,J> |
jobsList
[Required] List of jobs. |
protected java.util.Map<java.lang.String,java.util.Map<java.lang.String,J>> |
ownerJobs
[Required] List of jobs per ownerId/userId. |
Constructor Summary | |
---|---|
JobList(java.lang.String jobListName)
Builds a jobs list with its name. |
Method Summary | |
---|---|
java.lang.String |
addNewJob(J j)
Add the given job to the list except if a job with the same jobID already exists. |
void |
clear()
Destroys all jobs of this list. |
void |
clear(java.lang.String ownerId)
Destroys all jobs owned by the specified user. |
boolean |
destroyJob(java.lang.String jobId)
Removes the job from the list and deletes all its attached resources ( AbstractJob.clearResources() . |
DestructionManager |
getDestructionManager()
Gets the used destruction manager. |
J |
getJob(java.lang.String jobID)
Gets the job whose the ID is given in parameter. |
java.util.Iterator<J> |
getJobs()
Gets an iterator on the whole jobs list. |
java.util.Iterator<J> |
getJobs(java.lang.String ownerId)
Gets an iterator on the jobs list of the specified user. |
java.lang.String |
getName()
Gets the name of this jobs list. |
int |
getNbJobs()
Gets the number of jobs into this list. |
int |
getNbJobs(java.lang.String ownerId)
Gets the number of jobs owned by the specified user into this list. |
int |
getNbUsers()
Gets the number of all users that have at least one job in this list. |
UWSUrl |
getUrl()
Gets the UWS URL of this jobs list in function of its UWS. |
java.util.Iterator<java.lang.String> |
getUsers()
Gets all users that own at least one job in this list. |
AbstractUWS |
getUWS()
Gets the UWS which manages this jobs list. |
java.util.Iterator<J> |
iterator()
Gets an iterator on the jobs list. |
void |
removeAll()
Removes all jobs of this list. |
J |
removeJob(java.lang.String jobId)
Lets removing (NOT DESTROYING) the specified job from this jobs list. |
java.util.ArrayList<J> |
searchJobs(java.lang.String runID)
Gets all job whose the runID is equals (not case sensitive) to the given runID. |
java.lang.String |
serialize(UWSSerializer serializer,
java.lang.String ownerId)
Serializes the whole object considering the given owner ID (supposed to be the ID of the current user) and thanks to the given serializer. |
void |
setDestructionManager(DestructionManager newManager)
Sets the destruction manager to use. |
void |
setUWS(AbstractUWS newUws)
Sets the UWS which aims to manage this jobs list. |
void |
sync()
This method is called by its UWS just after a de-serialization of the whole UWS (this jobs list included). |
java.lang.String |
toString()
|
void |
updateDestruction(J job)
Lets notifying the destruction manager of a possible modification of the destructionTime of the given job. |
Methods inherited from class uws.job.SerializableUWSObject |
---|
serialize, serialize, serialize |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final java.util.Map<java.lang.String,J extends AbstractJob> jobsList
protected final java.util.Map<java.lang.String,java.util.Map<java.lang.String,J extends AbstractJob>> ownerJobs
Constructor Detail |
---|
public JobList(java.lang.String jobListName) throws UWSException
Builds a jobs list with its name.
jobListName
- The jobs list name.
UWSException
- If the given name is null or empty.Method Detail |
---|
public final void sync()
This method is called by its UWS just after a de-serialization of the whole UWS (this jobs list included). It re-initializes all the jobs of this jobs list.
If a job can not be re-initialized (AbstractJob.sync()
returns false)
it is destroyed and then removed from this jobs list.
DestructionManager.refresh()
,
AbstractJob.sync()
,
destroyJob(String)
public final AbstractUWS getUWS()
public final void setUWS(AbstractUWS newUws)
newUws
- Its new UWS (may be null).public final DestructionManager getDestructionManager()
Gets the used destruction manager.
Note: Remember that the destruction manager lets destroying automatically jobs only when their destructionTime has been reached.
public final void setDestructionManager(DestructionManager newManager)
Sets the destruction manager to use. All the jobs are removed from the former destruction manager and then added in the new one.
Note: Remember that the destruction manager lets destroying automatically jobs only when their destructionTime has been reached.
newManager
- Its new destruction manager (may be null).DestructionManager.remove(AbstractJob)
,
DestructionManager.update(AbstractJob)
public UWSUrl getUrl()
AbstractUWS.getUrlInterpreter()
,
UWSUrl.listJobs(String)
public final java.lang.String getName()
public final J getJob(java.lang.String jobID)
jobID
- The ID of the job to get.
public final java.util.Iterator<J> getJobs()
iterator()
public final java.util.Iterator<J> getJobs(java.lang.String ownerId)
ownerId
- The ID of the owner/user (may be null).
public final java.util.Iterator<J> iterator()
iterator
in interface java.lang.Iterable<J extends AbstractJob>
Iterable.iterator()
public final int getNbJobs()
public final int getNbJobs(java.lang.String ownerId)
ownerId
- The ID of the owner/user (may be null).
public final java.util.Iterator<java.lang.String> getUsers()
public final int getNbUsers()
public final java.util.ArrayList<J> searchJobs(java.lang.String runID)
runID
- The runID of jobs to search.
public java.lang.String addNewJob(J j) throws UWSException
Add the given job to the list except if a job with the same jobID already exists.
j
- The job to add.
UWSException
AbstractJob.loadAdditionalParams()
,
AbstractJob.setJobList(JobList)
,
DestructionManager.update(AbstractJob)
,
AbstractJob.applyPhaseParam()
public final void updateDestruction(J job)
Lets notifying the destruction manager of a possible modification of the destructionTime of the given job.
Note: This method does nothing if this jobs list has no destruction manager, if the given job is NULL or if this jobs list does not know the given job.
job
- The job whose the destructionTime may have been modified.DestructionManager.update(AbstractJob)
public J removeJob(java.lang.String jobId)
Lets removing (NOT DESTROYING) the specified job from this jobs list.
jobId
- The ID of the job to remove.
AbstractJob.setJobList(JobList)
,
DestructionManager.remove(AbstractJob)
public boolean destroyJob(java.lang.String jobId)
AbstractJob.clearResources()
.
jobId
- The ID of the job to destroy.
removeJob(String)
,
AbstractJob.clearResources()
public void removeAll()
removeJob(String)
public void clear()
destroyJob(String)
public void clear(java.lang.String ownerId)
ownerId
- The ID of the owner/user.clear()
,
destroyJob(String)
public java.lang.String serialize(UWSSerializer serializer, java.lang.String ownerId) throws UWSException
SerializableUWSObject
serialize
in class SerializableUWSObject
serializer
- The serializer to use.ownerId
- The ID of the current user.
UWSException
- If there is an error during the serialization.public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |