Package org.jppf.server.protocol
Class AbstractServerJob
java.lang.Object
org.jppf.server.protocol.AbstractServerJob
- All Implemented Interfaces:
org.jppf.node.protocol.JPPFDistributedJob
- Direct Known Subclasses:
AbstractServerJobBase
public abstract class AbstractServerJob
extends Object
implements org.jppf.node.protocol.JPPFDistributedJob
Abstract class that support job state management.
- Author:
- Martin JANDA
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<ServerTaskBundleClient>List of bundles added after submission status set toCOMPLETE.protected final longA unique id for this client bundle.protected final org.jppf.node.protocol.TaskBundleThe underlying task bundle.protected booleanJob expired indicator, determines whether the job is should be cancelled.protected longTime at which the job is received on the server side.protected final LockUsed for synchronized access to job.protected StringThe user-defined display name for this job.protected ServerJobChangeListenerHandler for job state notifications.List of all runnables called on job completion.protected booleanJob pending indicator, determines whether the job is waiting for its scheduled time to start.protected longThe time at which this wrapper was added to the queue.protected final org.jppf.utils.concurrent.ThreadSynchronizationCondition signalled when this job is removed from the queue.protected AtomicReference<ServerJobStatus>The job status.protected final org.jppf.utils.concurrent.SynchronizedReference<SubmissionStatus>The status of this submission.protected StringThe universal unique id for this job. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractServerJob(Lock lock, org.jppf.node.protocol.TaskBundle job) Initialized abstract client job with task bundle and list of tasks to execute. -
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters instance to be called on job finish.protected voiddone()Called when task was cancelled or finished.protected voidfireJobDispatched(org.jppf.execute.ExecutorChannel<?> channel, ServerTaskBundleNode bundleNode) A sub-job was dispatched to a node.protected voidfireJobReturned(org.jppf.execute.ExecutorChannel<?> channel, ServerTaskBundleNode bundleNode) A sub-job returned from a node.voidfireJobUpdated(boolean headerUpdated) The current number of tasks in a job was updated.Get the broadcast UUID.Get list of bundles added after job completion.intGet the initial task count.org.jppf.node.protocol.TaskBundlegetJob()Get the underlying task bundle.longGet the job received time.getLock()Get the lock used for synchronized access to job.org.jppf.node.protocol.JobMetadataGet the job metadata.getName()Get the user-defined display name for this job.longGet the time at which this wrapper was added to the queue.org.jppf.utils.concurrent.ThreadSynchronizationorg.jppf.node.protocol.JobSLAgetSLA()Get the service level agreement between the job and the server.Get the status of this submission.abstract intgetUuid()Get the universal unique id for this job.booleanbooleanGet the job expired indicator.booleanGet the job pending indicator.booleanbooleanGet the job suspended indicator.voidSets and notifies that job has expired.voidremoveOnDone(Runnable runnable) Deregisters instance to be called on job finish.booleansetCancelled(boolean mayInterruptIfRunning) Cancels this job.voidsetJobReceivedTime(long jobReceivedTime) Set the job received time.voidsetMaxNodes(int maxNodes) Set the maximum number of nodes this job can run on.voidsetMetadata(org.jppf.node.protocol.JobMetadata metadata) Set the job metadata.voidSet the user-defined display name for this job.voidsetPending(boolean pending) Set the job pending indicator.voidsetQueueEntryTime(long queueEntryTime) Set the time at which this wrapper was added to the queue.voidsetSLA(org.jppf.node.protocol.JobSLA sla) Get the service level agreement between the job and the server.voidsetSubmissionStatus(SubmissionStatus newStatus) Set the status of this submission.voidsetSuspended(boolean suspended, boolean requeue) Set the job suspended indicator.voidSet the universal unique id for this job.voidSerialize the updated job header and cache the resulting serialized representation.protected final booleanupdateStatus(ServerJobStatus expect, ServerJobStatus newStatus) Updates status to new value if old value is equal to expect.
-
Field Details
-
id
protected final long idA unique id for this client bundle. -
status
The job status. -
onDoneList
List of all runnables called on job completion. -
jobReceivedTime
protected long jobReceivedTimeTime at which the job is received on the server side. In milliseconds since January 1, 1970 UTC. -
queueEntryTime
protected transient long queueEntryTimeThe time at which this wrapper was added to the queue. -
job
protected final org.jppf.node.protocol.TaskBundle jobThe underlying task bundle. -
uuid
The universal unique id for this job. -
name
The user-defined display name for this job. -
jobExpired
protected boolean jobExpiredJob expired indicator, determines whether the job is should be cancelled. -
pending
protected boolean pendingJob pending indicator, determines whether the job is waiting for its scheduled time to start. -
lock
Used for synchronized access to job. -
removalCondition
protected final org.jppf.utils.concurrent.ThreadSynchronization removalConditionCondition signalled when this job is removed from the queue. -
submissionStatus
The status of this submission. -
notificationEmitter
Handler for job state notifications. -
completionBundles
List of bundles added after submission status set toCOMPLETE.
-
-
Constructor Details
-
AbstractServerJob
Initialized abstract client job with task bundle and list of tasks to execute.- Parameters:
lock- used to synchronized access to job.job- underlying task bundle.
-
-
Method Details
-
getJob
public org.jppf.node.protocol.TaskBundle getJob()Get the underlying task bundle.- Returns:
- a
ClientTaskBundleinstance.
-
getUuid
Get the universal unique id for this job.- Specified by:
getUuidin interfaceorg.jppf.node.protocol.JPPFDistributedJob- Returns:
- the uuid as a string.
-
setUuid
Set the universal unique id for this job.- Parameters:
uuid- the universal unique id.
-
getName
Get the user-defined display name for this job. This is the name displayed in the administration console.- Specified by:
getNamein interfaceorg.jppf.node.protocol.JPPFDistributedJob- Returns:
- the name as a string.
-
setName
Set the user-defined display name for this job.- Parameters:
name- the display name as a string.
-
getSLA
public org.jppf.node.protocol.JobSLA getSLA()Get the service level agreement between the job and the server.- Specified by:
getSLAin interfaceorg.jppf.node.protocol.JPPFDistributedJob- Returns:
- an instance of
JobSLA.
-
getMetadata
public org.jppf.node.protocol.JobMetadata getMetadata()Get the job metadata.- Specified by:
getMetadatain interfaceorg.jppf.node.protocol.JPPFDistributedJob- Returns:
- an instance of
JobMetadata.
-
setMetadata
public void setMetadata(org.jppf.node.protocol.JobMetadata metadata) Set the job metadata.- Parameters:
metadata- an instance ofJobMetadata.
-
setSLA
public void setSLA(org.jppf.node.protocol.JobSLA sla) Get the service level agreement between the job and the server.- Parameters:
sla- an instance ofJobSLA.
-
isJobExpired
public boolean isJobExpired()Get the job expired indicator.- Returns:
trueif job has expired,falseotherwise.
-
jobExpired
public void jobExpired()Sets and notifies that job has expired. -
isPending
public boolean isPending()Get the job pending indicator.- Returns:
trueif job is pending,falseotherwise.
-
setPending
public void setPending(boolean pending) Set the job pending indicator.- Parameters:
pending-trueto indicate that job is pending,falseotherwise
-
isSuspended
public boolean isSuspended()Get the job suspended indicator.- Returns:
trueif job is suspended,falseotherwise.
-
setSuspended
public void setSuspended(boolean suspended, boolean requeue) Set the job suspended indicator.- Parameters:
suspended-trueto indicate that job is suspended,falseotherwise.requeue-trueto indicate that job should be requeued,falseotherwise.
-
setMaxNodes
public void setMaxNodes(int maxNodes) Set the maximum number of nodes this job can run on.- Parameters:
maxNodes- the number of nodes as an int value. A value <= 0 means no limit on the number of nodes.
-
updateStatus
Updates status to new value if old value is equal to expect.- Parameters:
expect- the expected value.newStatus- the new value.- Returns:
trueif new status was set.
-
isCancelled
public boolean isCancelled()- Returns:
truewhen job was cancelled.
-
setCancelled
public boolean setCancelled(boolean mayInterruptIfRunning) Cancels this job.- Parameters:
mayInterruptIfRunning- true if the thread executing this task should be interrupted.- Returns:
- whether cancellation was successful.
-
done
protected void done()Called when task was cancelled or finished. -
addOnDone
Registers instance to be called on job finish.- Parameters:
runnable-Runnableto be called on job finish.
-
removeOnDone
Deregisters instance to be called on job finish.- Parameters:
runnable-Runnableto be called on job finish.
-
getJobReceivedTime
public long getJobReceivedTime()Get the job received time.- Returns:
- the time in milliseconds as a long value.
-
setJobReceivedTime
public void setJobReceivedTime(long jobReceivedTime) Set the job received time.- Parameters:
jobReceivedTime- the time in milliseconds as a long value.
-
getQueueEntryTime
public long getQueueEntryTime()Get the time at which this wrapper was added to the queue.- Returns:
- the time in milliseconds as a long value.
-
setQueueEntryTime
public void setQueueEntryTime(long queueEntryTime) Set the time at which this wrapper was added to the queue.- Parameters:
queueEntryTime- the time in milliseconds as a long value.
-
getTaskCount
public abstract int getTaskCount()- Specified by:
getTaskCountin interfaceorg.jppf.node.protocol.JPPFDistributedJob
-
getInitialTaskCount
public int getInitialTaskCount()Get the initial task count.- Returns:
- the count as an int.
-
getSubmissionStatus
Get the status of this submission.- Returns:
- a
SubmissionStatusenumerated value.
-
setSubmissionStatus
Set the status of this submission.- Parameters:
newStatus- aSubmissionStatusenumerated value.
-
getBroadcastUUID
Get the broadcast UUID.- Returns:
- an
Stringinstance.
-
getCompletionBundles
Get list of bundles added after job completion.- Returns:
- list of bundles added after job completion.
-
fireJobUpdated
public void fireJobUpdated(boolean headerUpdated) The current number of tasks in a job was updated.- Parameters:
headerUpdated- whether the job header(aTaskBundleinstance) has been updated.
-
fireJobDispatched
protected void fireJobDispatched(org.jppf.execute.ExecutorChannel<?> channel, ServerTaskBundleNode bundleNode) A sub-job was dispatched to a node.- Parameters:
channel- the node to which the job is dispatched.bundleNode- the bundle for job event.
-
fireJobReturned
protected void fireJobReturned(org.jppf.execute.ExecutorChannel<?> channel, ServerTaskBundleNode bundleNode) A sub-job returned from a node.- Parameters:
channel- the node from which the job is returned.bundleNode- the bundle for job event.
-
getLock
Get the lock used for synchronized access to job.- Returns:
- a
Lockobject.
-
updateJobDataLocation
public void updateJobDataLocation()Serialize the updated job header and cache the resulting serialized representation. -
isPersistent
public boolean isPersistent()- Returns:
- whether this job is persisted in the driver.
-
getRemovalCondition
public org.jppf.utils.concurrent.ThreadSynchronization getRemovalCondition()- Returns:
- a Condition that is signalled when this job is removed from the queue
-