Package org.apache.solr.cloud
Class SizeLimitedDistributedMap
java.lang.Object
org.apache.solr.cloud.DistributedMap
org.apache.solr.cloud.SizeLimitedDistributedMap
A size limited distributed map maintained in zk. Oldest znodes (as per modification time) are
evicted as newer ones come in.
When the map hits the specified maximum size, the oldest maxSize / 10 items are
evicted on the next put(String, byte[]) invocation.
-
Field Summary
Fields inherited from class org.apache.solr.cloud.DistributedMap
dir, PREFIX, zookeeper -
Constructor Summary
ConstructorsConstructorDescriptionSizeLimitedDistributedMap(org.apache.solr.common.cloud.SolrZkClient zookeeper, String dir, int maxSize) SizeLimitedDistributedMap(org.apache.solr.common.cloud.SolrZkClient zookeeper, String dir, int maxSize, org.apache.solr.cloud.SizeLimitedDistributedMap.OnOverflowObserver onOverflowObserver) -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanputIfAbsent(String trackingId, byte[] data) Puts an element in the map only if there isn't one with the same trackingId already
-
Constructor Details
-
SizeLimitedDistributedMap
public SizeLimitedDistributedMap(org.apache.solr.common.cloud.SolrZkClient zookeeper, String dir, int maxSize) -
SizeLimitedDistributedMap
public SizeLimitedDistributedMap(org.apache.solr.common.cloud.SolrZkClient zookeeper, String dir, int maxSize, org.apache.solr.cloud.SizeLimitedDistributedMap.OnOverflowObserver onOverflowObserver)
-
-
Method Details
-
put
public void put(String trackingId, byte[] data) throws org.apache.zookeeper.KeeperException, InterruptedException - Overrides:
putin classDistributedMap- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
putIfAbsent
public boolean putIfAbsent(String trackingId, byte[] data) throws org.apache.zookeeper.KeeperException, InterruptedException Description copied from class:DistributedMapPuts an element in the map only if there isn't one with the same trackingId already- Overrides:
putIfAbsentin classDistributedMap- Returns:
- True if the element was added. False if it wasn't (because the key already exists)
- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-