org.jppf.server
Class AbstractResultSender

java.lang.Object
  extended by org.jppf.server.AbstractResultSender
All Implemented Interfaces:
TaskCompletionListener
Direct Known Subclasses:
PeerNodeResultSender

public abstract class AbstractResultSender
extends Object
implements TaskCompletionListener

Author:
Laurent Cohen

Field Summary
protected  boolean asynch
          Determines whether results can be sent asynchronously, or if we must wait until all tasks have been completed.
protected  SerializationHelper helper
          Used to serialize and deserialize the tasks data.
protected  SocketWrapper socketClient
          The socket client used to communicate over a socket connection.
 
Constructor Summary
AbstractResultSender(SocketWrapper socketClient, boolean asynch)
          Initialize this result sender with a specified socket client.
 
Method Summary
protected  int getPendingTasksCount()
          Get the number of tasks that haven't yet been executed.
protected  List<BundleWrapper> getResultList()
          Get the list of task bundles whose execution has been completed.
 void run(int count)
          Wait for executed task bundles and send them back to the client.
abstract  void sendPartialResults(BundleWrapper bundle)
          Send the results of the tasks in a bundle back to the client who submitted the request.
protected  void setPendingTasksCount(int pendingTasksCount)
          Set the number of tasks that haven't yet been executed.
protected  void setResultList(List<BundleWrapper> resultList)
          Set the list of task bundles whose execution has been completed.
 void taskCompleted(BundleWrapper result)
          Callback method invoked when the execution of a task has completed.
 void waitForExecution()
          This method waits until all tasks of a request have been completed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

helper

protected SerializationHelper helper
Used to serialize and deserialize the tasks data.


socketClient

protected SocketWrapper socketClient
The socket client used to communicate over a socket connection.


asynch

protected boolean asynch
Determines whether results can be sent asynchronously, or if we must wait until all tasks have been completed.

Constructor Detail

AbstractResultSender

public AbstractResultSender(SocketWrapper socketClient,
                            boolean asynch)
Initialize this result sender with a specified socket client.

Parameters:
socketClient - the socket client used to send results back.
asynch - determines whether results can be sent asynchronously, or if it must wait until all tasks have been completed.
Method Detail

run

public void run(int count)
         throws Exception
Wait for executed task bundles and send them back to the client.

Parameters:
count - the number of tasks that must be executed.
Throws:
Exception - if an error occurs while sending one or more task bundles.

sendPartialResults

public abstract void sendPartialResults(BundleWrapper bundle)
                                 throws Exception
Send the results of the tasks in a bundle back to the client who submitted the request.

Parameters:
bundle - the bundle to get the task results from.
Throws:
Exception - if an IO exception occurred while sending the results back.

waitForExecution

public void waitForExecution()
                      throws Exception
This method waits until all tasks of a request have been completed.

Throws:
Exception - if handing of the results fails.

taskCompleted

public void taskCompleted(BundleWrapper result)
Callback method invoked when the execution of a task has completed. This method triggers a check of the request completion status. When all tasks have completed, this connection sends all results back.

Specified by:
taskCompleted in interface TaskCompletionListener
Parameters:
result - the result of the task's execution.

setPendingTasksCount

protected void setPendingTasksCount(int pendingTasksCount)
Set the number of tasks that haven't yet been executed.

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

getPendingTasksCount

protected int getPendingTasksCount()
Get the number of tasks that haven't yet been executed.

Returns:
the number of tasks as an int.

setResultList

protected void setResultList(List<BundleWrapper> resultList)
Set the list of task bundles whose execution has been completed.

Parameters:
resultList - a list of BundleWrapper instances.

getResultList

protected List<BundleWrapper> getResultList()
Get the list of task bundles whose execution has been completed.

Returns:
a list of JPPFTaskBundle instances.


Copyright © 2005-2010 JPPF Team.