Package mondrian.util

Class BlockingHashMap<K,​V>

  • Type Parameters:
    K - request (key) type
    V - response (value) type

    public class BlockingHashMap<K,​V>
    extends java.lang.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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      V 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 Detail

      • BlockingHashMap

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

      • 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 java.lang.InterruptedException
        Retrieves the response from the map matching the given key, blocking until it is received.
        Parameters:
        k - key
        Returns:
        value
        Throws:
        java.lang.InterruptedException - if interrupted while waiting