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 task
status - current lifecycle state
submitTimeMillis - epoch millis when the task was submitted
startTimeMillis - 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 completed
errorMessage - error message if status is FAILED, null otherwise
targetMemberId - target member for submitToMember, null for local execution
routingKey - 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 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 a TaskInfo record class.
      Parameters:
      taskId - the value for the taskId record component
      executorName - the value for the executorName record component
      status - the value for the status record component
      submitTimeMillis - the value for the submitTimeMillis record component
      startTimeMillis - the value for the startTimeMillis record component
      endTimeMillis - the value for the endTimeMillis record component
      serializedResult - the value for the serializedResult record component
      errorMessage - the value for the errorMessage record component
      targetMemberId - the value for the targetMemberId record component
      routingKey - the value for the routingKey record 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 identifier
      executorName - name of the owning executor
      targetMemberId - optional target member ID
      routingKey - optional routing key
      Returns:
      a new TaskInfo in PENDING state
    • toRunning

      public TaskInfo toRunning()
      Transition this task to RUNNING state.
      Returns:
      a new TaskInfo with RUNNING status and current start time
    • toCompleted

      public TaskInfo toCompleted(byte @Nullable [] result)
      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 the serializedResult record component.
      Returns:
      the value of the serializedResult record component
    • toFailed

      public TaskInfo toFailed(String error)
      Transition this task to FAILED state with an error message.
      Parameters:
      error - the error message describing the failure
      Returns:
      a new TaskInfo with FAILED status
    • toCancelled

      public TaskInfo toCancelled()
      Transition this task to CANCELLED state.
      Returns:
      a new TaskInfo with CANCELLED status
    • toTimedOut

      public TaskInfo 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

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • taskId

      public String taskId()
      Returns the value of the taskId record component.
      Returns:
      the value of the taskId record component
    • executorName

      public String executorName()
      Returns the value of the executorName record component.
      Returns:
      the value of the executorName record component
    • status

      public TaskStatus status()
      Returns the value of the status record component.
      Returns:
      the value of the status record component
    • submitTimeMillis

      public long submitTimeMillis()
      Returns the value of the submitTimeMillis record component.
      Returns:
      the value of the submitTimeMillis record component
    • startTimeMillis

      public long startTimeMillis()
      Returns the value of the startTimeMillis record component.
      Returns:
      the value of the startTimeMillis record component
    • endTimeMillis

      public long endTimeMillis()
      Returns the value of the endTimeMillis record component.
      Returns:
      the value of the endTimeMillis record component
    • errorMessage

      public @Nullable String errorMessage()
      Returns the value of the errorMessage record component.
      Returns:
      the value of the errorMessage record component
    • targetMemberId

      public @Nullable String targetMemberId()
      Returns the value of the targetMemberId record component.
      Returns:
      the value of the targetMemberId record component
    • routingKey

      public @Nullable String routingKey()
      Returns the value of the routingKey record component.
      Returns:
      the value of the routingKey record component