public class GridJobContextImpl extends GridMetadataAwareAdapter implements GridComputeJobContext, Externalizable
| Constructor and Description |
|---|
GridJobContextImpl()
Empty constructor required by
Externalizable. |
GridJobContextImpl(GridKernalContext ctx,
GridUuid jobId) |
GridJobContextImpl(GridKernalContext ctx,
GridUuid jobId,
Map<? extends Serializable,? extends Serializable> attrs) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
affinityKey()
Gets affinity key with which job was co-located.
|
String |
cacheName()
Gets cache name for which job was co-located.
|
void |
callcc()
Resumes job if it was held by
GridComputeJobContinuation.holdcc() method. |
<K,V> V |
getAttribute(K key)
Gets attribute from this job context.
|
Map<Object,Object> |
getAttributes()
Gets all attributes present in this job context.
|
GridUuid |
getJobId()
Gets ID of the job this context belongs to.
|
boolean |
heldcc()
Checks if job execution has been temporarily held (suspended).
|
<T> T |
holdcc()
Holds (suspends) a given job indefinitely until
GridComputeJobContinuation.callcc() is called. |
<T> T |
holdcc(long timeout)
Holds (suspends) a given job for specified timeout or until
GridComputeJobContinuation.callcc() is called. |
void |
job(GridJobWorker job) |
void |
readExternal(ObjectInput in) |
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.
|
String |
toString() |
void |
writeExternal(ObjectOutput out) |
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, clone, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, readExternalMeta, removeMeta, removeMeta, replaceMeta, writeExternalMetapublic GridJobContextImpl()
Externalizable.public GridJobContextImpl(@Nullable GridKernalContext ctx, GridUuid jobId)
ctx - Kernal context.jobId - Job ID.public GridJobContextImpl(GridKernalContext ctx, GridUuid jobId, Map<? extends Serializable,? extends Serializable> attrs)
ctx - Kernal context.jobId - Job ID.attrs - Job attributes.public void job(GridJobWorker job)
job - Job worker.public GridUuid getJobId()
getJobId in interface GridComputeJobContextpublic void setAttribute(Object key, @Nullable Object val)
setAttribute in interface GridComputeJobContextkey - Attribute key.val - Attribute value.public void setAttributes(Map<?,?> attrs)
setAttributes in interface GridComputeJobContextattrs - Local attributes.public <K,V> V getAttribute(K key)
getAttribute in interface GridComputeJobContextK - Type of the attribute key.V - Type of the attribute value.key - Attribute key.null).public Map<Object,Object> getAttributes()
getAttributes in interface GridComputeJobContextpublic boolean heldcc()
If job has completed its execution, then false is always returned.
heldcc in interface GridComputeJobContinuationTrue if job has been held.public <T> T holdcc()
GridComputeJobContinuation.callcc() is called.
Job will remain in active queue, but its GridComputeJobContinuation.heldcc() method will
return true. Implementations of GridCollisionSpi should check
if jobs are held or not as needed.
All jobs should stop their execution and return right after calling
'holdcc(..)' method. For convenience, this method always returns null,
so you can hold and return in one line by calling 'return holdcc()' method.
If job is not running or has completed its execution, then no-op.
The 'cc' suffix stands for 'current-continuation' which is a
pretty standard notation for this concept that originated from Scheme programming
language. Basically, the job is held to be continued later, hence the name of the method.
holdcc in interface GridComputeJobContinuationnull for convenience to be used in code with return statement.public <T> T holdcc(long timeout)
GridComputeJobContinuation.callcc() is called.
Holds (suspends) a given job for specified timeout or until GridComputeJobContinuation.callcc() is called.
Job will remain in active queue, but its GridComputeJobContinuation.heldcc() method will
return true. Implementations of GridCollisionSpi should check
if jobs are held or not as needed.
All jobs should stop their execution and return right after calling
'holdcc(..)' method. For convenience, this method always returns null,
so you can hold and return in one line by calling 'return holdcc()'.
If job is not running or has completed its execution, then no-op.
The 'cc' suffix stands for 'current-continuation' which is a
fairly standard notation for this concept. Basically, the job is held to
be continued later, hence the name of the method.
holdcc in interface GridComputeJobContinuationtimeout - Timeout in milliseconds after which job will be automatically resumed.null for convenience to be used in code with return statement.public void callcc()
GridComputeJobContinuation.holdcc() method. Resuming job means that
GridComputeJob.execute() method will be called again. It is user's responsibility to check,
as needed, whether job is executing from scratch and has been resumed.
Note that the job is resumed with exactly the same state as of when it was 'held' via
the GridComputeJobContinuation.holdcc() method.
If job is not running, has not been suspended, or has completed its execution, then no-op.
The method is named after 'call-with-current-continuation' design pattern, commonly
abbreviated as 'call/cc', which originated in Scheme programming language.
callcc in interface GridComputeJobContinuationpublic String cacheName()
cacheName in interface GridComputeJobContextnull otherwise.GridComputeJobContext.affinityKey(),
GridCompute.affinityCall(String, Object, Callable),
GridCompute.affinityRun(String, Object, Runnable)public <T> T affinityKey()
affinityKey in interface GridComputeJobContextnull otherwise.GridComputeJobContext.cacheName(),
GridCompute.affinityCall(String, Object, Callable),
GridCompute.affinityRun(String, Object, Runnable)public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionCopyright © 2014. All rights reserved.