org.apache.ignite.internal.processors.platform.compute

## Class PlatformAbstractTask

- java.lang.Object
- - org.apache.ignite.internal.processors.platform.compute.PlatformAbstractTask

All Implemented Interfaces:
  Serializable, ComputeTask<Object,Void>

Direct Known Subclasses:
  PlatformBalancingMultiClosureTask, PlatformBalancingSingleClosureAffinityTask, PlatformBalancingSingleClosureTask, PlatformBroadcastingMultiClosureTask, PlatformBroadcastingSingleClosureTask, PlatformFullTask

    public abstract class PlatformAbstractTask
    extends Object
    implements ComputeTask<Object,Void>

Base class for all interop tasks.

See Also:
  Serialized Form

### Field Summary

Fields
`protected PlatformContext` `ctx` Platform context.
`protected boolean` `done` Done flag.
`protected ReadWriteLock` `lock` Lock for safe access to native pointers.
`protected long` `taskPtr` Pointer to the task in the native platform.

### Constructor Summary

Constructors
`protected` `PlatformAbstractTask(PlatformContext ctx, long taskPtr)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `onDone(Exception e)` Callback invoked when task future is completed and all resources could be safely cleaned up.
`Void` `reduce(List<ComputeJobResult> results)` Reduces (or aggregates) results received so far into one compound result to be returned to caller via `ComputeTaskFuture.get()` method.
`ComputeJobResultPolicy` `result(ComputeJobResult res, List<ComputeJobResult> rcvd)` Asynchronous callback invoked every time a result from remote execution is received.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.ignite.compute.ComputeTask

`map`

### Field Detail

#### ctx

    protected final PlatformContext ctx

Platform context.

#### taskPtr

    protected final long taskPtr

Pointer to the task in the native platform.

#### lock

    protected final ReadWriteLock lock

Lock for safe access to native pointers.

#### done

    protected boolean done

Done flag.

### Constructor Detail

#### PlatformAbstractTask

    protected PlatformAbstractTask(PlatformContext ctx,
                                   long taskPtr)

Constructor.

Parameters:
  `ctx` - Platform context.
  `taskPtr` - Task pointer.

### Method Detail

#### result

    public ComputeJobResultPolicy result(ComputeJobResult res,
                                         List<ComputeJobResult> rcvd)

Asynchronous callback invoked every time a result from remote execution is received. It is ultimately upto this method to return a policy based on which the system will either wait for more results, reduce results received so far, or failover this job to another node. See `ComputeJobResultPolicy` for more information about result policies.

Specified by:
  `result` in interface `ComputeTask<Object,Void>`
Parameters:
  `res` - Received remote grid executable result.
  `rcvd` - All previously received results. Note that if task class has `ComputeTaskNoResultCache` annotation, then this list will be empty.
Returns:
  Result policy that dictates how to process further upcoming job results.

#### reduce

    @Nullable
    public Void reduce(List<ComputeJobResult> results)

Reduces (or aggregates) results received so far into one compound result to be returned to caller via `ComputeTaskFuture.get()` method.

Note, that if some jobs did not succeed and could not be failed over then the list of results passed into this method will include the failed results. Otherwise, failed results will not be in the list.

Specified by:
  `reduce` in interface `ComputeTask<Object,Void>`
Parameters:
  `results` - Received results of broadcasted remote executions. Note that if task class has `ComputeTaskNoResultCache` annotation, then this list will be empty.
Returns:
  Grid job result constructed from results of remote executions.

#### onDone

    public void onDone(Exception e)

Callback invoked when task future is completed and all resources could be safely cleaned up.

Parameters:
  `e` - If failed.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.7.0
Release Date | : November 30 2018