GridGain™ 2.1.0
Java API Specification

org.gridgain.grid
Interface GridTaskFuture<R>

Type Parameters:
R - Type of the task result returning from GridTask.reduce(java.util.List) method.

@Apache20LicenseCompatible
public interface GridTaskFuture<R>

This class defines a handler for asynchronous task execution. It's similar in design to standard JDK Future interface. Instance of this interface is returned from the following methods:

Migrating to GridGain 2.0

In GridGain 2.0 this interface API has been updated for better static type checking. Although the change is trivial and provides much better type safety during development - it introduced incompatibility with prior versions of GridGain. Follow this link for easy source code migration instructions.



See Also:

  Documentation
  Email Support
  Online Forums
  Issue Tracking

Author:   2005-2008 Copyright © GridGain Systems. All Rights Reserved. ver. 2.1.0

 

Method Summary
 void cancel()
          Cancels this task.
 R get()
          Synchronously waits for task completion and returns task computation result.
 R get(long timeout)
          Synchronously waits if necessary for at most the given time for task completion and returns task computation result.
 GridTaskSession getTaskSession()
          Gets task session of execution grid task.
 boolean isCancelled()
          Returns true if this task was cancelled before it completed normally.
 boolean isDone()
          Checks if task is finished.
 

Method Detail

getTaskSession

GridTaskSession getTaskSession()
Gets task session of execution grid task.

Returns:
Task session.

get

R get()
      throws GridTaskTimeoutException,
             GridException
Synchronously waits for task completion and returns task computation result. If task computation caused an exception, then it gets thrown out of this method.

Throws:
GridTaskTimeoutException - If task execution has timed out. Note that physically task may still be executing, as there is no practical way to stop it (however, every job within task will receive interrupt call).
GridException - If task execution resulted in exception.
Returns:
Task computation result.

get

R get(long timeout)
      throws GridTaskTimeoutException,
             GridException
Synchronously waits if necessary for at most the given time for task completion and returns task computation result. If task computation caused an exception, then it gets thrown out of this method.

Throws:
GridTaskTimeoutException - If task execution has timed out. Note that physically task may still be executing, as there is no practical way to stop it (however, every job within task will receive interrupt call).
GridException - If task execution resulted in exception.
Parameters:
timeout - The maximum timeout in milliseconds.
Returns:
Task computation result.

cancel

void cancel()
            throws GridException
Cancels this task.

Note, that there is no guarantee that a task will be cancelled after invoking this method. Implementation will attempt to cancel all jobs spawned by this task by calling GridJob.cancel(), but it is up to the actual GridJob implementation to react on it and cancel the execution. There is also no guarantee that every job spawned by the task will get the cancellation request, especially if a job was traveling on the network at the time the cancel request was issued.

Throws:
GridException - If task cancellation request was not successfully sent to all participating nodes.

isDone

boolean isDone()
Checks if task is finished.

Returns:
true if task is finished, false otherwise.

isCancelled

boolean isCancelled()
Returns true if this task was cancelled before it completed normally.

Returns:
true if this task was cancelled before it completed normally.

GridGain™ 2.1.0
Java API Specification

GridGain™ - Grid Computing Made Simple, ver. 2.1.0.19122008
2005-2008 Copyright © GridGain Systems. All Rights Reserved.