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
    • 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>