Class 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 Detail

      • dir

        protected final String dir
      • zookeeper

        protected org.apache.solr.common.cloud.SolrZkClient zookeeper
    • Constructor Detail

      • DistributedMap

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

      • 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
      • 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