Record Class TaskInfo
java.lang.Object
java.lang.Record
com.loomcache.server.executor.TaskInfo
- Record Components:
taskId- unique task identifier (UUID string)executorName- name of the executor service that owns this taskstatus- current lifecycle statesubmitTimeMillis- epoch millis when the task was submittedstartTimeMillis- epoch millis when execution started (0 if not started)endTimeMillis- epoch millis when execution ended (0 if not ended)serializedResult- Kryo-serialized result bytes, or null if not completederrorMessage- error message if status is FAILED, null otherwisetargetMemberId- target member for submitToMember, null for local executionroutingKey- routing key for submitToKey, null if not key-routed
public record TaskInfo(String taskId, String executorName, TaskStatus status, long submitTimeMillis, long startTimeMillis, long endTimeMillis, byte @Nullable [] serializedResult, @Nullable String errorMessage, @Nullable String targetMemberId, @Nullable String routingKey)
extends Record
Immutable snapshot of a distributed task's metadata and state.
Captures the full lifecycle of a task: when it was submitted, when it started/ended execution, its current status, serialized result (if completed), and routing metadata (target member / routing key).
The serializedResult holds Kryo-serialized bytes of the task's
return value. It is non-null only when status == COMPLETED.
- Since:
- 2.0
-
Constructor Summary
ConstructorsConstructorDescriptionTaskInfo(String taskId, String executorName, TaskStatus status, long submitTimeMillis, long startTimeMillis, long endTimeMillis, byte @Nullable [] serializedResult, @Nullable String errorMessage, @Nullable String targetMemberId, @Nullable String routingKey) Creates an instance of aTaskInforecord class. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the value of theendTimeMillisrecord component.final booleanIndicates whether some other object is "equal to" this one.@Nullable StringReturns the value of theerrorMessagerecord component.longCompute the execution duration in milliseconds.Returns the value of theexecutorNamerecord component.final inthashCode()Returns a hash code value for this object.static TaskInfopending(String taskId, String executorName, @Nullable String targetMemberId, @Nullable String routingKey) Create a new TaskInfo in PENDING state.@Nullable StringReturns the value of theroutingKeyrecord component.byte @Nullable []Returns the value of theserializedResultrecord component.longReturns the value of thestartTimeMillisrecord component.status()Returns the value of thestatusrecord component.longReturns the value of thesubmitTimeMillisrecord component.@Nullable StringReturns the value of thetargetMemberIdrecord component.taskId()Returns the value of thetaskIdrecord component.Transition this task to CANCELLED state.toCompleted(byte @Nullable [] result) Transition this task to COMPLETED state with a serialized result.Transition this task to FAILED state with an error message.Transition this task to RUNNING state.final StringtoString()Returns a string representation of this record class.Transition this task to TIMED_OUT state.
-
Constructor Details
-
TaskInfo
public TaskInfo(String taskId, String executorName, TaskStatus status, long submitTimeMillis, long startTimeMillis, long endTimeMillis, byte @Nullable [] serializedResult, @Nullable String errorMessage, @Nullable String targetMemberId, @Nullable String routingKey) Creates an instance of aTaskInforecord class.- Parameters:
taskId- the value for thetaskIdrecord componentexecutorName- the value for theexecutorNamerecord componentstatus- the value for thestatusrecord componentsubmitTimeMillis- the value for thesubmitTimeMillisrecord componentstartTimeMillis- the value for thestartTimeMillisrecord componentendTimeMillis- the value for theendTimeMillisrecord componentserializedResult- the value for theserializedResultrecord componenterrorMessage- the value for theerrorMessagerecord componenttargetMemberId- the value for thetargetMemberIdrecord componentroutingKey- the value for theroutingKeyrecord component
-
-
Method Details
-
pending
public static TaskInfo pending(String taskId, String executorName, @Nullable String targetMemberId, @Nullable String routingKey) Create a new TaskInfo in PENDING state.- Parameters:
taskId- unique task identifierexecutorName- name of the owning executortargetMemberId- optional target member IDroutingKey- optional routing key- Returns:
- a new TaskInfo in PENDING state
-
toRunning
Transition this task to RUNNING state.- Returns:
- a new TaskInfo with RUNNING status and current start time
-
toCompleted
Transition this task to COMPLETED state with a serialized result.- Parameters:
result- the Kryo-serialized result bytes (may be null for void tasks)- Returns:
- a new TaskInfo with COMPLETED status
-
serializedResult
public byte @Nullable [] serializedResult()Returns the value of theserializedResultrecord component.- Returns:
- the value of the
serializedResultrecord component
-
toFailed
-
toCancelled
Transition this task to CANCELLED state.- Returns:
- a new TaskInfo with CANCELLED status
-
toTimedOut
Transition this task to TIMED_OUT state.- Returns:
- a new TaskInfo with TIMED_OUT status
-
executionDurationMillis
public long executionDurationMillis()Compute the execution duration in milliseconds. Returns 0 if the task has not started or not ended.- Returns:
- execution duration in milliseconds, or 0 if not applicable
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
taskId
-
executorName
Returns the value of theexecutorNamerecord component.- Returns:
- the value of the
executorNamerecord component
-
status
-
submitTimeMillis
public long submitTimeMillis()Returns the value of thesubmitTimeMillisrecord component.- Returns:
- the value of the
submitTimeMillisrecord component
-
startTimeMillis
public long startTimeMillis()Returns the value of thestartTimeMillisrecord component.- Returns:
- the value of the
startTimeMillisrecord component
-
endTimeMillis
public long endTimeMillis()Returns the value of theendTimeMillisrecord component.- Returns:
- the value of the
endTimeMillisrecord component
-
errorMessage
Returns the value of theerrorMessagerecord component.- Returns:
- the value of the
errorMessagerecord component
-
targetMemberId
Returns the value of thetargetMemberIdrecord component.- Returns:
- the value of the
targetMemberIdrecord component
-
routingKey
Returns the value of theroutingKeyrecord component.- Returns:
- the value of the
routingKeyrecord component
-