public class GridTaskSessionImpl extends Object implements GridTaskSessionInternal
| Constructor and Description |
|---|
GridTaskSessionImpl(UUID taskNodeId,
String taskName,
GridDeployment dep,
String taskClsName,
IgniteUuid sesId,
Collection<UUID> top,
IgnitePredicate<ClusterNode> topPred,
long startTime,
long endTime,
Collection<ComputeJobSibling> siblings,
Map<Object,Object> attrs,
GridKernalContext ctx,
boolean fullSup,
boolean internal,
UUID subjId,
String execName) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acquire() |
void |
addAttributeListener(ComputeTaskSessionAttributeListener lsnr,
boolean rewind)
Add listener for the session attributes.
|
void |
addJobSiblings(Collection<ComputeJobSibling> siblings) |
protected void |
checkFullSupport() |
GridDeployment |
deployment() |
String |
executorName() |
<K,V> V |
getAttribute(K key)
Gets an attribute set by
ComputeTaskSession.setAttribute(Object, Object) or ComputeTaskSession.setAttributes(Map)
method. |
Map<Object,Object> |
getAttributes()
Gets all attributes.
|
String |
getCheckpointSpi() |
ClassLoader |
getClassLoader()
Gets class loader responsible for loading all classes within task.
|
long |
getEndTime()
Gets end of computation time for the task.
|
String |
getFailoverSpi() |
IgniteUuid |
getId()
Gets session ID of the task being executed.
|
IgniteUuid |
getJobId() |
ComputeJobSibling |
getJobSibling(IgniteUuid jobId)
Gets job sibling for a given ID.
|
Collection<ComputeJobSibling> |
getJobSiblings()
Gets a collection of all grid job siblings.
|
String |
getLoadBalancingSpi() |
long |
getSequenceNumber() |
long |
getStartTime()
Gets start of computation time for the task.
|
String |
getTaskClassName()
Returns task class name.
|
String |
getTaskName()
Gets task name of the task this session belongs to.
|
UUID |
getTaskNodeId()
Gets ID of the node on which task execution originated.
|
Collection<UUID> |
getTopology()
Gets a collection of grid nodes IDs.
|
IgnitePredicate<ClusterNode> |
getTopologyPredicate() |
String |
getUserVersion() |
boolean |
isClosed() |
boolean |
isFullSupport() |
boolean |
isInternal() |
boolean |
isTaskNode() |
<T> T |
loadCheckpoint(String key)
Loads job's state previously saved via
ComputeTaskSession.saveCheckpoint(String, Object, ComputeTaskSessionScope, long)
method from an underlying storage for a given key. |
protected <T> T |
loadCheckpoint0(GridTaskSessionInternal ses,
String key) |
IgniteFuture<?> |
mapFuture()
Gets future that will be completed when task "map" step has completed
(which means that
ComputeTask.map(List, Object) method has finished). |
void |
onClosed()
Closes session.
|
void |
onDone()
Finish task callback.
|
void |
onMapped()
Task map callback.
|
Collection<ComputeJobSibling> |
refreshJobSiblings()
Refreshes collection of job siblings.
|
boolean |
release() |
boolean |
removeAttributeListener(ComputeTaskSessionAttributeListener lsnr)
Removes given listener.
|
boolean |
removeCheckpoint(String key)
Removes previously saved job's state for a given
key from an underlying storage. |
protected boolean |
removeCheckpoint0(GridTaskSessionInternal ses,
String key) |
void |
saveCheckpoint(String key,
Object state)
Saves intermediate state of a job or task to a storage.
|
void |
saveCheckpoint(String key,
Object state,
ComputeTaskSessionScope scope,
long timeout)
Saves intermediate state of a job to a storage.
|
void |
saveCheckpoint(String key,
Object state,
ComputeTaskSessionScope scope,
long timeout,
boolean overwrite)
Saves intermediate state of a job or task to a storage.
|
protected void |
saveCheckpoint0(GridTaskSessionInternal ses,
String key,
Object state,
ComputeTaskSessionScope scope,
long timeout,
boolean overwrite) |
GridTaskSessionInternal |
session() |
void |
setAttribute(Object key,
Object val)
Sets session attributed.
|
void |
setAttributes(Map<?,?> attrs)
Sets task attributes.
|
void |
setCheckpointSpi(String cpSpi) |
void |
setClassLoader(ClassLoader clsLdr) |
void |
setFailoverSpi(String failSpi) |
void |
setInternal(Map<?,?> attrs) |
void |
setJobSiblings(Collection<ComputeJobSibling> siblings) |
void |
setLoadBalancingSpi(String loadSpi) |
UUID |
subjectId() |
String |
toString() |
<K,V> V |
waitForAttribute(K key,
long timeout)
Waits for the specified attribute to be set.
|
boolean |
waitForAttribute(Object key,
Object val,
long timeout)
Waits for the specified attribute to be set or updated with given value.
|
Map<?,?> |
waitForAttributes(Collection<?> keys,
long timeout)
Waits for the specified attributes to be set.
|
boolean |
waitForAttributes(Map<?,?> attrs,
long timeout)
Waits for the specified attributes to be set or updated with given values.
|
public GridTaskSessionImpl(UUID taskNodeId, String taskName, @Nullable GridDeployment dep, String taskClsName, IgniteUuid sesId, @Nullable Collection<UUID> top, @Nullable IgnitePredicate<ClusterNode> topPred, long startTime, long endTime, Collection<ComputeJobSibling> siblings, @Nullable Map<Object,Object> attrs, GridKernalContext ctx, boolean fullSup, boolean internal, UUID subjId, @Nullable String execName)
taskNodeId - Task node ID.taskName - Task name.dep - Deployment.taskClsName - Task class name.sesId - Task session ID.top - Topology.topPred - Topology predicate.startTime - Task execution start time.endTime - Task execution end time.siblings - Collection of siblings.attrs - Session attributes.ctx - Grid Kernal Context.fullSup - Session full support enabled flag.internal - Internal task flag.subjId - Subject ID.execName - Custom executor name.public boolean isFullSupport()
isFullSupport in interface GridTaskSessionInternalTrue if checkpoints and attributes are enabled.public UUID subjectId()
subjectId in interface GridTaskSessionInternalprotected void checkFullSupport()
public boolean acquire()
True if session was acquired.public boolean release()
True if session cannot be acquired any more.public GridTaskSessionInternal session()
session in interface GridTaskSessionInternal@Nullable public IgniteUuid getJobId()
getJobId in interface GridTaskSessionInternalpublic void onClosed()
onClosed in interface GridTaskSessionInternalpublic boolean isClosed()
isClosed in interface GridTaskSessionInternalpublic UUID getTaskNodeId()
ComputeTaskSessiongetTaskNodeId in interface ComputeTaskSessionpublic long getStartTime()
getStartTime in interface ComputeTaskSessionpublic <K,V> V waitForAttribute(K key,
long timeout)
throws InterruptedException
waitForAttribute in interface ComputeTaskSessionK - Attribute key type.V - Attribute value type.key - Attribute key to wait for.timeout - Timeout in milliseconds to wait for. 0 means indefinite wait.InterruptedException - Thrown if wait was interrupted.public boolean waitForAttribute(Object key, Object val, long timeout) throws InterruptedException
waitForAttribute in interface ComputeTaskSessionkey - Attribute key to wait for.val - Attribute value to wait for. Can be null.timeout - Timeout in milliseconds to wait for. 0 means indefinite wait.InterruptedException - Thrown if wait was interrupted.public Map<?,?> waitForAttributes(Collection<?> keys, long timeout) throws InterruptedException
waitForAttributes in interface ComputeTaskSessionkeys - Attribute keys to wait for.timeout - Timeout in milliseconds to wait for. 0 means indefinite wait.InterruptedException - Thrown if wait was interrupted.public boolean waitForAttributes(Map<?,?> attrs, long timeout) throws InterruptedException
waitForAttributes in interface ComputeTaskSessionattrs - Key/value pairs to wait for.timeout - Timeout in milliseconds to wait for. 0 means indefinite wait.InterruptedException - Thrown if wait was interrupted.public String getTaskName()
getTaskName in interface ComputeTaskSessionpublic String getTaskClassName()
public IgniteUuid getId()
getId in interface ComputeTaskSessionpublic long getEndTime()
getEndTime in interface ComputeTaskSessionpublic String getUserVersion()
public ClassLoader getClassLoader()
Note that for classes that were loaded remotely from other nodes methods
Class.getResource(String) or ClassLoader.getResource(String)
will always return null. Use
Class.getResourceAsStream(String) or ClassLoader.getResourceAsStream(String)
instead.
getClassLoader in interface ComputeTaskSessionpublic void setClassLoader(ClassLoader clsLdr)
clsLdr - Class loader.public boolean isTaskNode()
isTaskNode in interface GridTaskSessionInternalTrue if task node.public Collection<ComputeJobSibling> refreshJobSiblings()
ComputeTaskContinuousMapper),
list of siblings on remote node may not be fresh. In that case, this method
will re-request list of siblings from originating node.refreshJobSiblings in interface ComputeTaskSessionpublic Collection<ComputeJobSibling> getJobSiblings()
If task uses continuous mapper (i.e. it injected into task class) then job siblings will be requested from task node for each apply.
getJobSiblings in interface ComputeTaskSessionpublic void setJobSiblings(Collection<ComputeJobSibling> siblings)
siblings - Siblings.public void addJobSiblings(Collection<ComputeJobSibling> siblings)
siblings - Siblings.public ComputeJobSibling getJobSibling(IgniteUuid jobId)
If task uses continuous mapper (i.e. it injected into task class) then job sibling will be requested from task node for each apply.
getJobSibling in interface ComputeTaskSessionjobId - Job ID to get the sibling for.public void setAttribute(Object key, Object val)
ComputeTaskSessionAttributeListener
callback than an attribute has changed.
This method is no-op if the session has finished.
setAttribute in interface ComputeTaskSessionkey - Attribute key.val - Attribute value. Can be null.public <K,V> V getAttribute(K key)
ComputeTaskSession.setAttribute(Object, Object) or ComputeTaskSession.setAttributes(Map)
method. Note that this attribute could have been set by another job on
another node.
This method is no-op if the session has finished.
getAttribute in interface ComputeTaskSessionK - Attribute key type.V - Attribute value type.key - Attribute key.public void setAttributes(Map<?,?> attrs)
ComputeTaskSession.setAttribute(Object, Object)
method, whenever you need to set multiple attributes.
This method is no-op if the session has finished.
setAttributes in interface ComputeTaskSessionattrs - Attributes to set.public Map<Object,Object> getAttributes()
getAttributes in interface ComputeTaskSessionpublic void setInternal(Map<?,?> attrs)
attrs - Attributes to set.public void addAttributeListener(ComputeTaskSessionAttributeListener lsnr, boolean rewind)
addAttributeListener in interface ComputeTaskSessionlsnr - Listener to add.rewind - true value will result in calling given listener for all
already received attributes, while false value will result only
in new attribute notification. Settings rewind to true
allows for a simple mechanism that prevents the loss of notifications for
the attributes that were previously received or received while this method
was executing.public boolean removeAttributeListener(ComputeTaskSessionAttributeListener lsnr)
removeAttributeListener in interface ComputeTaskSessionlsnr - Listener to remove.true if listener was removed, false otherwise.public void saveCheckpoint(String key, Object state)
CheckpointSpi implementation used.
Long running jobs may decide to store intermediate state to protect themselves from failures.
This way whenever a job fails over to another node, it can load its previously saved state via
ComputeTaskSession.loadCheckpoint(String) method and continue with execution.
This method defaults checkpoint scope to ComputeTaskSessionScope.SESSION_SCOPE and
implementation will automatically remove the checkpoint at the end of the session. It is
analogous to calling saveCheckpoint(String, Serializable, GridCheckpointScope.SESSION_SCOPE, 0.
saveCheckpoint in interface ComputeTaskSessionkey - Key to be used to load this checkpoint in future.state - Intermediate job state to save.ComputeTaskSession.loadCheckpoint(String),
ComputeTaskSession.removeCheckpoint(String),
CheckpointSpipublic void saveCheckpoint(String key, Object state, ComputeTaskSessionScope scope, long timeout)
CheckpointSpi implementation used.
Long running jobs may decide to store intermediate state to protect themselves from failures.
This way whenever a job fails over to another node, it can load its previously saved state via
ComputeTaskSession.loadCheckpoint(String) method and continue with execution.
The life time of the checkpoint is determined by its timeout and scope.
If ComputeTaskSessionScope.GLOBAL_SCOPE is used, the checkpoint will outlive
its session, and can only be removed by calling CheckpointSpi.removeCheckpoint(String)
from Ignite or another task or job.
saveCheckpoint in interface ComputeTaskSessionkey - Key to be used to load this checkpoint in future.state - Intermediate job state to save.scope - Checkpoint scope. If equal to ComputeTaskSessionScope.SESSION_SCOPE, then
state will automatically be removed at the end of task execution. Otherwise, if scope is
ComputeTaskSessionScope.GLOBAL_SCOPE then state will outlive its session and can be
removed by calling ComputeTaskSession.removeCheckpoint(String) from another task or whenever
timeout expires.timeout - Maximum time this state should be kept by the underlying storage. Value 0 means that
timeout will never expire.ComputeTaskSession.loadCheckpoint(String),
ComputeTaskSession.removeCheckpoint(String),
CheckpointSpipublic void saveCheckpoint(String key, Object state, ComputeTaskSessionScope scope, long timeout, boolean overwrite)
CheckpointSpi implementation used.
Long running jobs may decide to store intermediate state to protect themselves from failures.
This way whenever a job fails over to another node, it can load its previously saved state via
ComputeTaskSession.loadCheckpoint(String) method and continue with execution.
The life time of the checkpoint is determined by its timeout and scope.
If ComputeTaskSessionScope.GLOBAL_SCOPE is used, the checkpoint will outlive
its session, and can only be removed by calling CheckpointSpi.removeCheckpoint(String)
from Ignite or another task or job.
saveCheckpoint in interface ComputeTaskSessionkey - Key to be used to load this checkpoint in future.state - Intermediate job state to save.scope - Checkpoint scope. If equal to ComputeTaskSessionScope.SESSION_SCOPE, then
state will automatically be removed at the end of task execution. Otherwise, if scope is
ComputeTaskSessionScope.GLOBAL_SCOPE then state will outlive its session and can be
removed by calling ComputeTaskSession.removeCheckpoint(String) from another task or whenever
timeout expires.timeout - Maximum time this state should be kept by the underlying storage. Value 0 means that
timeout will never expire.overwrite - Whether or not overwrite checkpoint if it already exists.ComputeTaskSession.loadCheckpoint(String),
ComputeTaskSession.removeCheckpoint(String),
CheckpointSpiprotected void saveCheckpoint0(GridTaskSessionInternal ses, String key, Object state, ComputeTaskSessionScope scope, long timeout, boolean overwrite) throws IgniteException
ses - Session.key - Key.state - State.scope - Scope.timeout - Timeout.overwrite - Overwrite.IgniteException - If failed.public <T> T loadCheckpoint(String key)
ComputeTaskSession.saveCheckpoint(String, Object, ComputeTaskSessionScope, long)
method from an underlying storage for a given key. If state was not previously
saved, then null will be returned. The storage implementation is defined by
CheckpointSpi implementation used.
Long running jobs may decide to store intermediate state to protect themselves from failures. This way whenever a job starts, it can load its previously saved state and continue with execution.
loadCheckpoint in interface ComputeTaskSessionT - Type of the checkpoint state.key - Key for intermediate job state to load.null if no state was found for a given key.ComputeTaskSession.removeCheckpoint(String),
CheckpointSpiprotected <T> T loadCheckpoint0(GridTaskSessionInternal ses, String key)
ses - Session.key - Key.IgniteException - If failed.public boolean removeCheckpoint(String key)
key from an underlying storage.
The storage implementation is defined by CheckpointSpi implementation used.
Long running jobs may decide to store intermediate state to protect themselves from failures. This way whenever a job starts, it can load its previously saved state and continue with execution.
removeCheckpoint in interface ComputeTaskSessionkey - Key for intermediate job state to load.true if job state was removed, false if state was not found.ComputeTaskSession.loadCheckpoint(String),
CheckpointSpiprotected boolean removeCheckpoint0(GridTaskSessionInternal ses, String key) throws IgniteException
ses - Session.key - Key.True if removed.IgniteException - If failed.@Nullable public IgnitePredicate<ClusterNode> getTopologyPredicate()
public Collection<UUID> getTopology()
getTopology in interface ComputeTaskSessionpublic String getCheckpointSpi()
getCheckpointSpi in interface GridTaskSessionInternalpublic void setCheckpointSpi(String cpSpi)
cpSpi - Checkpoint SPI name.public String getFailoverSpi()
public void setFailoverSpi(String failSpi)
failSpi - Failover SPI name.public String getLoadBalancingSpi()
public void setLoadBalancingSpi(String loadSpi)
loadSpi - Load balancing SPI name.public long getSequenceNumber()
public GridDeployment deployment()
public void onMapped()
public void onDone()
public IgniteFuture<?> mapFuture()
ComputeTask.map(List, Object) method has finished).mapFuture in interface ComputeTaskSessionpublic boolean isInternal()
True if task is internal.@Nullable public String executorName()
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.7.5 Release Date : June 4 2019