org.apache.ignite.internal.visor.compute

## Class VisorGatewayTask

- java.lang.Object
- - org.apache.ignite.internal.visor.compute.VisorGatewayTask

All Implemented Interfaces:
  Serializable, ComputeTask<Object[],Object>

    @GridInternal
    public class VisorGatewayTask
    extends Object
    implements ComputeTask<Object[],Object>

Task to run Visor tasks through http REST.

See Also:
  Serialized Form

### Field Summary

Fields
`protected IgniteEx` `ignite` Auto-injected grid instance.

### Constructor Summary

Constructors
Constructor and Description
`VisorGatewayTask()`

### Method Summary

All Methods Instance Methods Concrete Methods
`@NotNull Map<? extends ComputeJob,ClusterNode>` `map(List<ClusterNode> subgrid, @Nullable Object[] args)` This method is called to map or split grid task into multiple grid jobs.
`@Nullable Object` `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`

### Field Detail

#### ignite

    @IgniteInstanceResource
    protected transient IgniteEx ignite

Auto-injected grid instance.

### Constructor Detail

#### VisorGatewayTask

    public VisorGatewayTask()

### Method Detail

#### map

    @NotNull
    public @NotNull Map<? extends ComputeJob,ClusterNode> map(List<ClusterNode> subgrid,
                                                                       @Nullable
                                                                       @Nullable Object[] args)
                                                                throws IgniteException

This method is called to map or split grid task into multiple grid jobs. This is the first method that gets called when task execution starts.

Specified by:
  `map` in interface `ComputeTask<Object[],Object>`
Parameters:
  `subgrid` - Nodes available for this task execution. Note that order of nodes is guaranteed to be randomized by container. This ensures that every time you simply iterate through grid nodes, the order of nodes will be random which over time should result into all nodes being used equally.
  `args` - Task execution argument. Can be `null`. This is the same argument as the one passed into `Grid#execute(...)` methods.
Returns:
  Map of grid jobs assigned to subgrid node. Unless `ComputeTaskContinuousMapper` is injected into task, if `null` or empty map is returned, exception will be thrown.
Throws:
  `IgniteException` - If mapping could not complete successfully. This exception will be thrown out of `ComputeTaskFuture.get()` method.

#### result

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

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[],Object>`
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.
Throws:
  `IgniteException` - If handling a job result caused an error. This exception will be thrown out of `ComputeTaskFuture.get()` method.

#### reduce

    @Nullable
    public @Nullable Object reduce(List<ComputeJobResult> results)
                                      throws IgniteException

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[],Object>`
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.
Throws:
  `IgniteException` - If reduction or results caused an error. This exception will be thrown out of `ComputeTaskFuture.get()` method.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022