Class TimingValues


  • public class TimingValues
    extends java.lang.Object
    Timeouts, delays and retries used in RPC config protocol.
    Author:
    Gunnar Gauslaa Bergem
    • Constructor Summary

      Constructors 
      Constructor Description
      TimingValues()  
      TimingValues​(long successTimeout, long errorTimeout, long initialTimeout, long subscribeTimeout, long unconfiguredDelay, long configuredErrorDelay, long fixedDelay, int maxDelayMultiplier)  
      TimingValues​(TimingValues tv, java.util.Random random)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getConfiguredErrorDelay()
      Returns time to wait until next attempt to get config after a failed request when the client has previously gotten a successful response to a config subscription (i.e, the client is configured).
      long getErrorTimeout()
      Returns timeout to use as server timeout when we got an error with the previous config request.
      long getFixedDelay()
      Returns fixed delay that is used when retrying getting config no matter if it was a success or an error and independent of number of retries.
      int getMaxDelayMultiplier()
      Returns maximum multiplier to use when calculating delay (the delay is multiplied by the number of failed requests, unless that number is this maximum multiplier).
      long getPlusMinusFractionRandom​(long val, float fraction)
      Returns a number +/- a random component
      long getSubscribeTimeout()
      Returns timeout to use as server timeout when subscribing for the first time.
      long getSuccessTimeout()
      Returns timeout to use as server timeout when previous config request was a success.
      long getUnconfiguredDelay()
      Returns time to wait until next attempt to get config after a failed request when the client has not gotten a successful response to a config subscription (i.e, the client has not been configured).
      TimingValues setConfiguredErrorDelay​(long d)  
      TimingValues setConfiguredErrorTimeout​(long t)  
      TimingValues setSubscribeTimeout​(long t)  
      TimingValues setUnconfiguredDelay​(long d)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • defaultNextConfigTimeout

        public static final long defaultNextConfigTimeout
        See Also:
        Constant Field Values
    • Constructor Detail

      • TimingValues

        public TimingValues()
      • TimingValues

        public TimingValues​(long successTimeout,
                            long errorTimeout,
                            long initialTimeout,
                            long subscribeTimeout,
                            long unconfiguredDelay,
                            long configuredErrorDelay,
                            long fixedDelay,
                            int maxDelayMultiplier)
      • TimingValues

        public TimingValues​(TimingValues tv,
                            java.util.Random random)
    • Method Detail

      • getSuccessTimeout

        public long getSuccessTimeout()
        Returns timeout to use as server timeout when previous config request was a success.
        Returns:
        timeout in milliseconds.
      • getErrorTimeout

        public long getErrorTimeout()
        Returns timeout to use as server timeout when we got an error with the previous config request.
        Returns:
        timeout in milliseconds.
      • getSubscribeTimeout

        public long getSubscribeTimeout()
        Returns timeout to use as server timeout when subscribing for the first time.
        Returns:
        timeout in milliseconds.
      • setSubscribeTimeout

        public TimingValues setSubscribeTimeout​(long t)
      • setConfiguredErrorTimeout

        public TimingValues setConfiguredErrorTimeout​(long t)
      • getUnconfiguredDelay

        public long getUnconfiguredDelay()
        Returns time to wait until next attempt to get config after a failed request when the client has not gotten a successful response to a config subscription (i.e, the client has not been configured). A negative value means that there will never be a next attempt. If a negative value is set, the user must also setSubscribeTimeout(0) to prevent a deadlock while subscribing.
        Returns:
        delay in milliseconds, a negative value means never.
      • setUnconfiguredDelay

        public TimingValues setUnconfiguredDelay​(long d)
      • getConfiguredErrorDelay

        public long getConfiguredErrorDelay()
        Returns time to wait until next attempt to get config after a failed request when the client has previously gotten a successful response to a config subscription (i.e, the client is configured). A negative value means that there will never be a next attempt.
        Returns:
        delay in milliseconds, a negative value means never.
      • setConfiguredErrorDelay

        public TimingValues setConfiguredErrorDelay​(long d)
      • getMaxDelayMultiplier

        public int getMaxDelayMultiplier()
        Returns maximum multiplier to use when calculating delay (the delay is multiplied by the number of failed requests, unless that number is this maximum multiplier).
        Returns:
        timeout in milliseconds.
      • getFixedDelay

        public long getFixedDelay()
        Returns fixed delay that is used when retrying getting config no matter if it was a success or an error and independent of number of retries.
        Returns:
        timeout in milliseconds.
      • getPlusMinusFractionRandom

        public long getPlusMinusFractionRandom​(long val,
                                               float fraction)
        Returns a number +/- a random component
        Parameters:
        val - input
        fraction - for instance 0.1 for +/- 10%
        Returns:
        a number
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object