Class DistributedMap

java.lang.Object
org.apache.solr.cloud.DistributedMap
Direct Known Subclasses:
SizeLimitedDistributedMap

public class DistributedMap extends Object
A distributed map. This supports basic map functions e.g. get, put, contains for interaction with zk which don't have to be ordered i.e. DistributedQueue.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final String
     
    protected static final String
     
    protected org.apache.solr.common.cloud.SolrZkClient
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DistributedMap(org.apache.solr.common.cloud.SolrZkClient zookeeper, String dir)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Helper method to clear all child nodes for a parent node.
    boolean
    contains(String trackingId)
     
    byte[]
    get(String trackingId)
     
    Returns the keys of all the elements in the map
    void
    put(String trackingId, byte[] data)
     
    boolean
    putIfAbsent(String trackingId, byte[] data)
    Puts an element in the map only if there isn't one with the same trackingId already
    boolean
    remove(String trackingId)
    return true if the znode was successfully deleted false if the node didn't exist and therefore not deleted exception an exception occurred while deleting
    int
     

    Methods inherited from class java.lang.Object

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

    • dir

      protected final String dir
    • zookeeper

      protected org.apache.solr.common.cloud.SolrZkClient zookeeper
    • PREFIX

      protected static final String PREFIX
      See Also:
  • Constructor Details

    • DistributedMap

      public DistributedMap(org.apache.solr.common.cloud.SolrZkClient zookeeper, String dir)
  • Method Details

    • put

      public void put(String trackingId, byte[] data) throws org.apache.zookeeper.KeeperException, InterruptedException
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • putIfAbsent

      public boolean putIfAbsent(String trackingId, byte[] data) throws org.apache.zookeeper.KeeperException, InterruptedException
      Puts an element in the map only if there isn't one with the same trackingId already
      Returns:
      True if the element was added. False if it wasn't (because the key already exists)
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • get

      public byte[] get(String trackingId) throws org.apache.zookeeper.KeeperException, InterruptedException
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • contains

      public boolean contains(String trackingId) throws org.apache.zookeeper.KeeperException, InterruptedException
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • size

      public int size() throws org.apache.zookeeper.KeeperException, InterruptedException
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • remove

      public boolean remove(String trackingId) throws org.apache.zookeeper.KeeperException, InterruptedException
      return true if the znode was successfully deleted false if the node didn't exist and therefore not deleted exception an exception occurred while deleting
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • clear

      public void clear() throws org.apache.zookeeper.KeeperException, InterruptedException
      Helper method to clear all child nodes for a parent node.
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • keys

      public Collection<String> keys() throws org.apache.zookeeper.KeeperException, InterruptedException
      Returns the keys of all the elements in the map
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException