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 serviceserializedCallable- Kryo-serialized bytes of the Callablestatus- current lifecycle statesubmitTimeMillis- epoch millis when the task was submittedtargetMemberId- optional target member for directed executionroutingKey- optional routing key for key-based routingscheduleConfig- 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 Summary
ConstructorsConstructorDescriptionDurableTaskRecord(String taskId, String executorName, byte[] serializedCallable, TaskStatus status, long submitTimeMillis, @Nullable String targetMemberId, @Nullable String routingKey, @Nullable ScheduledTaskInfo scheduleConfig) Creates an instance of aDurableTaskRecordrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.Returns the value of theexecutorNamerecord component.final inthashCode()Returns a hash code value for this object.booleanWhether this record represents a task that should be re-executed on recovery.static DurableTaskRecordCreate a new durable task record in PENDING state.@Nullable StringReturns the value of theroutingKeyrecord component.@Nullable ScheduledTaskInfoReturns the value of thescheduleConfigrecord component.byte[]Returns the value of theserializedCallablerecord 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.Create a cancelled version of this record.Create a completed version of this record.toFailed()Create a failed version of this record.Create a running version of this record.final StringtoString()Returns a string representation of this record class.
-
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 aDurableTaskRecordrecord class.- Parameters:
taskId- the value for thetaskIdrecord componentexecutorName- the value for theexecutorNamerecord componentserializedCallable- the value for theserializedCallablerecord componentstatus- the value for thestatusrecord componentsubmitTimeMillis- the value for thesubmitTimeMillisrecord componenttargetMemberId- the value for thetargetMemberIdrecord componentroutingKey- the value for theroutingKeyrecord componentscheduleConfig- the value for thescheduleConfigrecord component
-
-
Method Details
-
serializedCallable
public byte[] serializedCallable()Returns the value of theserializedCallablerecord component.- Returns:
- the value of the
serializedCallablerecord 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 identifierexecutorName- owning executor nameserializedCallable- Kryo-serialized callable bytes- Returns:
- a new DurableTaskRecord in PENDING state
-
toCompleted
Create a completed version of this record.- Returns:
- new record with COMPLETED status
-
toFailed
Create a failed version of this record.- Returns:
- new record with FAILED status
-
toCancelled
Create a cancelled version of this record.- Returns:
- new record with CANCELLED status
-
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
-
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
-
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
-
scheduleConfig
Returns the value of thescheduleConfigrecord component.- Returns:
- the value of the
scheduleConfigrecord component
-