Package org.apache.solr.cloud
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.
-
-
Constructor Summary
Constructors Constructor Description DistributedMap(org.apache.solr.common.cloud.SolrZkClient zookeeper, String dir)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Helper method to clear all child nodes for a parent node.boolean
contains(String trackingId)
byte[]
get(String trackingId)
Collection<String>
keys()
Returns the keys of all the elements in the mapvoid
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 alreadyboolean
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 deletingint
size()
-
-
-
Field Detail
-
dir
protected final String dir
-
zookeeper
protected org.apache.solr.common.cloud.SolrZkClient zookeeper
-
PREFIX
protected static final String PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DistributedMap
public DistributedMap(org.apache.solr.common.cloud.SolrZkClient zookeeper, String dir)
-
-
Method Detail
-
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 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
-
-