public class GridJobSessionImpl extends Object implements GridTaskSessionInternal
| Constructor and Description |
|---|
GridJobSessionImpl(GridKernalContext ctx,
GridTaskSessionImpl ses,
IgniteUuid jobId) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAttributeListener(ComputeTaskSessionAttributeListener lsnr,
boolean rewind)
Add listener for the session attributes.
|
<K,V> V |
getAttribute(K key)
Gets an attribute set by
ComputeTaskSession.setAttribute(Object, Object) or ComputeTaskSession.setAttributes(Map)
method. |
Map<?,?> |
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.
|
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.
|
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.
|
boolean |
isClosed() |
boolean |
isFullSupport() |
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. |
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.
|
Collection<ComputeJobSibling> |
refreshJobSiblings()
Refreshes collection of job siblings.
|
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. |
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.
|
GridTaskSessionInternal |
session() |
void |
setAttribute(Object key,
Object val)
Sets session attributed.
|
void |
setAttributes(Map<?,?> attrs)
Sets task attributes.
|
UUID |
subjectId() |
String |
toString() |
<K,V> V |
waitForAttribute(K key,
long timeout)
Waits for the specified attribute to be set.
|
<K,V> boolean |
waitForAttribute(K key,
V 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 GridJobSessionImpl(GridKernalContext ctx, GridTaskSessionImpl ses, IgniteUuid jobId)
ctx - Kernal context.ses - Task session.jobId - Job ID.public GridTaskSessionInternal session()
session in interface GridTaskSessionInternalpublic IgniteUuid getJobId()
getJobId in interface GridTaskSessionInternalpublic void onClosed()
onClosed in interface GridTaskSessionInternalpublic boolean isClosed()
isClosed in interface GridTaskSessionInternalpublic boolean isTaskNode()
isTaskNode in interface GridTaskSessionInternalTrue if task node.public String getCheckpointSpi()
getCheckpointSpi in interface GridTaskSessionInternalpublic String getTaskName()
getTaskName in interface ComputeTaskSessionpublic String getTaskClassName()
public UUID getTaskNodeId()
getTaskNodeId in interface ComputeTaskSessionpublic long getStartTime()
getStartTime in interface ComputeTaskSessionpublic long getEndTime()
getEndTime in interface ComputeTaskSessionpublic IgniteUuid getId()
getId in interface ComputeTaskSessionpublic 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 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 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, @Nullable 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<?,?> getAttributes()
getAttributes in interface ComputeTaskSessionpublic 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 <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 <K,V> boolean waitForAttribute(K key,
@Nullable
V val,
long timeout)
throws InterruptedException
waitForAttribute in interface ComputeTaskSessionK - Attribute key type.V - Attribute value type.key - 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 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),
CheckpointSpipublic <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),
CheckpointSpipublic 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),
CheckpointSpipublic Collection<UUID> getTopology()
getTopology in interface ComputeTaskSessionpublic boolean isFullSupport()
isFullSupport in interface GridTaskSessionInternalTrue if checkpoints and attributes are enabled.public UUID subjectId()
subjectId in interface GridTaskSessionInternalpublic IgniteFuture<?> mapFuture()
ComputeTask.map(List, Object) method has finished).mapFuture in interface ComputeTaskSession
Follow @ApacheIgnite
Ignite Fabric : ver. 1.0.0 Release Date : March 31 2015