Class GridJobResultImpl
- java.lang.Object
-
- org.apache.ignite.internal.GridJobResultImpl
-
- All Implemented Interfaces:
ComputeJobResult
public class GridJobResultImpl extends Object implements ComputeJobResult
Class provides implementation for job result.
-
-
Constructor Summary
Constructors Constructor Description GridJobResultImpl(ComputeJob job, IgniteUuid jobId, ClusterNode node, GridJobSiblingImpl sib)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearData()Clears stored job data.ObjectgetData()Gets data returned by remote job if it didn't fail.IgniteExceptiongetException()Gets exception produced by execution of remote job, ornullif remote execution finished normally and did not produce any exceptions.ComputeJobgetJob()Gets local instance of remote job returned byComputeTask.map(List, Object)method.ComputeJobContextgetJobContext()Gets job context.ClusterNodegetNode()Gets node this job executed on.GridJobSiblingImplgetSibling()booleanhasResponse()booleanisCancelled()Gets job cancellation status.booleanisOccupied()voidonResponse(@Nullable Object data, @Nullable IgniteException ex, @Nullable Map<Object,Object> jobAttrs, boolean isCancelled)voidresetResponse()voidsetNode(ClusterNode node)voidsetOccupied(boolean isOccupied)StringtoString()
-
-
-
Constructor Detail
-
GridJobResultImpl
public GridJobResultImpl(ComputeJob job, IgniteUuid jobId, ClusterNode node, GridJobSiblingImpl sib)
- Parameters:
job- Job instance.jobId- ID of the job.node- Node from where this result was received.sib- Sibling associated with this result.
-
-
Method Detail
-
getJob
public ComputeJob getJob()
Gets local instance of remote job returned byComputeTask.map(List, Object)method.- Specified by:
getJobin interfaceComputeJobResult- Returns:
- Local instance of remote job returned by
ComputeTask.map(List, Object)method.
-
getJobContext
public ComputeJobContext getJobContext()
Gets job context. Use job context to access job unique ID or to get/set jobs attributes. Context is attached to a job and travels with it wherever it goes. For example, if a job gets failed-over from one node to another, then its context will be failed over with it and all attributes that were set on the job on the first node will be available on the new node.- Specified by:
getJobContextin interfaceComputeJobResult- Returns:
- Job context.
-
getSibling
public GridJobSiblingImpl getSibling()
- Returns:
- Sibling associated with this result.
-
getNode
public ClusterNode getNode()
Gets node this job executed on.- Specified by:
getNodein interfaceComputeJobResult- Returns:
- Node this job executed on.
-
getData
public Object getData()
Gets data returned by remote job if it didn't fail. This data is the object returned fromComputeJob.execute()method.Note that if task is annotated with
ComputeTaskNoResultCacheannotation, then job results will not be cached and will be available only inComputeTask.result(ComputeJobResult, List)method for every individual job, but not inComputeTask.reduce(List)method. This feature was added to avoid excessive storing of overly large results.- Specified by:
getDatain interfaceComputeJobResult- Returns:
- Data returned by remote job's
ComputeJob.execute()method if it didn't fail.
-
getException
public IgniteException getException()
Gets exception produced by execution of remote job, ornullif remote execution finished normally and did not produce any exceptions.- Specified by:
getExceptionin interfaceComputeJobResult- Returns:
IgniteExceptionproduced by execution of remote job ornullif no exception was produced.Note that if remote job resulted in
RuntimeExceptionorErrorthen they will be wrapped intoComputeUserUndeclaredExceptionreturned by this method.If job on remote node was rejected (cancelled while it was on waiting queue), then
ComputeExecutionRejectedExceptionwill be returned.If node on which job was computing failed, then
ClusterTopologyExceptionis returned.
-
isCancelled
public boolean isCancelled()
Gets job cancellation status. Returnstrueif job received cancellation request on remote node. Note that job, after receiving cancellation request, will still need to finish and return, henceComputeJobResult.getData()method may contain execution result even if the job was canceled.Job can receive cancellation request if the task was explicitly cancelled from future (see
IgniteFuture.cancel()) or if task completed prior to getting results from all remote jobs.- Specified by:
isCancelledin interfaceComputeJobResult- Returns:
trueif job received cancellation request andfalseotherwise.
-
setNode
public void setNode(ClusterNode node)
- Parameters:
node- Node from where this result was received.
-
onResponse
public void onResponse(@Nullable @Nullable Object data, @Nullable @Nullable IgniteException ex, @Nullable @Nullable Map<Object,Object> jobAttrs, boolean isCancelled)- Parameters:
data- Job data.ex- Job exception.jobAttrs- Job attributes.isCancelled- Whether job was cancelled or not.
-
setOccupied
public void setOccupied(boolean isOccupied)
- Parameters:
isOccupied-Trueif job for this response is being sent.
-
isOccupied
public boolean isOccupied()
- Returns:
Trueif job for this response is being sent.
-
clearData
public void clearData()
Clears stored job data.
-
resetResponse
public void resetResponse()
-
hasResponse
public boolean hasResponse()
- Returns:
trueif remote job responded.
-
-