org.jppf.server.protocol
Class JPPFTaskBundle

java.lang.Object
  extended by org.jppf.server.protocol.JPPFTaskBundle
All Implemented Interfaces:
Serializable, Comparable<JPPFTaskBundle>, JPPFDistributedJob

public class JPPFTaskBundle
extends Object
implements Serializable, Comparable<JPPFTaskBundle>, JPPFDistributedJob

Instances of this class group tasks from the same client together, so they are sent to the same node, avoiding unnecessary transport overhead.
The goal is to provide a performance enhancement through an adaptive bundling of tasks originating from the same client. The bundle size is computed dynamically, depending on the number of nodes connected to the server, and other factors.

Author:
Laurent Cohen
See Also:
Serialized Form

Nested Class Summary
static class JPPFTaskBundle.State
          Type safe enumeration for the values of the bundle state.
 
Constructor Summary
JPPFTaskBundle()
          Initialize this task bundle and set its build number.
 
Method Summary
 int compareTo(JPPFTaskBundle bundle)
          Compare two task bundles, based on their respective priorities.
 JPPFTaskBundle copy()
          Make a copy of this bundle.
 JPPFTaskBundle copy(int nbTasks)
          Make a copy of this bundle containing only the first nbTasks tasks it contains.
 int getBuildNumber()
          Get the build number under which this task bundle was created.
 String getBundleUuid()
          Get the unique identifier for this task bundle.
 TaskCompletionListener getCompletionListener()
          Get the task completion listener to notify, once the execution of this task has completed.
 byte[] getDataProvider()
          Get shared data provider for this task.
 long getExecutionStartTime()
          Get the time at which the bundle is taken out of the queue for sending to a node.
 String getId()
          Get the user-defined display name for this job.
 int getInitialTaskCount()
          Get the initial task count of this bundle.
 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.
 long getNodeExecutionTime()
          Get the time it took a node to execute this task.
 Object getParameter(Object name)
          Get the value of a parameter of this request.
 Object getParameter(Object name, Object defaultValue)
          Get the value of a parameter of this request.
 Map<Object,Object> getParametersMap()
          Get the map holding the parameters of the request.
 long getQueueEntryTime()
          Get the time at which this wrapper was added to the queue.
 String getRequestUuid()
          Get the unique identifier for the request this task is a part of.
 JPPFTaskBundle.State getState()
          Get the state of this bundle.
 int getTaskCount()
          Get the number of tasks in this bundle.
 List<byte[]> getTasks()
          Get the tasks to be executed by the node.
 TraversalList<String> getUuidPath()
          Get the uuid path of the applications (driver or client) in whose classpath the class definition may be found.
 Object removeParameter(Object name)
          Remove a parameter from this request.
 void setBundleUuid(String uuid)
          Set the unique identifier for this task bundle.
 void setCompletionListener(TaskCompletionListener listener)
          Set the task completion listener to notify, once the execution of this task has completed.
 void setDataProvider(byte[] dataProvider)
          Set shared data provider for this task.
 void setExecutionStartTime(long executionStartTime)
          Set the time at which the bundle is taken out of the queue for sending to a node.
 void setJobSLA(JPPFJobSLA jobSLA)
          Get the service level agreement between the job and the server.
 void setNodeExecutionTime(long nodeExecutionTime)
          Set the time it took a node to execute this task.
 void setParameter(Object name, Object value)
          Set a parameter of this request.
 void setQueueEntryTime(long queueEntryTime)
          Set the time at which this wrapper was added to the queue.
 void setRequestUuid(String requestUuid)
          Set the unique identifier for the request this task is a part of.
 void setState(JPPFTaskBundle.State state)
          Set the state of this bundle.
 void setTaskCount(int taskCount)
          Set the number of tasks in this bundle.
 void setTasks(List<byte[]> tasks)
          Set the tasks to be executed by the node.
 void setUuidPath(TraversalList<String> uuidPath)
          Set the uuid path of the applications (driver or client) in whose classpath the class definition may be found.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JPPFTaskBundle

public JPPFTaskBundle()
Initialize this task bundle and set its build number.

Method Detail

getBundleUuid

public String getBundleUuid()
Get the unique identifier for this task bundle.

Returns:
the uuid as a string.

setBundleUuid

public void setBundleUuid(String uuid)
Set the unique identifier for this task bundle.

Parameters:
uuid - the uuid as a string.

getRequestUuid

public String getRequestUuid()
Get the unique identifier for the request this task is a part of.

Returns:
the request uuid as a string.

setRequestUuid

public void setRequestUuid(String requestUuid)
Set the unique identifier for the request this task is a part of.

Parameters:
requestUuid - the request uuid as a string.

getDataProvider

public byte[] getDataProvider()
Get shared data provider for this task.

Returns:
a DataProvider instance.

setDataProvider

public void setDataProvider(byte[] dataProvider)
Set shared data provider for this task.

Parameters:
dataProvider - a DataProvider instance.

getUuidPath

public TraversalList<String> getUuidPath()
Get the uuid path of the applications (driver or client) in whose classpath the class definition may be found.

Returns:
the uuid path as a list of string elements.

setUuidPath

public void setUuidPath(TraversalList<String> uuidPath)
Set the uuid path of the applications (driver or client) in whose classpath the class definition may be found.

Parameters:
uuidPath - the uuid path as a list of string elements.

getQueueEntryTime

public long getQueueEntryTime()
Get the time at which this wrapper was added to the queue.

Returns:
the time 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 as a long value.

getNodeExecutionTime

public long getNodeExecutionTime()
Get the time it took a node to execute this task.

Returns:
the time in milliseconds as a long value.

setNodeExecutionTime

public void setNodeExecutionTime(long nodeExecutionTime)
Set the time it took a node to execute this task.

Parameters:
nodeExecutionTime - the time in milliseconds as a long value.

getTasks

public List<byte[]> getTasks()
Get the tasks to be executed by the node.

Returns:
the tasks as a List of arrays of bytes.

setTasks

public void setTasks(List<byte[]> tasks)
Set the tasks to be executed by the node.

Parameters:
tasks - the tasks as a List of arrays of bytes.

getTaskCount

public int getTaskCount()
Get the number of tasks in this bundle.

Returns:
the number of tasks as an int.

setTaskCount

public void setTaskCount(int taskCount)
Set the number of tasks in this bundle.

Parameters:
taskCount - the number of tasks as an int.

getCompletionListener

public TaskCompletionListener getCompletionListener()
Get the task completion listener to notify, once the execution of this task has completed.

Returns:
a TaskCompletionListener instance.

setCompletionListener

public void setCompletionListener(TaskCompletionListener listener)
Set the task completion listener to notify, once the execution of this task has completed.

Parameters:
listener - a TaskCompletionListener instance.

compareTo

public int compareTo(JPPFTaskBundle bundle)
Compare two task bundles, based on their respective priorities.
Note: this class has a natural ordering that is inconsistent with equals.

Specified by:
compareTo in interface Comparable<JPPFTaskBundle>
Parameters:
bundle - the bundle compare this one to.
Returns:
a positive int if this bundle is greater, 0 if both are equal, or a negative int if this bundless is less than the other.
See Also:
Comparable.compareTo(java.lang.Object)

getBuildNumber

public int getBuildNumber()
Get the build number under which this task bundle was created.

Returns:
the build number as an int value.

copy

public JPPFTaskBundle copy()
Make a copy of this bundle.

Returns:
a new JPPFTaskBundle instance.

copy

public JPPFTaskBundle copy(int nbTasks)
Make a copy of this bundle containing only the first nbTasks tasks it contains.

Parameters:
nbTasks - the number of tasks to include in the copy.
Returns:
a new JPPFTaskBundle instance.

getState

public JPPFTaskBundle.State getState()
Get the state of this bundle.

Returns:
a State type safe enumeration value.

setState

public void setState(JPPFTaskBundle.State state)
Set the state of this bundle.

Parameters:
state - a State type safe enumeration value.

getExecutionStartTime

public long getExecutionStartTime()
Get the time at which the bundle is taken out of the queue for sending to a node.

Returns:
the time as a long value.

setExecutionStartTime

public void setExecutionStartTime(long executionStartTime)
Set the time at which the bundle is taken out of the queue for sending to a node.

Parameters:
executionStartTime - the time as a long value.

getInitialTaskCount

public int getInitialTaskCount()
Get the initial task count of this bundle.

Returns:
the task count as an int.

setParameter

public void setParameter(Object name,
                         Object value)
Set a parameter of this request.

Parameters:
name - the name of the parameter to set.
value - the value of the parameter to set.

getParameter

public Object getParameter(Object name)
Get the value of a parameter of this request.

Parameters:
name - the name of the parameter to get.
Returns:
the value of the parameter, or null if the parameter is not set.

getParameter

public Object getParameter(Object name,
                           Object defaultValue)
Get the value of a parameter of this request.

Parameters:
name - the name of the parameter to get.
defaultValue - the default value to return if the parameter is not set.
Returns:
the value of the parameter, or defaultValue if the parameter is not set.

removeParameter

public Object removeParameter(Object name)
Remove a parameter from this request.

Parameters:
name - the name of the parameter to remove.
Returns:
the value of the parameter to remove, or null if the parameter is not set.

getParametersMap

public Map<Object,Object> getParametersMap()
Get the map holding the parameters of the request.

Returns:
a map of string keys to object values.

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.

toString

public String toString()

Overrides:
toString in class Object

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.

getJobMetadata

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

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

getJobUuid

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

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


Copyright © 2005-2010 JPPF Team.