Class NonBlockingFiniteStateMachine.Task

    • Method Detail

      • getAssociatedKey

        public Object getAssociatedKey()
        Determine the host key (or base) object to which this object is associated.

        Note: It's expected that the returned object is suitable to be used as an immutable identity (e.g. a key in a Map).
        Note 2: Circular associations are not permitted.

        Specified by:
        getAssociatedKey in interface Associated
        Returns:
        the host key that for this object, or null if this object has no association
      • run

        public void run()
        Specified by:
        run in interface Runnable
      • getSchedulingPriority

        public int getSchedulingPriority()
        Obtain this task's scheduling priority. Valid values are one of the SCHEDULE_* constants.
        Specified by:
        getSchedulingPriority in interface PriorityTask
        Returns:
        this task's scheduling priority
      • getExecutionTimeoutMillis

        public long getExecutionTimeoutMillis()
        Obtain the maximum amount of time this task is allowed to run before the corresponding service will attempt to stop it.

        The value of TIMEOUT_DEFAULT indicates a default timeout value configured for the corresponding service; the value of TIMEOUT_NONE indicates that this task can execute indefinitely.

        If, by the time the specified amount of time passed, the task has not finished, the service will attempt to stop the execution by using the Thread.interrupt() method. In the case that interrupting the thread does not result in the task's termination, the PriorityTask.runCanceled(boolean) method will be called.

        Specified by:
        getExecutionTimeoutMillis in interface PriorityTask
        Returns:
        the execution timeout value in milliseconds or one of the special TIMEOUT_* values
      • getRequestTimeoutMillis

        public long getRequestTimeoutMillis()
        Obtain the maximum amount of time a calling thread is willing to wait for a result of the request execution. The request time is measured on the client side as the time elapsed from the moment a request is sent for execution to the corresponding server node(s) and includes:
        • the time it takes to deliver the request to the executing node(s);
        • the interval between the time the task is received and placed into a service queue until the execution starts;
        • the task execution time;
        • the time it takes to deliver a result back to the client.

        The value of TIMEOUT_DEFAULT indicates a default timeout value configured for the corresponding service; the value of TIMEOUT_NONE indicates that the client thread is willing to wait indefinitely until the task execution completes or is canceled by the service due to a task execution timeout specified by the PriorityTask.getExecutionTimeoutMillis() value.

        If the specified amount of time elapsed and the client has not received any response from the server, an RequestTimeoutException will be thrown to the caller.

        Specified by:
        getRequestTimeoutMillis in interface PriorityTask
        Returns:
        the request timeout value in milliseconds or one of the special TIMEOUT_* values
      • runCanceled

        public void runCanceled​(boolean fAbandoned)
        This method will be called if and only if all attempts to interrupt this task were unsuccessful in stopping the execution or if the execution was canceled before it had a chance to run at all.

        Since this method is usually called on a service thread, implementors must exercise extreme caution since any delay introduced by the implementation will cause a delay of the corresponding service.

        Specified by:
        runCanceled in interface PriorityTask
        Parameters:
        fAbandoned - true if the task has timed-out, but all attempts to interrupt it were unsuccessful in stopping the execution; otherwise the task was never started