Class GridTaskProcessor
- java.lang.Object
-
- org.apache.ignite.internal.processors.GridProcessorAdapter
-
- org.apache.ignite.internal.processors.task.GridTaskProcessor
-
- All Implemented Interfaces:
GridComponent,IgniteChangeGlobalStateSupport,GridProcessor
public class GridTaskProcessor extends GridProcessorAdapter implements IgniteChangeGlobalStateSupport
This class defines task processor.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent
GridComponent.DiscoveryDataExchangeType
-
-
Field Summary
Fields Modifier and Type Field Description static StringTASKS_VIEWstatic StringTASKS_VIEW_DESCstatic StringTOTAL_EXEC_TASKSTotal executed tasks metric name.-
Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter
ctx, diagnosticLog, log
-
-
Constructor Summary
Constructors Constructor Description GridTaskProcessor(GridKernalContext ctx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancel(IgniteUuid sesId)Handles user cancellation.<T,R>
ComputeTaskInternalFuture<R>execute(Class<? extends ComputeTask<T,R>> taskCls, T arg)<T,R>
ComputeTaskInternalFuture<R>execute(Class<? extends ComputeTask<T,R>> taskCls, T arg, TaskExecutionOptions opts)<T,R>
ComputeTaskInternalFuture<R>execute(String taskName, T arg)<T,R>
ComputeTaskInternalFuture<R>execute(String taskName, T arg, @Nullable TaskExecutionOptions opts)<T,R>
ComputeTaskInternalFuture<R>execute(ComputeTask<T,R> task, T arg)<T,R>
ComputeTaskInternalFuture<R>execute(ComputeTask<T,R> task, T arg, TaskExecutionOptions opts)Map<String,GridDeployment>getUsedDeploymentMap()Gets currently used deployments mapped by task name or aliases.Collection<GridDeployment>getUsedDeployments()Gets currently used deployments.Map<ComputeJobStatusEnum,Long>jobStatuses(IgniteUuid sesId)Collects statistics on jobs locally, only for those jobs that have already sent a response or are being executed locally.voidlistenStatusUpdates(ComputeGridMonitor monitor)Subscription to update the status of tasks.voidonActivate(GridKernalContext kctx)Called when cluster performing activation.voidonDeActivate(GridKernalContext kctx)Called when cluster performing deactivation.voidonDisconnected(IgniteFuture<?> reconnectFut)Client disconnected callback.voidonKernalStart(boolean active)Callback that notifies that kernal has successfully started, including all managers and processors.voidonKernalStop(boolean cancel)Callback to notify that kernal is about to stop.voidprintMemoryStats()Prints memory statistics (sizes of internal structures, etc.).voidprocessJobExecuteResponse(UUID nodeId, GridJobExecuteResponse msg)voidresetMetrics()Resets processor metrics.StringresolveTaskName(int taskNameHash)Resolves task name by task name hash.voidsetAttributes(GridTaskSessionImpl ses, Map<?,?> attrs)voidstart()Starts grid component.voidstop(boolean cancel)Stops grid component.voidstopListenStatusUpdates(ComputeGridMonitor monitor)Unsubscribe to update the status of tasks.<R> @Nullable ComputeTaskInternalFuture<R>taskFuture(IgniteUuid sesId)<R> Map<IgniteUuid,ComputeTaskFuture<R>>taskFutures()-
Methods inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter
assertParameter, collectGridNodeData, collectJoiningNodeData, discoveryDataType, onGridDataReceived, onJoiningNodeDataReceived, onReconnected, toString, validateNode, validateNode
-
-
-
-
Field Detail
-
TASKS_VIEW
public static final String TASKS_VIEW
- See Also:
- Constant Field Values
-
TASKS_VIEW_DESC
public static final String TASKS_VIEW_DESC
- See Also:
- Constant Field Values
-
TOTAL_EXEC_TASKS
public static final String TOTAL_EXEC_TASKS
Total executed tasks metric name.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GridTaskProcessor
public GridTaskProcessor(GridKernalContext ctx)
- Parameters:
ctx- Kernal context.
-
-
Method Detail
-
start
public void start()
Starts grid component.- Specified by:
startin interfaceGridComponent- Overrides:
startin classGridProcessorAdapter
-
onKernalStart
public void onKernalStart(boolean active) throws IgniteCheckedExceptionCallback that notifies that kernal has successfully started, including all managers and processors.- Specified by:
onKernalStartin interfaceGridComponent- Overrides:
onKernalStartin classGridProcessorAdapter- Parameters:
active- Cluster active flag (note: should be used carefully since state can change concurrently).- Throws:
IgniteCheckedException- Thrown in case of any errors.
-
onDisconnected
public void onDisconnected(IgniteFuture<?> reconnectFut) throws IgniteCheckedException
Client disconnected callback.- Specified by:
onDisconnectedin interfaceGridComponent- Overrides:
onDisconnectedin classGridProcessorAdapter- Parameters:
reconnectFut- Reconnect future.- Throws:
IgniteCheckedException- If failed.
-
onKernalStop
public void onKernalStop(boolean cancel)
Callback to notify that kernal is about to stop.- Specified by:
onKernalStopin interfaceGridComponent- Overrides:
onKernalStopin classGridProcessorAdapter- Parameters:
cancel- Flag indicating whether jobs should be canceled.
-
stop
public void stop(boolean cancel)
Stops grid component.- Specified by:
stopin interfaceGridComponent- Overrides:
stopin classGridProcessorAdapter- Parameters:
cancel- Iftrue, then all ongoing tasks or jobs for relevant components need to be cancelled.
-
getUsedDeployments
public Collection<GridDeployment> getUsedDeployments()
Gets currently used deployments.- Returns:
- Currently used deployments.
-
getUsedDeploymentMap
public Map<String,GridDeployment> getUsedDeploymentMap()
Gets currently used deployments mapped by task name or aliases.- Returns:
- Currently used deployments.
-
execute
public <T,R> ComputeTaskInternalFuture<R> execute(Class<? extends ComputeTask<T,R>> taskCls, @Nullable T arg)
- Type Parameters:
T- Task argument type.R- Task return value type.- Parameters:
taskCls- Task class.arg- Optional execution argument.- Returns:
- Task future.
-
execute
public <T,R> ComputeTaskInternalFuture<R> execute(Class<? extends ComputeTask<T,R>> taskCls, @Nullable T arg, TaskExecutionOptions opts)
- Type Parameters:
T- Task argument type.R- Task return value type.- Parameters:
taskCls- Task class.arg- Optional execution argument.opts- Task execution options.- Returns:
- Task future.
-
execute
public <T,R> ComputeTaskInternalFuture<R> execute(ComputeTask<T,R> task, @Nullable T arg)
- Type Parameters:
T- Task argument type.R- Task return value type.- Parameters:
task- Actual task.arg- Optional task argument.- Returns:
- Task future.
-
execute
public <T,R> ComputeTaskInternalFuture<R> execute(ComputeTask<T,R> task, @Nullable T arg, TaskExecutionOptions opts)
- Type Parameters:
T- Task argument type.R- Task return value type.- Parameters:
task- Actual task.arg- Optional task argument.opts- Task execution options.- Returns:
- Task future.
-
resolveTaskName
public String resolveTaskName(int taskNameHash)
Resolves task name by task name hash.- Parameters:
taskNameHash- Task name hash.- Returns:
- Task name or
nullif not found.
-
execute
public <T,R> ComputeTaskInternalFuture<R> execute(String taskName, @Nullable T arg)
- Type Parameters:
T- Task argument type.R- Task return value type.- Parameters:
taskName- Task name.arg- Optional execution argument.- Returns:
- Task future.
-
execute
public <T,R> ComputeTaskInternalFuture<R> execute(String taskName, @Nullable T arg, @Nullable @Nullable TaskExecutionOptions opts)
- Type Parameters:
T- Task argument type.R- Task return value type.- Parameters:
taskName- Task name.arg- Optional execution argument.opts- Task execution options.- Returns:
- Task future.
-
taskFuture
@Nullable public <R> @Nullable ComputeTaskInternalFuture<R> taskFuture(IgniteUuid sesId)
- Parameters:
sesId- Task's session id.- Returns:
- A
ComputeTaskInternalFutureinstance ornullif no such task found.
-
taskFutures
public <R> Map<IgniteUuid,ComputeTaskFuture<R>> taskFutures()
- Returns:
- Active task futures.
-
setAttributes
public void setAttributes(GridTaskSessionImpl ses, Map<?,?> attrs) throws IgniteCheckedException
- Parameters:
ses- Task session.attrs- Attributes.- Throws:
IgniteCheckedException- Thrown in case of any errors.
-
processJobExecuteResponse
public void processJobExecuteResponse(UUID nodeId, GridJobExecuteResponse msg)
- Parameters:
nodeId- Node ID.msg- Execute response message.
-
cancel
public boolean cancel(IgniteUuid sesId)
Handles user cancellation.- Parameters:
sesId- Session ID.- Returns:
- Whether task was cancelled by this call.
-
onActivate
public void onActivate(GridKernalContext kctx) throws IgniteCheckedException
Called when cluster performing activation.- Specified by:
onActivatein interfaceIgniteChangeGlobalStateSupport- Parameters:
kctx- Kernal context.- Throws:
IgniteCheckedException- If failed.
-
onDeActivate
public void onDeActivate(GridKernalContext kctx)
Called when cluster performing deactivation.- Specified by:
onDeActivatein interfaceIgniteChangeGlobalStateSupport- Parameters:
kctx- Kernal context.
-
resetMetrics
public void resetMetrics()
Resets processor metrics.
-
printMemoryStats
public void printMemoryStats()
Prints memory statistics (sizes of internal structures, etc.). NOTE: this method is for testing and profiling purposes only.- Specified by:
printMemoryStatsin interfaceGridComponent- Overrides:
printMemoryStatsin classGridProcessorAdapter
-
listenStatusUpdates
public void listenStatusUpdates(ComputeGridMonitor monitor) throws NodeStoppingException
Subscription to update the status of tasks.NOTE:
ComputeGridMonitor.processStatusSnapshots(java.util.Collection<org.apache.ignite.internal.processors.task.monitor.ComputeTaskStatusSnapshot>)will be called only on subscription, then onlyComputeGridMonitor.processStatusChange(org.apache.ignite.internal.processors.task.monitor.ComputeTaskStatusSnapshot)will be called.- Parameters:
monitor- Task status update monitor.- Throws:
NodeStoppingException- If the node is stopped.
-
stopListenStatusUpdates
public void stopListenStatusUpdates(ComputeGridMonitor monitor)
Unsubscribe to update the status of tasks.- Parameters:
monitor- Task status update monitor.
-
jobStatuses
public Map<ComputeJobStatusEnum,Long> jobStatuses(IgniteUuid sesId)
Collects statistics on jobs locally, only for those jobs that have already sent a response or are being executed locally.- Parameters:
sesId- Task session ID.- Returns:
- Job statistics for the task. Mapping: Job status -> count of jobs.
-
-