Class ManagementOperation<R>

java.lang.Object
java.util.concurrent.FutureTask<R>
org.apache.jackrabbit.oak.commons.jmx.ManagementOperation<R>
All Implemented Interfaces:
Runnable, Future<R>, RunnableFuture<R>

public class ManagementOperation<R> extends FutureTask<R>
A ManagementOperation is a background task, which can be executed by an Executor. Its ManagementOperation.Status indicates whether execution has already been started, is currently under the way or has already finished.
See Also:
  • Method Details

    • newManagementOperation

      public static <R> ManagementOperation<R> newManagementOperation(@NotNull @NotNull String name, @NotNull @NotNull Callable<R> task)
      Create a new ManagementOperation of the given name. The name is an informal value attached to this instance.
      Parameters:
      name - informal name
      task - task to execute for this operation
    • newManagementOperation

      public static <R> ManagementOperation<R> newManagementOperation(@NotNull @NotNull String name, @NotNull @NotNull Supplier<String> statusMessage, @NotNull @NotNull Callable<R> task)
      Create a new ManagementOperation of the given name. The name is an informal value attached to this instance.
      Parameters:
      name - informal name
      statusMessage - an informal status message describing the status of the background operation at the time of invocation.
      task - task to execute for this operation
    • done

      @NotNull public static <R> @NotNull ManagementOperation<R> done(String name, R result)
      An operation that is already done with the given value.
      Parameters:
      name - name of the operation
      result - result returned by the operation
      Returns:
      a ManagementOperation instance that is already done.
    • getId

      public int getId()
      Each instance of a ManagementOperation has an unique id associated with it. This id is returned as a part of its status
      Returns:
      id of this operation
    • getName

      @NotNull public @NotNull String getName()
      Informal name
      Returns:
      name of this operation
    • getStatus

      @NotNull public @NotNull ManagementOperation.Status getStatus()
      The status of this operation:
      • running if the operation is currently being executed.
      • succeeded if the operation has terminated without errors.
      • failed if the operation has been cancelled, its thread has been interrupted during execution or the operation has failed with an exception.
      Returns:
      the current status of this operation
    • toString

      public String toString()
      Overrides:
      toString in class FutureTask<R>