Package org.apache.ignite.internal.visor
Class VisorMultiNodeTask<A,R,J>
- java.lang.Object
-
- org.apache.ignite.internal.visor.VisorMultiNodeTask<A,R,J>
-
- Type Parameters:
A- Task argument type.R- Task result type.J- Job result type
- All Implemented Interfaces:
Serializable,ComputeTask<VisorTaskArgument<A>,VisorTaskResult<R>>
- Direct Known Subclasses:
AbstractConsistencyTask,CacheDistributionTask,CacheGroupEncryptionTask,CdcCacheDataResendTask,CdcDeleteLostSegmentsTask,CheckIndexInlineSizesTask,ClientConnectionDropTask,ConnectivityTask,ConsistencyCancelTask,ContentionTask,DefragmentationTask,FetchNearXidVersionTask,FindAndDeleteGarbageInPersistenceTask,IndexForceRebuildTask,IndexRebuildStatusTask,KillTransactionTask,MetadataInfoTask,MetadataRemoveTask,MetadataUpdateTask,PageLocksTask,PropertiesListTask,PropertyTask,ReencryptionRateTask,ScheduleIndexRebuildTask,SnapshotStatusTask,SystemViewTask,TxTask,ValidateIndexesTask,VisorOneNodeTask,WalTask
public abstract class VisorMultiNodeTask<A,R,J> extends Object implements ComputeTask<VisorTaskArgument<A>,VisorTaskResult<R>>
Base class for Visor tasks intended to query data from a multiple node.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description VisorMultiNodeTask()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract VisorJob<A,J>job(A arg)protected Collection<UUID>jobNodes(VisorTaskArgument<A> arg)@NotNull Map<? extends ComputeJob,ClusterNode>map(List<ClusterNode> subgrid, VisorTaskArgument<A> arg)This method is called to map or split grid task into multiple grid jobs.protected Map<? extends ComputeJob,ClusterNode>map0(List<ClusterNode> subgrid, VisorTaskArgument<A> arg)Actual map logic.@Nullable VisorTaskResult<R>reduce(List<ComputeJobResult> results)Reduces (or aggregates) results received so far into one compound result to be returned to caller viaComputeTaskFuture.get()method.protected abstract Rreduce0(List<ComputeJobResult> results)Actual reduce logic.ComputeJobResultPolicyresult(ComputeJobResult res, List<ComputeJobResult> rcvd)Asynchronous callback invoked every time a result from remote execution is received.
-
-
-
Field Detail
-
ignite
@IgniteInstanceResource protected transient IgniteEx ignite
Auto-injected grid instance.
-
debug
protected boolean debug
Debug flag.
-
taskArg
protected A taskArg
Task argument.
-
start
protected long start
Task start time.
-
-
Method Detail
-
map
@NotNull public @NotNull Map<? extends ComputeJob,ClusterNode> map(List<ClusterNode> subgrid, VisorTaskArgument<A> arg)
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:
mapin interfaceComputeTask<A,R>- 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.arg- Task execution argument. Can benull. This is the same argument as the one passed intoGrid#execute(...)methods.- Returns:
- Map of grid jobs assigned to subgrid node. Unless
ComputeTaskContinuousMapperis injected into task, ifnullor empty map is returned, exception will be thrown.
-
jobNodes
protected Collection<UUID> jobNodes(VisorTaskArgument<A> arg)
- Returns:
- Collection of nodes IDs where jobs should be mapped.
-
map0
protected Map<? extends ComputeJob,ClusterNode> map0(List<ClusterNode> subgrid, VisorTaskArgument<A> arg)
Actual map logic.- Parameters:
arg- Task execution argument.subgrid- Nodes available for this task execution.- Returns:
- Map of grid jobs assigned to subgrid node.
- Throws:
IgniteException- If mapping could not complete successfully.
-
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. SeeComputeJobResultPolicyfor more information about result policies.- Specified by:
resultin interfaceComputeTask<A,R>- Parameters:
res- Received remote grid executable result.rcvd- All previously received results. Note that if task class hasComputeTaskNoResultCacheannotation, then this list will be empty.- Returns:
- Result policy that dictates how to process further upcoming job results.
-
reduce0
@Nullable protected abstract R reduce0(List<ComputeJobResult> results) throws IgniteException
Actual reduce logic.- Parameters:
results- Job results.- Returns:
- Task result.
- Throws:
IgniteException- If reduction or results caused an error.
-
reduce
@Nullable public final @Nullable VisorTaskResult<R> reduce(List<ComputeJobResult> results)
Reduces (or aggregates) results received so far into one compound result to be returned to caller viaComputeTaskFuture.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:
reducein interfaceComputeTask<A,R>- Parameters:
results- Received results of broadcasted remote executions. Note that if task class hasComputeTaskNoResultCacheannotation, then this list will be empty.- Returns:
- Grid job result constructed from results of remote executions.
-
-