Interface RunningTask

  • All Superinterfaces:
    DebugDumpable, StatisticsCollector, Task

    public interface RunningTask
    extends Task
    A task that is directly used to execute the handler code. It is a very sensitive structure. First of all, it must be thread-safe because it is used for the handler code execution and at the same time accessed by clients that need to check its state. There are two such situations: (1) Lightweight Asynchronous Tasks because they have no persistent representation. The only instance that exists is the one that is being executed by a handler. (2) When a client asks the task manager for a current state of the task (typically being interested in operational stats). The information could be fetched from the repository but it would be a bit outdated. This situation can be avoided by retrieving information always from the repository, sacrificing information timeliness a bit. But the (1) cannot. Some information related to task execution (e.g. list of lightweight asynchronous tasks, information on task thread, etc) is relevant only for running tasks. Therefore they are moved here.
    • Method Detail

      • canRun

        boolean canRun()
        Returns true if the task can run (was not interrupted). Will return false e.g. if shutdown was signaled. BEWARE: this flag is present only on the instance of the task that is being "executed", i.e. passed to task execution routine and task handler(s).
        true if the task can run
      • createSubtask

        RunningTask createSubtask​(LightweightTaskHandler handler)
        Creates a transient subtask, ready to execute a given LightweightTaskHandler. Owner is inherited from parent task to subtask.
      • getParentForLightweightAsynchronousTask

        RunningTask getParentForLightweightAsynchronousTask()
        Returns the in-memory version of the parent task. Applicable only to lightweight subtasks. EXPERIMENTAL (use with care)
      • isLightweightAsynchronousTask

        boolean isLightweightAsynchronousTask()
      • getLightweightAsynchronousSubtasks

        Collection<? extends RunningTask> getLightweightAsynchronousSubtasks()
      • getRunningLightweightAsynchronousSubtasks

        Collection<? extends RunningTask> getRunningLightweightAsynchronousSubtasks()
      • lightweightHandlerStartRequested

        boolean lightweightHandlerStartRequested()
      • startLightweightHandler

        void startLightweightHandler()
        Starts execution of a transient task carrying a LightweightTaskHandler. (just a shortcut to analogous call in TaskManager)
      • startCollectingOperationStats

        void startCollectingOperationStats​(@NotNull
                                           StatisticsCollectionStrategy strategy,
                                           boolean initialExecution)
      • storeOperationStatsDeferred

        void storeOperationStatsDeferred()
      • refreshLowLevelStatistics

        void refreshLowLevelStatistics()
        Call from the thread that executes the task ONLY! Otherwise wrong data might be recorded.
      • storeOperationStats

        void storeOperationStats()
      • storeOperationStatsIfNeeded

        void storeOperationStatsIfNeeded()
      • getLastOperationStatsUpdateTimestamp

        Long getLastOperationStatsUpdateTimestamp()
      • setOperationStatsUpdateInterval

        void setOperationStatsUpdateInterval​(long interval)
      • getOperationStatsUpdateInterval

        long getOperationStatsUpdateInterval()
      • incrementProgressAndStoreStatsIfNeeded

        void incrementProgressAndStoreStatsIfNeeded()
      • deleteLightweightAsynchronousSubtasks

        void deleteLightweightAsynchronousSubtasks()
      • getAndIncrementObjectsSeen

        int getAndIncrementObjectsSeen()
      • startDynamicProfilingIfNeeded

        void startDynamicProfilingIfNeeded​(RunningTask coordinatorTask,
                                           int objectsSeen)
        Must be called from the thread that executes the task. EXPERIMENTAL; consider moving to AbstractSearchIterativeResultHandler
      • stopDynamicProfiling

        void stopDynamicProfiling()
        Must be called from the thread that executes the task.
      • requestTracingIfNeeded

        boolean requestTracingIfNeeded​(RunningTask coordinatorTask,
                                       int objectsSeen,
                                       TracingRootType defaultTracingRoot)
      • stopTracing

        void stopTracing()