Class TaskRegistry.TaskData

java.lang.Object
de.iip_ecosphere.platform.support.TaskRegistry.TaskData
Enclosing class:
TaskRegistry

public static class TaskRegistry.TaskData extends Object
Represents data associated to a task. The task data may require multiple task status changes to count as TaskRegistry.TaskStatus.STOPPED. It may also count/compare a certain number of generic events.
Author:
Holger Eichelberger, SSE
  • Field Details

    • id

      private String id
    • threadId

      private long threadId
    • timestamp

      private long timestamp
    • status

      private TaskRegistry.TaskStatus status
    • requiredStopCalls

      private int requiredStopCalls
    • stopCallCount

      private int stopCallCount
    • maxEventCount

      private int maxEventCount
    • eventCount

      private int eventCount
  • Constructor Details

    • TaskData

      private TaskData(String taskId, Thread thread)
      Creates an instance, sets the id and turns the status to TaskRegistry.TaskStatus.RUNNING.
      Parameters:
      taskId - a given task id, null for generate one
      thread - the thread to take for the thread id, may be null for the actual thread
  • Method Details

    • setStatus

      private TaskRegistry.TaskData setStatus(TaskRegistry.TaskStatus status)
      Changes the task status and the timestamp of change.
      Parameters:
      status - the new status
      Returns:
      this
    • setRequiredStopCalls

      public void setRequiredStopCalls(int requiredStopCalls)
      Changes the number of required stop calls (setStatus(TaskStatus) with TaskRegistry.TaskStatus.STOPPED) to change the task to stopped. The default value is 1.
      Parameters:
      requiredStopCalls - the number of required stop calls, ignored if not positive
    • setMaxEventCount

      public void setMaxEventCount(int maxEventCount)
      Defines the maximum number of (expected) events.
      Parameters:
      maxEventCount - the maximum number of events
    • incEventCount

      public int incEventCount()
      Increases the event counter.
      Returns:
      the new counter value
    • maxEventCountReached

      public boolean maxEventCountReached()
      Returns whether the maximum number of (expected) events was already reached.
      Returns:
      true for reached, false else
    • getId

      public String getId()
      Returns the task id.
      Returns:
      the id
    • getStatus

      public TaskRegistry.TaskStatus getStatus()
      Returns the task status.
      Returns:
      the status
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • sameTask

      public boolean sameTask(TaskRegistry.TaskData data)
      Returns whether the given task data is the same regarding the task id modulo beginning/trailing quotes as getId().
      Parameters:
      data - the task id to compare (may be null)
      Returns:
      true if both task ids are the same (modulo begining/trailing quotes),
    • sameTask

      public boolean sameTask(String taskId)
      Returns whether the given taskId modulo beginning/trailing quotes is the same as getId().
      Parameters:
      taskId - the task id to compare (may be null)
      Returns:
      true if both task ids are the same (modulo begining/trailing quotes),