|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gcube.application.enm.service.concurrent.JobMonitor
public class JobMonitor
Coordinates the access to the jobs from several different threads. Instead
of using blocking collections (thread-free), this class implements a monitor
to guarantee that no duplicates occur in the PriorityQueue of
pending jobs, and no collisions occur with the Map of submitted jobs.
Even though, a ConcurrentMap is used to store jobs, because of its
possible use in other classes.
| Field Summary | |
|---|---|
protected org.gcube.common.core.utils.logging.GCUBELog |
logger
|
| Method Summary | |
|---|---|
void |
cancelJob(UUID uuid)
Cancels a job. |
void |
clean()
|
static JobMonitor |
get()
Get the singleton instance of the monitor. |
GenericJob |
getJob(UUID uuid)
Returns the job to which the specified uuid is mapped, or
null if this map contains no mapping for the
uuid. |
void |
init(ConcurrentMap<UUID,GenericJob> jobsMap)
Initializes the job monitor, scheduling the execution of those jobs with the status pending. |
GenericJob |
nextPendingJob()
Retrieves the next job from the queue, waiting if necessary until a job becomes available. |
int |
numPendingJobs()
|
boolean |
registerNewJob(GenericJob job)
Register a new job. |
void |
removeJob(UUID uuid)
Removes a job from the map and the persistent storage. |
void |
schedulePendingJob(GenericJob job)
Inserts the specified job into the priority queue. |
void |
updateJob(GenericJob job,
JobUpdate updates)
Call this method any time that a job receives an update. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected org.gcube.common.core.utils.logging.GCUBELog logger
| Method Detail |
|---|
public static JobMonitor get()
public void init(ConcurrentMap<UUID,GenericJob> jobsMap)
throws IllegalArgumentException
jobsMap - Holds the list of all jobs.
IllegalArgumentExceptionpublic int numPendingJobs()
public GenericJob nextPendingJob()
public void schedulePendingJob(GenericJob job)
job - The job to add.public boolean registerNewJob(GenericJob job)
uuid - Unequally identifies the job.job - The job to add.public GenericJob getJob(UUID uuid)
uuid is mapped, or
null if this map contains no mapping for the
uuid. In the case that the job is not contained in the map
loaded in memory, the method uses the persistence client to retrieve the
job from the persistent storage and puts the job in the map, before
returning it to the caller.
uuid - Unequally identifies the job.
uuid is mapped, or
null if this map contains no mapping for the
uuid.public void cancelJob(UUID uuid)
uuid - Unequally identifies the job.
public void updateJob(GenericJob job,
JobUpdate updates)
job - The job to update.public void removeJob(UUID uuid)
cancelJob(UUID) wait until the status of
the job change to cancelled, and then call this method.
job - The job to remove.public void clean()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||