Interface ThrottledTaskRunner

All Superinterfaces:
ThrottledTaskRunnerMBean

@ProviderType public interface ThrottledTaskRunner extends ThrottledTaskRunnerMBean
In addition to MBean operations, a ThrottledTaskRunner lets the caller schedule work and provides a throttle method. The logCompletion method should also allow a runnable action provide appropriate notification of success/failure
  • Method Details

    • waitForLowCpuAndLowMemory

      void waitForLowCpuAndLowMemory() throws InterruptedException
      Waits for CPU and Memory usage to fall below an acceptable threshold. NEVER call this inside a critical section as it will result in sluggish lock contention. Only call this BEFORE starting a critical section.
      Throws:
      InterruptedException - If the thread was interrupted
    • scheduleWork

      void scheduleWork(Runnable work)
      Schedule some kind of work to run in the future using the internal thread pool. The work will be throttled according to the CPU/Memory settings
      Parameters:
      work -
    • scheduleWork

      void scheduleWork(Runnable work, CancelHandler cancelHandler)
      Schedule some kind of work to run in the future using the internal thread pool. The work will be throttled according to the CPU/Memory settings. This action can be canceled at any time.
      Parameters:
      work -
      cancelHandler -
    • scheduleWork

      void scheduleWork(Runnable work, int priority)
      Schedule some kind of work to run in the future using the internal thread pool. The work will be throttled according to the CPU/Memory settings
      Parameters:
      work -
      priority - the priority of the task
    • scheduleWork

      void scheduleWork(Runnable work, CancelHandler cancelHandler, int priority)
      Schedule some kind of work to run in the future using the internal thread pool. The work will be throttled according to the CPU/Memory settings. This action can be canceled at any time.
      Parameters:
      work -
      cancelHandler -
      priority - the priority of the task
    • logCompletion

      void logCompletion(long created, long started, long executed, long finished, boolean successful, Throwable error)
      Record statistics
      Parameters:
      created - Task creation time (Milliseconds since epoch) -- This is when the work is added to the queue
      started - Start time (Milliseconds since epoch) -- This is recorded when the work is picked up by a thread
      executed - Execution time (Milliseconds since epoch) -- this is recorded after CPU/Memory throttle completes
      finished - Finish time (Milliseconds since epoch) -- This is recorded when work finishes (or throws an error)
      successful - If true, action concluded normally
      error - Exception caught, if any.
    • getMaxThreads

      int getMaxThreads()
      Get number of maximum threads supported by this thread manager
      Returns:
      Thread pool maximum size