org.jppf.client
Class JPPFResultCollector

java.lang.Object
  extended by org.jppf.client.JPPFResultCollector
All Implemented Interfaces:
EventListener, TaskResultListener

public class JPPFResultCollector
extends Object
implements TaskResultListener

Implementation of the TaskResultListener interface that can be used "as is" to collect the results of an asynchronous job submission.

Author:
Laurent Cohen
See Also:
org.jppf.client.JPPFClient#submitNonBlocking(List, org.jppf.task.storage.DataProvider, TaskResultListener)

Field Summary
protected  int pendingCount
          Count of results notr yet received.
protected  Map<Integer,JPPFTask> resultMap
          A map containing the resulting tasks, ordered by ascending position in the submitted list of tasks.
protected  List<JPPFTask> results
          The list of final resulting tasks.
 
Constructor Summary
JPPFResultCollector(int count)
          Initialize this collector with a specified number of tasks.
 
Method Summary
 List<JPPFTask> getResults()
          Get the list of final results.
 void resultsReceived(TaskResultEvent event)
          Called to notify that the results of a number of tasks have been received from the server.
 List<JPPFTask> waitForResults()
          Wait until all results of a request have been collected.
 List<JPPFTask> waitForResults(long millis)
          Wait until all results of a request have been collected, or the timeout has expired, whichever happens first.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pendingCount

protected int pendingCount
Count of results notr yet received.


resultMap

protected Map<Integer,JPPFTask> resultMap
A map containing the resulting tasks, ordered by ascending position in the submitted list of tasks.


results

protected List<JPPFTask> results
The list of final resulting tasks.

Constructor Detail

JPPFResultCollector

public JPPFResultCollector(int count)
Initialize this collector with a specified number of tasks.

Parameters:
count - the count of submitted tasks.
Method Detail

resultsReceived

public void resultsReceived(TaskResultEvent event)
Called to notify that the results of a number of tasks have been received from the server.

Specified by:
resultsReceived in interface TaskResultListener
Parameters:
event - a notification of completion for a set of submitted tasks.
See Also:
TaskResultListener.resultsReceived(org.jppf.client.event.TaskResultEvent)

waitForResults

public List<JPPFTask> waitForResults()
Wait until all results of a request have been collected.

Returns:
the list of resulting tasks.

waitForResults

public List<JPPFTask> waitForResults(long millis)
Wait until all results of a request have been collected, or the timeout has expired, whichever happens first.

Parameters:
millis - the maximum time to wait, zero meaning an indefinite wait.
Returns:
the list of resulting tasks.

getResults

public List<JPPFTask> getResults()
Get the list of final results.

Returns:
a list of results as tasks, or null if not all tasks have been executed.


Copyright © 2005-2010 JPPF Team.