Record Class ScheduledTaskInfo
java.lang.Object
java.lang.Record
com.loomcache.server.executor.ScheduledTaskInfo
- Record Components:
taskId- unique task identifier (UUID string)executorName- name of the owning executor servicescheduleType- the scheduling strategy (ONE_SHOT_DELAY, FIXED_RATE, FIXED_DELAY)initialDelayMillis- initial delay before first execution, in millisecondsperiodMillis- period between executions (0 for one-shot tasks)nextExecutionTimeMillis- epoch millis of the next scheduled executionexecutionCount- number of times the task has executed so faractive- whether this scheduled task is still active (not cancelled)serializedCallable- Kryo-serialized bytes of the Callable to execute
public record ScheduledTaskInfo(String taskId, String executorName, ScheduleType scheduleType, long initialDelayMillis, long periodMillis, long nextExecutionTimeMillis, int executionCount, boolean active, byte @Nullable [] serializedCallable)
extends Record
Metadata for a scheduled task within a
DistributedExecutorService.
Tracks the schedule configuration (type, delays, period), execution count, next planned execution time, and active state. Serialized as part of the executor's Raft snapshot for persistence across restarts.
- Since:
- 2.0
-
Constructor Summary
ConstructorsConstructorDescriptionScheduledTaskInfo(String taskId, String executorName, ScheduleType scheduleType, long initialDelayMillis, long periodMillis, long nextExecutionTimeMillis, int executionCount, boolean active, byte @Nullable [] serializedCallable) Creates an instance of aScheduledTaskInforecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanactive()Returns the value of theactiverecord component.Create an updated info after one execution completes.Create a cancelled version of this scheduled task info.static ScheduledTaskInfocreate(String taskId, String executorName, ScheduleType scheduleType, long initialDelayMillis, long periodMillis, byte[] serializedCallable) final booleanIndicates whether some other object is "equal to" this one.intReturns the value of theexecutionCountrecord component.Returns the value of theexecutorNamerecord component.final inthashCode()Returns a hash code value for this object.longReturns the value of theinitialDelayMillisrecord component.longReturns the value of thenextExecutionTimeMillisrecord component.longReturns the value of theperiodMillisrecord component.Returns the value of thescheduleTyperecord component.byte @Nullable []Returns the value of theserializedCallablerecord component.taskId()Returns the value of thetaskIdrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ScheduledTaskInfo
public ScheduledTaskInfo(String taskId, String executorName, ScheduleType scheduleType, long initialDelayMillis, long periodMillis, long nextExecutionTimeMillis, int executionCount, boolean active, byte @Nullable [] serializedCallable) Creates an instance of aScheduledTaskInforecord class.- Parameters:
taskId- the value for thetaskIdrecord componentexecutorName- the value for theexecutorNamerecord componentscheduleType- the value for thescheduleTyperecord componentinitialDelayMillis- the value for theinitialDelayMillisrecord componentperiodMillis- the value for theperiodMillisrecord componentnextExecutionTimeMillis- the value for thenextExecutionTimeMillisrecord componentexecutionCount- the value for theexecutionCountrecord componentactive- the value for theactiverecord componentserializedCallable- the value for theserializedCallablerecord component
-
-
Method Details
-
create
public static ScheduledTaskInfo create(String taskId, String executorName, ScheduleType scheduleType, long initialDelayMillis, long periodMillis, byte[] serializedCallable) -
serializedCallable
public byte @Nullable [] serializedCallable()Returns the value of theserializedCallablerecord component.- Returns:
- the value of the
serializedCallablerecord component
-
afterExecution
Create an updated info after one execution completes.- Returns:
- new info with incremented count and updated next execution time, or inactive if this was a one-shot task
-
cancelled
Create a cancelled version of this scheduled task info.- Returns:
- new info with active set to false
-
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
-
scheduleType
Returns the value of thescheduleTyperecord component.- Returns:
- the value of the
scheduleTyperecord component
-
initialDelayMillis
public long initialDelayMillis()Returns the value of theinitialDelayMillisrecord component.- Returns:
- the value of the
initialDelayMillisrecord component
-
periodMillis
public long periodMillis()Returns the value of theperiodMillisrecord component.- Returns:
- the value of the
periodMillisrecord component
-
nextExecutionTimeMillis
public long nextExecutionTimeMillis()Returns the value of thenextExecutionTimeMillisrecord component.- Returns:
- the value of the
nextExecutionTimeMillisrecord component
-
executionCount
public int executionCount()Returns the value of theexecutionCountrecord component.- Returns:
- the value of the
executionCountrecord component
-
active
-