Package com.onenetwork.platform.grid
Class TaskResult
java.lang.Object
com.onenetwork.platform.grid.TaskResult
public class TaskResult
extends java.lang.Object
At the end of task execution, a
TaskPerformer
returns a TaskResult to indicate
whether the task succeeded or failed, if it failed then why, and finally whether a retry
should be attempted.
The createSucceed(String)
method or SUCCEED
member should be used to indicate that
the task succeeded.
One of the createRetry(String)
methods should be used to indicate that execution failed
(and why), and that the task should be retried (as long as the max attempts has not been consumed).
One of the createFail(String)
methods should be used to indicate that execution failed
(and why), and that no attempt should be made to retry.-
Field Summary
Fields Modifier and Type Field Description static TaskResult
FAIL
Indicates failed execution without recording a failure reason.static TaskResult
RETRY
Indicates failed execution with desired retry, without recording a failure reason.static TaskResult
SUCCEED
Indicates successful execution without any need for recorded output -
Method Summary
Modifier and Type Method Description static TaskResult
createFail(java.lang.String reason)
Create a fail result (with no retry), with a reason for the failure.static TaskResult
createFail(java.lang.String reason, java.lang.Throwable e)
Create a fail result (with no retry), with a reason and an exception.static TaskResult
createFail(java.lang.Throwable e)
Create a fail result (with no retry), with an exception.static TaskResult
createRetry(java.lang.String reason)
Create a retry result with a reason for the retry.static TaskResult
createRetry(java.lang.String reason, java.lang.Throwable e)
Create a retry result with a reason and an exception.static TaskResult
createRetry(java.lang.Throwable e)
Create a retry result with an exception.static TaskResult
createSucceed(java.lang.String output)
Create a successful result, attaching the specified output which will be written to the database and available asGridTask.getTaskResult()
.java.lang.String
getFailReason()
Return the fail reason.java.lang.String
getTaskOutput()
Returns the task output.boolean
isFail()
Returns true iff result is FAILboolean
isRetry()
Returns true iff result is RETRYboolean
isSucceed()
Returns true iff result is SUCCEEDjava.lang.String
toString()
-
Field Details
-
SUCCEED
Indicates successful execution without any need for recorded output -
FAIL
Indicates failed execution without recording a failure reason. PrefercreateFail(String)
-
RETRY
Indicates failed execution with desired retry, without recording a failure reason. PrefercreateRetry(String)
-
-
Method Details
-
createSucceed
Create a successful result, attaching the specified output which will be written to the database and available asGridTask.getTaskResult()
.- Parameters:
output
- successful output- Returns:
- a succeed result with output attached
-
createFail
Create a fail result (with no retry), with a reason for the failure.- Parameters:
reason
- why the task failed- Returns:
- a fail task result with the specified reason
-
createFail
Create a fail result (with no retry), with a reason and an exception.- Parameters:
reason
- The reason for the failuree
- the exception that caused the failure- Returns:
- a fail task result with the reason and stack trace
-
createFail
Create a fail result (with no retry), with an exception.- Parameters:
e
- the exception that caused the failure- Returns:
- a fail task result with the stack trace as the reason
-
createRetry
Create a retry result with a reason for the retry.- Parameters:
reason
- why the task needs to be retried- Returns:
- a retry task result with the specified reason
-
createRetry
Create a retry result with a reason and an exception.- Parameters:
reason
- The reason for the need to retrye
- the exception that caused the need to retry- Returns:
- a retry task result with the reason and stack trace
-
createRetry
Create a retry result with an exception.- Parameters:
e
- the exception that caused the need to retry- Returns:
- a retry task result with the stack trace as the reason
-
isSucceed
public boolean isSucceed()Returns true iff result is SUCCEED- Returns:
- true iff result is SUCCEED
-
isFail
public boolean isFail()Returns true iff result is FAIL- Returns:
- true iff result is FAIL
-
isRetry
public boolean isRetry()Returns true iff result is RETRY- Returns:
- true iff result is RETRY
-
getFailReason
public java.lang.String getFailReason()Return the fail reason. If this result is not a failure, the fail reason will always be null.- Returns:
- the fail reason
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
getTaskOutput
public java.lang.String getTaskOutput()Returns the task output. If this result is not a success, the task output will always be null.- Returns:
- task output
-