Package mondrian.util

Class BlockingHashMap<K,V>

java.lang.Object
mondrian.util.BlockingHashMap<K,V>
Type Parameters:
K - request (key) type
V - response (value) type

public class BlockingHashMap<K,V> extends Object
A limited Map implementation which supports waiting for a value to be available when calling get(). Intended for use with producer/consumer queues, where a producer thread puts a value into the collection with a separate thread waiting to get that value. Currently used by the Actor implementations in SegmentCacheManager and MonitorImpl.

Thread safety. BlockingHashMap is thread safe. The class delegates all get and put operations to a ConcurrentHashMap.

  • Constructor Summary

    Constructors
    Constructor
    Description
    BlockingHashMap(int capacity)
    Creates a BlockingHashMap with given capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    get(K k)
    Retrieves the response from the map matching the given key, blocking until it is received.
    void
    put(K k, V v)
    Places a (request, response) pair onto the map.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BlockingHashMap

      public BlockingHashMap(int capacity)
      Creates a BlockingHashMap with given capacity.
      Parameters:
      capacity - Capacity
  • Method Details

    • put

      public void put(K k, V v)
      Places a (request, response) pair onto the map.
      Parameters:
      k - key
      v - value
    • get

      public V get(K k) throws InterruptedException
      Retrieves the response from the map matching the given key, blocking until it is received.
      Parameters:
      k - key
      Returns:
      value
      Throws:
      InterruptedException - if interrupted while waiting