Package org.jppf.client
Class AbstractJPPFJob<J extends AbstractJPPFJob<J>>
java.lang.Object
org.jppf.client.AbstractJPPFJob<J>
- Type Parameters:
J- the type of job.
- All Implemented Interfaces:
Serializable,JobStatusHandler,org.jppf.node.protocol.JPPFDistributedJob
- Direct Known Subclasses:
JPPFJob
public abstract class AbstractJPPFJob<J extends AbstractJPPFJob<J>>
extends Object
implements Serializable, org.jppf.node.protocol.JPPFDistributedJob, JobStatusHandler
Instances of this class represent a JPPF job and hold all the required elements:
tasks, execution policy, task listener, data provider, priority, blocking indicator.
- Author:
- Laurent Cohen
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor, creates a blocking job with no data provider, default SLA values and a priority of 0.AbstractJPPFJob(String jobUuid) Default constructor, creates a blocking job with no data provider, default SLA values and a priority of 0. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddJobStatusListener(JobStatusListener listener) Add a listener to the list of status listeners.booleanintGet the count of the tasks in this job that haven completed.protected voidfireStatusChangeEvent(JobStatus newStatus) Notify all listeners of a change of status for this job.Get the flag that determines whether this job has been cancelled.Get the flag that determines whether this job is being cancelled.org.jppf.node.protocol.JobClientSLAGet the job SLA for the client side.org.jppf.node.protocol.DataProviderGet the container for data shared between tasks.org.jppf.node.protocol.JobMetadatagetName()Get the object that holds the results of executed tasks.org.jppf.node.protocol.JobSLAgetSLA()Get the status of the job.intgetUuid()inthashCode()booleanDeprecated.a job should be submittable either synchronously or asynchronously, regardless of its state.protected ObjectResolve this instance after deserialization.voidremoveJobStatusListener(JobStatusListener listener) Remove a listener from the list of status listeners.setBlocking(boolean blocking) Deprecated.a job should be submittable either synchronously or asynchronously, regardless of its state.voidsetClientSLA(org.jppf.node.protocol.JobClientSLA jobClientSLA) Get the service level agreement between the job and the server.setDataProvider(org.jppf.node.protocol.DataProvider dataProvider) Set the container for data shared between tasks.voidsetMetadata(org.jppf.node.protocol.JobMetadata jobMetadata) Set this job's metadata.Set the user-defined display name for this job.voidsetSLA(org.jppf.node.protocol.JobSLA jobSLA) Get the service level agreement between the job and the server.voidSet the status of the job.toString()intGet the count of the tasks in this job that haven't yet been executed.
-
Constructor Details
-
AbstractJPPFJob
public AbstractJPPFJob()Default constructor, creates a blocking job with no data provider, default SLA values and a priority of 0. This constructor generates a pseudo-random id as a string of 32 hexadecimal characters. -
AbstractJPPFJob
Default constructor, creates a blocking job with no data provider, default SLA values and a priority of 0. This constructor generates a pseudo-random id as a string of 32 hexadecimal characters.- Parameters:
jobUuid- the uuid to assign to this job.
-
-
Method Details
-
getUuid
- Specified by:
getUuidin interfaceorg.jppf.node.protocol.JPPFDistributedJob
-
getName
- Specified by:
getNamein interfaceorg.jppf.node.protocol.JPPFDistributedJob
-
setName
Set the user-defined display name for this job.- Parameters:
name- the display name as a string.- Returns:
- this job, for method chaining.
-
getTaskCount
public int getTaskCount()- Specified by:
getTaskCountin interfaceorg.jppf.node.protocol.JPPFDistributedJob
-
hashCode
public int hashCode() -
equals
-
getResults
Get the object that holds the results of executed tasks.- Returns:
- a
JobResultsinstance.
-
executedTaskCount
public int executedTaskCount()Get the count of the tasks in this job that haven completed.- Returns:
- the number of executed tasks in this job.
- Since:
- 4.2
-
unexecutedTaskCount
public int unexecutedTaskCount()Get the count of the tasks in this job that haven't yet been executed.- Returns:
- the number of unexecuted tasks in this job.
- Since:
- 4.2
-
getDataProvider
public org.jppf.node.protocol.DataProvider getDataProvider()Get the container for data shared between tasks.- Returns:
- a
DataProviderinstance.
-
setDataProvider
Set the container for data shared between tasks.- Parameters:
dataProvider- aDataProviderinstance.- Returns:
- this job, for method chaining.
-
isBlocking
public boolean isBlocking()Deprecated.a job should be submittable either synchronously or asynchronously, regardless of its state. The submission mode is the user's choice at the time of submission, using one ofJPPFClient.submit()orJPPFClient.submitAsync().Determine whether the execution of this job is blocking on the client side.- Returns:
- true if the execution is blocking, false otherwise.
-
setBlocking
Deprecated.a job should be submittable either synchronously or asynchronously, regardless of its state. The submission mode is the user's choice at the time of submission, using one ofJPPFClient.submit()orJPPFClient.submitAsync().Specify whether the execution of this job is blocking on the client side.- Parameters:
blocking- true if the execution is blocking, false otherwise.- Returns:
- this job, for method chaining.
-
getSLA
public org.jppf.node.protocol.JobSLA getSLA()- Specified by:
getSLAin interfaceorg.jppf.node.protocol.JPPFDistributedJob
-
getClientSLA
public org.jppf.node.protocol.JobClientSLA getClientSLA()Get the job SLA for the client side.- Returns:
- an instance of
JobSLA.
-
getMetadata
public org.jppf.node.protocol.JobMetadata getMetadata()- Specified by:
getMetadatain interfaceorg.jppf.node.protocol.JPPFDistributedJob
-
setSLA
public void setSLA(org.jppf.node.protocol.JobSLA jobSLA) Get the service level agreement between the job and the server.- Parameters:
jobSLA- an instance ofJobSLA.
-
setClientSLA
public void setClientSLA(org.jppf.node.protocol.JobClientSLA jobClientSLA) Get the service level agreement between the job and the server.- Parameters:
jobClientSLA- an instance ofJobSLA.
-
setMetadata
public void setMetadata(org.jppf.node.protocol.JobMetadata jobMetadata) Set this job's metadata.- Parameters:
jobMetadata- aJobMetadatainstance.
-
readResolve
Resolve this instance after deserialization.- Returns:
- an instance of
Object.
-
toString
-
getCancelledFlag
Get the flag that determines whether this job has been cancelled.- Returns:
- an
AtomicBooleaninstance.
-
getStatus
Description copied from interface:JobStatusHandlerGet the status of the job.- Specified by:
getStatusin interfaceJobStatusHandler- Returns:
- a
JobStatusenumerated value.
-
setStatus
Description copied from interface:JobStatusHandlerSet the status of the job.- Specified by:
setStatusin interfaceJobStatusHandler- Parameters:
newStatus- aJobStatusenumerated value.
-
addJobStatusListener
Add a listener to the list of status listeners.- Parameters:
listener- the listener to add.
-
removeJobStatusListener
Remove a listener from the list of status listeners.- Parameters:
listener- the listener to remove.
-
fireStatusChangeEvent
Notify all listeners of a change of status for this job.- Parameters:
newStatus- the status for job event.
-
getCancellingFlag
Get the flag that determines whether this job is being cancelled.- Returns:
- an
AtomicBooleaninstance.
-