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 service
scheduleType - the scheduling strategy (ONE_SHOT_DELAY, FIXED_RATE, FIXED_DELAY)
initialDelayMillis - initial delay before first execution, in milliseconds
periodMillis - period between executions (0 for one-shot tasks)
nextExecutionTimeMillis - epoch millis of the next scheduled execution
executionCount - number of times the task has executed so far
active - 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 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 a ScheduledTaskInfo record class.
      Parameters:
      taskId - the value for the taskId record component
      executorName - the value for the executorName record component
      scheduleType - the value for the scheduleType record component
      initialDelayMillis - the value for the initialDelayMillis record component
      periodMillis - the value for the periodMillis record component
      nextExecutionTimeMillis - the value for the nextExecutionTimeMillis record component
      executionCount - the value for the executionCount record component
      active - the value for the active record component
      serializedCallable - the value for the serializedCallable record 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 the serializedCallable record component.
      Returns:
      the value of the serializedCallable record component
    • afterExecution

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

      public ScheduledTaskInfo cancelled()
      Create a cancelled version of this scheduled task info.
      Returns:
      new info with active set to false
    • 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
    • scheduleType

      public ScheduleType scheduleType()
      Returns the value of the scheduleType record component.
      Returns:
      the value of the scheduleType record component
    • initialDelayMillis

      public long initialDelayMillis()
      Returns the value of the initialDelayMillis record component.
      Returns:
      the value of the initialDelayMillis record component
    • periodMillis

      public long periodMillis()
      Returns the value of the periodMillis record component.
      Returns:
      the value of the periodMillis record component
    • nextExecutionTimeMillis

      public long nextExecutionTimeMillis()
      Returns the value of the nextExecutionTimeMillis record component.
      Returns:
      the value of the nextExecutionTimeMillis record component
    • executionCount

      public int executionCount()
      Returns the value of the executionCount record component.
      Returns:
      the value of the executionCount record component
    • active

      public boolean active()
      Returns the value of the active record component.
      Returns:
      the value of the active record component