Class IgniteSpiOperationTimeoutHelper


  • public class IgniteSpiOperationTimeoutHelper
    extends Object
    Object that incorporates logic that determines a timeout value for the next network related operation and checks whether a failure detection timeout is reached or not. A new instance of the class should be created for every complex network based operations that usually consists of request and response parts.
    • Constructor Detail

      • IgniteSpiOperationTimeoutHelper

        public IgniteSpiOperationTimeoutHelper​(IgniteSpiAdapter adapter,
                                               boolean srvOp)
        Constructor.
        Parameters:
        adapter - SPI adapter.
        srvOp - True if communicates with server node.
      • IgniteSpiOperationTimeoutHelper

        public IgniteSpiOperationTimeoutHelper​(IgniteSpiAdapter adapter,
                                               boolean srvOp,
                                               long lastRelatedOperationTime,
                                               long absoluteThreshold)
        Creates timeout helper based on time of last related operation.
        Parameters:
        adapter - SPI adapter.
        srvOp - True if communicates with server node.
        lastRelatedOperationTime - Time of last related operation in nanos. Ignored if negative, 0 or adapter.failureDetectionTimeoutEnabled() is false.
        absoluteThreshold - Absolute time threshold (nanos) which must not be reached. Ignored if negative or 0.
      • IgniteSpiOperationTimeoutHelper

        public IgniteSpiOperationTimeoutHelper​(long timeout)
        Creates timeout helper with an absolute time threshold. Sets timeoutEnabled to false.
        Parameters:
        timeout - Timeout in milliseconds.
    • Method Detail

      • nextTimeoutChunk

        public long nextTimeoutChunk​(long dfltTimeout)
                              throws IgniteSpiOperationTimeoutException
        Returns a timeout value to use for the next network operation. If failure detection timeout is enabled then the returned value is a portion of time left since the last time this method is called. If the timeout is disabled then dfltTimeout is returned.
        Parameters:
        dfltTimeout - Timeout to use if failure detection timeout is disabled.
        Returns:
        Timeout in milliseconds.
        Throws:
        IgniteSpiOperationTimeoutException - If failure detection timeout is reached for an operation that uses this IgniteSpiOperationTimeoutController.
      • checkFailureTimeoutReached

        public static boolean checkFailureTimeoutReached​(Exception e)
        Checks whether the given Exception is a timeout.
        Parameters:
        e - Exception to check.
        Returns:
        True if given exception is a timeout. False otherwise.