Class ManagementOperation<R>

  • All Implemented Interfaces:
    java.lang.Runnable, java.util.concurrent.Future<R>, java.util.concurrent.RunnableFuture<R>

    public class ManagementOperation<R>
    extends java.util.concurrent.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:
    RepositoryManagementMBean
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int id  
      protected @NotNull java.lang.String name  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <R> @NotNull ManagementOperation<R> done​(java.lang.String name, R result)
      An operation that is already done with the given value.
      int getId()
      Each instance of a ManagementOperation has an unique id associated with it.
      @NotNull java.lang.String getName()
      Informal name
      @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.
      static <R> ManagementOperation<R> newManagementOperation​(@NotNull java.lang.String name, @NotNull java.util.concurrent.Callable<R> task)
      Create a new ManagementOperation of the given name.
      static <R> ManagementOperation<R> newManagementOperation​(@NotNull java.lang.String name, @NotNull java.util.function.Supplier<java.lang.String> statusMessage, @NotNull java.util.concurrent.Callable<R> task)
      Create a new ManagementOperation of the given name.
      java.lang.String toString()  
      • Methods inherited from class java.util.concurrent.FutureTask

        cancel, done, get, get, isCancelled, isDone, run, runAndReset, set, setException
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • id

        protected final int id
      • name

        @NotNull
        protected final @NotNull java.lang.String name
    • Method Detail

      • newManagementOperation

        public static <R> ManagementOperation<R> newManagementOperation​(@NotNull
                                                                        @NotNull java.lang.String name,
                                                                        @NotNull
                                                                        @NotNull java.util.concurrent.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 java.lang.String name,
                                                                        @NotNull
                                                                        @NotNull java.util.function.Supplier<java.lang.String> statusMessage,
                                                                        @NotNull
                                                                        @NotNull java.util.concurrent.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​(java.lang.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 java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.util.concurrent.FutureTask<R>