public interface ComputeJobContext extends ComputeJobContinuation
ComputeTaskSession
, which distributes all attributes to all jobs
in the task including the task itself, job context attributes belong
to a job and do not get sent over network unless a job moves from one
node to another.
In most cases a job, once assigned to a node, will never move to another
node. However, it is possible that collision SPI rejects a job before
it ever got a chance to execute (job rejection) which will cause fail-over
to another node. Or user is not satisfied with the outcome of a job and
fails it over to another node by returning ComputeJobResultPolicy.FAILOVER
policy from ComputeTask.result(ComputeJobResult, List)
method. In this case
all context attributes set on one node will be available on any other node
this job travels to.
You can also use ComputeJobContext
to communicate between SPI's and jobs.
For example, if you need to cancel an actively running job from CollisionSpi
you may choose to set some context attribute on the job to mark the fact
that a job was cancelled by grid and not by a user. Context attributes can
also be assigned in FailoverSpi
prior to failing over a job.
From within ComputeTask.result(ComputeJobResult, List)
or ComputeTask.reduce(List)
methods,
job context is available via ComputeJobResult.getJobContext()
method which gives user the
ability to check context attributes from within grid task implementation for every job
returned from remote nodes.
Job context can be injected into ComputeJob
via JobContextResource
annotation. Refer to the JobContextResource
documentation for coding examples on how to inject job context.
Attribute names that start with "apache.ignite:"
are reserved for internal system use.
Modifier and Type | Method and Description |
---|---|
<K,V> V |
getAttribute(K key)
Gets attribute from this job context.
|
Map<?,?> |
getAttributes()
Gets all attributes present in this job context.
|
IgniteUuid |
getJobId()
Gets ID of the job this context belongs to.
|
void |
setAttribute(Object key,
Object val)
Sets an attribute into this job context.
|
void |
setAttributes(Map<?,?> attrs)
Sets map of attributes into this job context.
|
callcc, heldcc, holdcc, holdcc
IgniteUuid getJobId()
void setAttribute(Object key, Object val)
key
- Attribute key.val
- Attribute value, may be null
.void setAttributes(Map<?,?> attrs)
attrs
- Local attributes.<K,V> V getAttribute(K key)
K
- Type of the attribute key.V
- Type of the attribute value.key
- Attribute key.null
).Map<?,?> getAttributes()
GridGain In-Memory Computing Platform : ver. 8.9.14 Release Date : November 5 2024