Record Class DurableTaskRecord

java.lang.Object
java.lang.Record
com.loomcache.server.executor.DurableTaskRecord
Record Components:
taskId - unique task identifier (UUID string)
executorName - name of the owning executor service
serializedCallable - Kryo-serialized bytes of the Callable
status - current lifecycle state
submitTimeMillis - epoch millis when the task was submitted
targetMemberId - optional target member for directed execution
routingKey - optional routing key for key-based routing
scheduleConfig - optional schedule configuration for scheduled durable tasks

public record DurableTaskRecord(String taskId, String executorName, byte[] serializedCallable, TaskStatus status, long submitTimeMillis, @Nullable String targetMemberId, @Nullable String routingKey, @Nullable ScheduledTaskInfo scheduleConfig) extends Record
A Raft-replicated record for durable task execution.

Durable tasks survive node crashes: the serialized callable is committed to the Raft log before execution begins. On leader change, pending durable tasks are re-submitted for execution by the new leader.

Constraint: Only concrete named classes can be used as callables for durable tasks — lambdas and anonymous classes cannot be serialized by Kryo. Users must register callable classes with KryoSerializer.registerClass().

Since:
2.0
  • Constructor Details

    • DurableTaskRecord

      public DurableTaskRecord(String taskId, String executorName, byte[] serializedCallable, TaskStatus status, long submitTimeMillis, @Nullable String targetMemberId, @Nullable String routingKey, @Nullable ScheduledTaskInfo scheduleConfig)
      Creates an instance of a DurableTaskRecord record class.
      Parameters:
      taskId - the value for the taskId record component
      executorName - the value for the executorName record component
      serializedCallable - the value for the serializedCallable record component
      status - the value for the status record component
      submitTimeMillis - the value for the submitTimeMillis record component
      targetMemberId - the value for the targetMemberId record component
      routingKey - the value for the routingKey record component
      scheduleConfig - the value for the scheduleConfig record component
  • Method Details

    • serializedCallable

      public byte[] serializedCallable()
      Returns the value of the serializedCallable record component.
      Returns:
      the value of the serializedCallable record component
    • pending

      public static DurableTaskRecord pending(String taskId, String executorName, byte[] serializedCallable)
      Create a new durable task record in PENDING state.
      Parameters:
      taskId - unique task identifier
      executorName - owning executor name
      serializedCallable - Kryo-serialized callable bytes
      Returns:
      a new DurableTaskRecord in PENDING state
    • toCompleted

      public DurableTaskRecord toCompleted()
      Create a completed version of this record.
      Returns:
      new record with COMPLETED status
    • toFailed

      public DurableTaskRecord toFailed()
      Create a failed version of this record.
      Returns:
      new record with FAILED status
    • toCancelled

      public DurableTaskRecord toCancelled()
      Create a cancelled version of this record.
      Returns:
      new record with CANCELLED status
    • toRunning

      public DurableTaskRecord toRunning()
      Create a running version of this record.
      Returns:
      new record with RUNNING status
    • needsRecovery

      public boolean needsRecovery()
      Whether this record represents a task that should be re-executed on recovery.
      Returns:
      true if the task is PENDING or RUNNING (needs re-execution)
    • 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
    • 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
    • scheduleConfig

      public @Nullable ScheduledTaskInfo scheduleConfig()
      Returns the value of the scheduleConfig record component.
      Returns:
      the value of the scheduleConfig record component