org.apache.storm.policy

## Class WaitStrategyProgressive

- java.lang.Object
- - org.apache.storm.policy.WaitStrategyProgressive

- All Implemented Interfaces:
    IWaitStrategy

      public class WaitStrategyProgressive
      extends Object
      implements IWaitStrategy

  A Progressive Wait Strategy.

  Has three levels of idling. Stays in each level for a configured number of iterations before entering the next level. Level 1 - No idling. Returns immediately. Stays in this level for `level1Count` iterations. Level 2 - Calls LockSupport.parkNanos(1). Stays in this level for `level2Count` iterations Level 3 - Calls Thread.sleep(). Stays in this level until wait situation changes.

  The initial spin can be useful to prevent downstream bolt from repeatedly sleeping/parking when the upstream component is a bit relatively slower. Allows downstream bolt can enter deeper wait states only if the traffic to it appears to have reduced.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.storm.policy.IWaitStrategy

      `IWaitStrategy.WaitSituation`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `WaitStrategyProgressive()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `idle(int idleCounter)` Implementations of this method should be thread-safe (preferably no side-effects and lock-free).
    `void` | `prepare(Map<String,Object> conf, IWaitStrategy.WaitSituation waitSituation)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.storm.policy.IWaitStrategy

      `createBackPressureWaitStrategy`

- - ### Constructor Detail

    - #### WaitStrategyProgressive

          public WaitStrategyProgressive()

  - ### Method Detail

    - #### prepare

          public void prepare(Map<String,Object> conf,
                              IWaitStrategy.WaitSituation waitSituation)

      Specified by:
        `prepare` in interface `IWaitStrategy`

    - #### idle

          public int idle(int idleCounter)
                   throws InterruptedException

      Description copied from interface: `IWaitStrategy`

      Implementations of this method should be thread-safe (preferably no side-effects and lock-free).

      Supports static or dynamic backoff. Dynamic backoff relies on idleCounter to estimate how long caller has been idling.

             int idleCounter = 0;  int consumeCount = consumeFromQ();  while (consumeCount==0) {  idleCounter = strategy.idle(idleCounter);  consumeCount = consumeFromQ();  }

      Specified by:
        `idle` in interface `IWaitStrategy`
      Parameters:
        `idleCounter` - managed by the idle method until reset
      Returns:
        new counter value to be used on subsequent idle cycle
      Throws:
        `InterruptedException`

Copyright © 2021 The Apache Software Foundation. All rights reserved.