Class DynamicThrottlePolicy

  • All Implemented Interfaces:
    ThrottlePolicy

    public class DynamicThrottlePolicy
    extends StaticThrottlePolicy
    This is an implementation of the ThrottlePolicy that offers dynamic limits to the number of pending messages a SourceSession is allowed to have. NOTE: By context, "pending" is refering to the number of sent messages that have not been replied to yet.
    Author:
    Simon Thoresen Hult
    • Constructor Detail

      • DynamicThrottlePolicy

        public DynamicThrottlePolicy()
        Constructs a new instance of this policy and sets the appropriate default values of member data.
      • DynamicThrottlePolicy

        public DynamicThrottlePolicy​(com.yahoo.concurrent.Timer timer)
        Constructs a new instance of this class using the given clock to calculate efficiency.
        Parameters:
        timer - the timer to use
    • Method Detail

      • getWindowSizeIncrement

        public double getWindowSizeIncrement()
      • getWindowSizeBackOff

        public double getWindowSizeBackOff()
      • canSend

        public boolean canSend​(Message message,
                               int pendingCount)
        Description copied from interface: ThrottlePolicy
        Returns whether or not the given message can be sent according to the current state of this policy.
        Specified by:
        canSend in interface ThrottlePolicy
        Overrides:
        canSend in class StaticThrottlePolicy
        Parameters:
        message - the message to evaluate
        pendingCount - the current number of pending messages
        Returns:
        true to send the message
      • setEfficiencyThreshold

        public DynamicThrottlePolicy setEfficiencyThreshold​(double efficiencyThreshold)
        Sets the lower efficiency threshold at which the algorithm should perform window size back off. Efficiency is the correlation between throughput and window size. The algorithm will increase the window size until efficiency drops below the efficiency of the local maxima times this value.
        Parameters:
        efficiencyThreshold - the limit to set
        Returns:
        this, to allow chaining
        See Also:
        setWindowSizeBackOff(double)
      • setWindowSizeIncrement

        public DynamicThrottlePolicy setWindowSizeIncrement​(double windowSizeIncrement)
        Sets the step size used when increasing window size.
        Parameters:
        windowSizeIncrement - the step size to set
        Returns:
        this, to allow chaining
      • setWindowSizeDecrementFactor

        public DynamicThrottlePolicy setWindowSizeDecrementFactor​(double decrementFactor)
        Sets the relative stepsize when decreasing window size.
        Parameters:
        decrementFactor - the step size to set
        Returns:
        this, to allow chaining
      • setWindowSizeBackOff

        public DynamicThrottlePolicy setWindowSizeBackOff​(double windowSizeBackOff)
        Sets the factor of window size to back off to when the algorithm determines that efficiency is not increasing. A value of 1 means that there is no back off from the local maxima, and means that the algorithm will fail to reduce window size to something lower than a previous maxima. This value is capped to the [0, 1] range.
        Parameters:
        windowSizeBackOff - the back off to set
        Returns:
        this, to allow chaining
      • setResizeRate

        public DynamicThrottlePolicy setResizeRate​(double resizeRate)
        Sets the rate at which the window size is updated. The larger the value, the less responsive the resizing becomes. However, the smaller the value, the less accurate the measurements become.
        Parameters:
        resizeRate - the rate to set
        Returns:
        this, to allow chaining
      • setWeight

        public DynamicThrottlePolicy setWeight​(double weight)
        Sets the weight for this client. The larger the value, the more resources will be allocated to this clients. Resources are shared between clients proportiannally to their weights.
        Parameters:
        weight - the weight to set
        Returns:
        this, to allow chaining
      • setMaxWindowSize

        public DynamicThrottlePolicy setMaxWindowSize​(double max)
        Sets the maximium number of pending operations allowed at any time, in order to avoid using too much resources.
        Parameters:
        max - the max to set
        Returns:
        this, to allow chaining
      • getMaxWindowSize

        public double getMaxWindowSize()
        Get the maximum number of pending operations allowed at any time.
        Returns:
        the maximum number of operations
      • setMinWindowSize

        public DynamicThrottlePolicy setMinWindowSize​(double min)
        Sets the minimium number of pending operations allowed at any time, in order to keep a level of performance.
        Parameters:
        min - the min to set
        Returns:
        this, to allow chaining
      • getMinWindowSize

        public double getMinWindowSize()
        Get the minimum number of pending operations allowed at any time.
        Returns:
        the minimum number of operations
      • getMaxPendingCount

        public int getMaxPendingCount()
        Returns the maximum number of pending messages allowed.
        Overrides:
        getMaxPendingCount in class StaticThrottlePolicy
        Returns:
        the max limit