com.parabon.client
Interface TaskProxy


public interface TaskProxy

The interface to control an active task and query its state. Once obtained, an instance of this interface remains valid until the associated task, its job, or the session has been destroyed, or the task or job removed.

A TaskProxy instance is obtained through a Job, either at task creation time (via Job.addTask()TaskEvent in a listener or via Job.getTaskIterator()).


Field Summary
static java.lang.String TASK_ID_ATTRIBUTE
           
 
Method Summary
 void addListener(TaskEventListener listener)
          Add a listener to the task.
 void destroy()
          Remove all local references to a task, and if it is running locally, end its execution.
 java.util.Map<java.lang.String,java.lang.String> getAttributes()
          Get the attribute list for the task; if no associated attributes exist, an empty map will be returned.
 Job getJob()
          Get the Job of which this task is a part.
 void remove()
          Request that a task's execution end and that all references to it be removed, locally and remotely.
 void removeAllListeners()
          Remove all listeners from a task's listener list.
 void removeListener(TaskEventListener listener)
          Remove a given listener from a task's listener list, if it exists.
 void start()
          Begin execution of the task.
 void stop()
          Request that the execution of a task be stopped.
 void stop(int blockMillis)
          Deprecated. - use stop() method instead
 

Field Detail

TASK_ID_ATTRIBUTE

static final java.lang.String TASK_ID_ATTRIBUTE
See Also:
Constant Field Values
Method Detail

getAttributes

java.util.Map<java.lang.String,java.lang.String> getAttributes()
Get the attribute list for the task; if no associated attributes exist, an empty map will be returned. Returned Map should be treated as an accessor only; any changes will result in undefined behaviour of undefined scope.


getJob

Job getJob()
Get the Job of which this task is a part.


addListener

void addListener(TaskEventListener listener)
Add a listener to the task. The listener will be sent any events occurring on this task for which the listener implements relevant interfaces. The order in which task-level listeners are called is not defined, but all task-level listeners will be invoked for a given event before any job-level listeners.

It is highly recommended that listeners perform only very brief, lightweight actions. In particular, listeners should never call methods that block waiting for task, job, or session state changes to occur.

If a single listener is added to the same task more than once, it may or may not receive any given events more than once.

A task with registered listeners will not be automatically released.


removeListener

void removeListener(TaskEventListener listener)
Remove a given listener from a task's listener list, if it exists.


removeAllListeners

void removeAllListeners()
Remove all listeners from a task's listener list.


destroy

void destroy()
Remove all local references to a task, and if it is running locally, end its execution. Note that if the task exists remotely, it will not be stopped as a result of this call, nor will it be affected in any way.

All task listeners will be removed automatically.


remove

void remove()
Request that a task's execution end and that all references to it be removed, locally and remotely. All listeners will be removed automatically as well. Note, however, that the task may continue to execute for some period of time, and any events it generates as a result may still be sent to Job.


start

void start()
           throws java.lang.IllegalStateException
Begin execution of the task. The mechanism used to execute the task, for instance local execution, remote execution, or simulated remote execution are defined by the SessionManager and Job which own the task.

Note that in general, it is recommended that any listeners be attached to a task or job just before starting the task rather than just after, so that they do not miss events.

Throws:
java.lang.IllegalStateException - if the task or job have already been removed.

stop

void stop(int blockMillis)
          throws TimeoutException
Deprecated. - use stop() method instead

Request that the execution of a task be stopped. Blocks for at most approximately the specified number of milliseconds (or indefinitely if a negative number is supplied) or until it has been verified that the task has ceased executing; if a nonzero number of milliseconds is supplied and the task cannot be stopped in that time, a TimeoutException is thrown.

This method should never be called from within a listener unless blockMillis == -1.

Throws:
TimeoutException

stop

void stop()
Request that the execution of a task be stopped. Partial results will returned if they exist.