org.apache.storm.utils

## Class RotatingMap<K,V>

- java.lang.Object
- - org.apache.storm.utils.RotatingMap<K,V>

-     public class RotatingMap<K,V>
      extends Object

  Expires keys that have not been updated in the configured number of seconds. The algorithm used will take between expirationSecs and expirationSecs * (1 + 1 / (numBuckets-1)) to actually expire the message.

  get, put, remove, containsKey, and size take O(numBuckets) time to run.

  The advantage of this design is that the expiration thread only locks the object for O(1) time, meaning the object is essentially always available for gets/puts.

  Note: This class is not thread-safe since it does not protect against changes to buckets while it is being read

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `RotatingMap.ExpiredCallback<K,V>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RotatingMap(int numBuckets)`
    `RotatingMap(int numBuckets, RotatingMap.ExpiredCallback<K,V> callback)`
    `RotatingMap(RotatingMap.ExpiredCallback<K,V> callback)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `containsKey(K key)`
    `V` | `get(K key)`
    `void` | `put(K key, V value)`
    `V` | `remove(K key)`
    `Map<K,V>` | `rotate()`
    `int` | `size()`

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

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

- - ### Constructor Detail

    - #### RotatingMap

          public RotatingMap(int numBuckets,
                             RotatingMap.ExpiredCallback<K,V> callback)

    - #### RotatingMap

          public RotatingMap(RotatingMap.ExpiredCallback<K,V> callback)

    - #### RotatingMap

          public RotatingMap(int numBuckets)

  - ### Method Detail

    - #### rotate

          public Map<K,V> rotate()

    - #### containsKey

          public boolean containsKey(K key)

    - #### get

          public V get(K key)

    - #### put

          public void put(K key,
                          V value)

    - #### remove

          public V remove(K key)

    - #### size

          public int size()

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