Package org.apache.solr.cloud
Class SizeLimitedDistributedMap
- java.lang.Object
-
- org.apache.solr.cloud.DistributedMap
-
- org.apache.solr.cloud.SizeLimitedDistributedMap
-
public class SizeLimitedDistributedMap extends DistributedMap
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 nextput(String, byte[])
invocation.
-
-
Field Summary
-
Fields inherited from class org.apache.solr.cloud.DistributedMap
dir, PREFIX, zookeeper
-
-
Constructor Summary
Constructors Constructor Description SizeLimitedDistributedMap(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
-
-
-
Constructor Detail
-
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 Detail
-
put
public void put(String trackingId, byte[] data) throws org.apache.zookeeper.KeeperException, InterruptedException
- Overrides:
put
in classDistributedMap
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
putIfAbsent
public boolean putIfAbsent(String trackingId, byte[] data) throws org.apache.zookeeper.KeeperException, InterruptedException
Description copied from class:DistributedMap
Puts an element in the map only if there isn't one with the same trackingId already- Overrides:
putIfAbsent
in classDistributedMap
- Returns:
- True if the element was added. False if it wasn't (because the key already exists)
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
-