org.jppf.client
Class JPPFJob

java.lang.Object
  extended by org.jppf.client.JPPFJob
All Implemented Interfaces:
Serializable, JPPFDistributedJob

public class JPPFJob
extends Object
implements Serializable, JPPFDistributedJob

Instances of this class represent a JPPF submission and hold all the required elements: tasks, execution policy, task listener, data provider, priority, blocking indicator.

This class also provides the API for handling JPPF-annotated tasks and POJO tasks.

All jobs have an id. It can be specified by calling setId(String). If left unspecified, JPPF will automatically assign a uuid as its value.

Author:
Laurent Cohen
See Also:
Serialized Form

Constructor Summary
JPPFJob()
          Default constructor, creates a blocking job with no data provider, default SLA values and a priority of 0.
JPPFJob(DataProvider dataProvider)
          Initialize a blocking job with the specified parameters.
JPPFJob(DataProvider dataProvider, JPPFJobSLA jobSLA)
          Initialize a blocking job with the specified parameters.
JPPFJob(DataProvider dataProvider, JPPFJobSLA jobSLA, boolean blocking, TaskResultListener resultsListener)
          Initialize a job with the specified parameters.
JPPFJob(DataProvider dataProvider, JPPFJobSLA jobSLA, JPPFJobMetadata jobMetadata, boolean blocking, TaskResultListener resultsListener)
          Initialize a job with the specified parameters.
JPPFJob(DataProvider dataProvider, JPPFJobSLA jobSLA, TaskResultListener resultsListener)
          Initialize a non-blocking job with the specified parameters.
JPPFJob(DataProvider dataProvider, TaskResultListener resultsListener)
          Initialize a non-blocking job with the specified parameters.
JPPFJob(String jobUuid)
          Default constructor, creates a blocking job with no data provider, default SLA values and a priority of 0.
JPPFJob(TaskResultListener resultsListener)
          Initialize a non-blocking job with the specified parameters.
 
Method Summary
 JPPFTask addTask(Object taskObject, Object... args)
          Add a task to this job.
 JPPFTask addTask(String method, Object taskObject, Object... args)
          Add a POJO task to this job.
 boolean equals(Object obj)
          Determine whether this object is equal to another.
 DataProvider getDataProvider()
          Get the container for data shared between tasks.
 ExecutionPolicy getExecutionPolicy()
          Deprecated. use JPPFJobSLA.getExecutionPolicy() instead.
 String getId()
          Get the user-defined display name for this job.
 JPPFJobMetadata getJobMetadata()
          Get the user-defined metadata asoociated with this job.
 JPPFJobSLA getJobSLA()
          Get the service level agreement between the job and the server.
 String getJobUuid()
          Get the universal unique id for this job.
 int getPriority()
          Deprecated. use JPPFJobSLA.getPriority() instead.
 TaskResultListener getResultListener()
          Get the listener that receives notifications of completed tasks.
 List<JPPFTask> getTasks()
          Get the list of tasks to execute.
 int hashCode()
          COmpute the hascode of this job.
 boolean isBlocking()
          Determine whether the execution of this job is blocking on the client side.
 void setBlocking(boolean blocking)
          Specify whether the execution of this job is blocking on the client side.
 void setDataProvider(DataProvider dataProvider)
          Set the container for data shared between tasks.
 void setExecutionPolicy(ExecutionPolicy executionPolicy)
          Deprecated. use JPPFJobSLA.setExecutionPolicy(ExecutionPolicy) instead.
 void setId(String id)
          Set the user-defined display name for this job.
 void setJobMetadata(JPPFJobMetadata jobMetadata)
          Set this job's metadata.
 void setJobSLA(JPPFJobSLA jobSLA)
          Get the service level agreement between the job and the server.
 void setPriority(int priority)
          Deprecated. use JPPFJobSLA.setPriority(int) instead.
 void setResultListener(TaskResultListener resultsListener)
          Set the listener that receives notifications of completed tasks.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JPPFJob

public JPPFJob()
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.


JPPFJob

public JPPFJob(String jobUuid)
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.

JPPFJob

public JPPFJob(DataProvider dataProvider)
Initialize a blocking job with the specified parameters.

Parameters:
dataProvider - the container for data shared between tasks.

JPPFJob

public JPPFJob(DataProvider dataProvider,
               JPPFJobSLA jobSLA)
Initialize a blocking job with the specified parameters.

Parameters:
dataProvider - the container for data shared between tasks.
jobSLA - sevice level agreement between job and server.

JPPFJob

public JPPFJob(TaskResultListener resultsListener)
Initialize a non-blocking job with the specified parameters.

Parameters:
resultsListener - the listener that receives notifications of completed tasks.

JPPFJob

public JPPFJob(DataProvider dataProvider,
               TaskResultListener resultsListener)
Initialize a non-blocking job with the specified parameters.

Parameters:
dataProvider - the container for data shared between tasks.
resultsListener - the listener that receives notifications of completed tasks.

JPPFJob

public JPPFJob(DataProvider dataProvider,
               JPPFJobSLA jobSLA,
               TaskResultListener resultsListener)
Initialize a non-blocking job with the specified parameters.

Parameters:
dataProvider - the container for data shared between tasks.
jobSLA - sevice level agreement between job and server.
resultsListener - the listener that receives notifications of completed tasks.

JPPFJob

public JPPFJob(DataProvider dataProvider,
               JPPFJobSLA jobSLA,
               boolean blocking,
               TaskResultListener resultsListener)
Initialize a job with the specified parameters.

Parameters:
dataProvider - the container for data shared between tasks.
jobSLA - sevice level agreement between job and server.
blocking - determines whether this job is blocking.
resultsListener - the listener that receives notifications of completed tasks.

JPPFJob

public JPPFJob(DataProvider dataProvider,
               JPPFJobSLA jobSLA,
               JPPFJobMetadata jobMetadata,
               boolean blocking,
               TaskResultListener resultsListener)
Initialize a job with the specified parameters.

Parameters:
dataProvider - the container for data shared between tasks.
jobSLA - sevice level agreement between job and server.
jobMetadata - the user-defined job metadata.
blocking - determines whether this job is blocking.
resultsListener - the listener that receives notifications of completed tasks.
Method Detail

getJobUuid

public String getJobUuid()
Get the universal unique id for this job.

Specified by:
getJobUuid in interface JPPFDistributedJob
Returns:
the uuid as a string.

getId

public String getId()
Get the user-defined display name for this job. This is th name displayed in the administration console.

Specified by:
getId in interface JPPFDistributedJob
Returns:
the id as a string.

setId

public void setId(String id)
Set the user-defined display name for this job.

Parameters:
id - the display name as a string.

getTasks

public List<JPPFTask> getTasks()
Get the list of tasks to execute.

Returns:
a list of objects.

addTask

public JPPFTask addTask(Object taskObject,
                        Object... args)
                 throws JPPFException
Add a task to this job. This method is for adding a task that is either an instance of JPPFTask, annotated with JPPFRunnable, or an instance of Runnable or Callable.

Parameters:
taskObject - the task to add to this job.
args - arguments to use with a JPPF-annotated class.
Returns:
an instance of JPPFTask that is either the same as the input if the input is a subclass of JPPFTask, or a wrapper around the input object in the other cases.
Throws:
JPPFException - if one of the tasks is neither a JPPFTask or a JPPF-annotated class.

addTask

public JPPFTask addTask(String method,
                        Object taskObject,
                        Object... args)
                 throws JPPFException
Add a POJO task to this job. The POJO task is identified as a method name associated with either an object for a non-static method, or a class for a static method or for a constructor.

Parameters:
taskObject - the task to add to this job.
method - the name of the method to execute.
args - arguments to use with a JPPF-annotated class.
Returns:
an instance of JPPFTask that is a wrapper around the input task object.
Throws:
JPPFException - if one of the tasks is neither a JPPFTask or a JPPF-annotated class.

getDataProvider

public DataProvider getDataProvider()
Get the container for data shared between tasks.

Returns:
a DataProvider instance.

setDataProvider

public void setDataProvider(DataProvider dataProvider)
Set the container for data shared between tasks.

Parameters:
dataProvider - a DataProvider instance.

getResultListener

public TaskResultListener getResultListener()
Get the listener that receives notifications of completed tasks.

Returns:
a TaskCompletionListener instance.

setResultListener

public void setResultListener(TaskResultListener resultsListener)
Set the listener that receives notifications of completed tasks.

Parameters:
resultsListener - a TaskCompletionListener instance.

isBlocking

public boolean isBlocking()
Determine whether the execution of this job is blocking on the client side.

Returns:
true if the execution is blocking, false otherwise.

setBlocking

public void setBlocking(boolean blocking)
Specify whether the execution of this job is blocking on the client side.

Parameters:
blocking - true if the execution is blocking, false otherwise.

getExecutionPolicy

public ExecutionPolicy getExecutionPolicy()
Deprecated. use JPPFJobSLA.getExecutionPolicy() instead.

Get the tasks execution policy.

Returns:
an ExecutionPolicy instance.

setExecutionPolicy

public void setExecutionPolicy(ExecutionPolicy executionPolicy)
Deprecated. use JPPFJobSLA.setExecutionPolicy(ExecutionPolicy) instead.

Set the tasks execution policy.

Parameters:
executionPolicy - an ExecutionPolicy instance.

getPriority

public int getPriority()
Deprecated. use JPPFJobSLA.getPriority() instead.

Get the priority of this job.

Returns:
the priority as an int.

setPriority

public void setPriority(int priority)
Deprecated. use JPPFJobSLA.setPriority(int) instead.

Set the priority of this job.

Parameters:
priority - the priority as an int.

getJobSLA

public JPPFJobSLA getJobSLA()
Get the service level agreement between the job and the server.

Specified by:
getJobSLA in interface JPPFDistributedJob
Returns:
an instance of JPPFJobSLA.

setJobSLA

public void setJobSLA(JPPFJobSLA jobSLA)
Get the service level agreement between the job and the server.

Parameters:
jobSLA - an instance of JPPFJobSLA.

getJobMetadata

public JPPFJobMetadata getJobMetadata()
Get the user-defined metadata asoociated with this job.

Specified by:
getJobMetadata in interface JPPFDistributedJob
Returns:
a JPPFJobMetadata instance.

setJobMetadata

public void setJobMetadata(JPPFJobMetadata jobMetadata)
Set this job's metadata.

Parameters:
jobMetadata - a JPPFJobMetadata instance.

hashCode

public int hashCode()
COmpute the hascode of this job.

Overrides:
hashCode in class Object
Returns:
th hascode as an int.
See Also:
Object.hashCode()

equals

public boolean equals(Object obj)
Determine whether this object is equal to another.

Overrides:
equals in class Object
Parameters:
obj - the object to compare with.
Returns:
true if the two objects are equal, false otherwise.
See Also:
Object.equals(java.lang.Object)


Copyright © 2005-2010 JPPF Team.