Package org.apache.solr.cloud
Class ZkDistributedQueue
- java.lang.Object
- 
- org.apache.solr.cloud.ZkDistributedQueue
 
- 
- All Implemented Interfaces:
- org.apache.solr.client.solrj.cloud.DistributedQueue
 - Direct Known Subclasses:
- OverseerTaskQueue
 
 public class ZkDistributedQueue extends Object implements org.apache.solr.client.solrj.cloud.DistributedQueue A ZK-based distributed queue. Optimized for single-consumer, multiple-producer: if there are multiple consumers on the same ZK queue, the results should be correct but inefficient.This implementation (with help from subclass OverseerTaskQueue) is used for the/overseer/collection-queue-workqueue used for Collection and Config Set API calls to the Overseer.Implementation note: In order to enqueue a message into this queue, a CreateMode.EPHEMERAL_SEQUENTIALresponse node is created and watched at/overseer/collection-queue-work/qnr-monotonically_increasng_id, then a correspondingCreateMode.PERSISTENTrequest node reusing the same id is created at/overseer/collection-queue-work/qn-response_id.
- 
- 
Constructor SummaryConstructors Constructor Description ZkDistributedQueue(org.apache.solr.common.cloud.SolrZkClient zookeeper, String dir)ZkDistributedQueue(org.apache.solr.common.cloud.SolrZkClient zookeeper, String dir, Stats stats)ZkDistributedQueue(org.apache.solr.common.cloud.SolrZkClient zookeeper, String dir, Stats stats, int maxQueueSize)ZkDistributedQueue(org.apache.solr.common.cloud.SolrZkClient zookeeper, String dir, Stats stats, int maxQueueSize, org.apache.solr.common.cloud.ConnectionManager.IsClosed higherLevelIsClosed)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Object>getStats()StatsgetZkStats()voidoffer(byte[] data)Inserts data into queue.byte[]peek()Returns the data at the first element of the queue, or null if the queue is empty.byte[]peek(boolean block)Returns the data at the first element of the queue, or null if the queue is empty and block is false.byte[]peek(long wait)Returns the data at the first element of the queue, or null if the queue is empty after wait ms.Collection<org.apache.solr.common.util.Pair<String,byte[]>>peekElements(int max, long waitMillis, Predicate<String> acceptFilter)Return the currently-known set of elements, using child names from memory.byte[]poll()Attempts to remove the head of the queue and return it.byte[]remove()Attempts to remove the head of the queue and return it.voidremove(Collection<String> paths)byte[]take()Removes the head of the queue and returns it, blocks until it succeeds.
 
- 
- 
- 
Constructor Detail- 
ZkDistributedQueuepublic ZkDistributedQueue(org.apache.solr.common.cloud.SolrZkClient zookeeper, String dir)
 - 
ZkDistributedQueuepublic ZkDistributedQueue(org.apache.solr.common.cloud.SolrZkClient zookeeper, String dir, Stats stats)
 - 
ZkDistributedQueuepublic ZkDistributedQueue(org.apache.solr.common.cloud.SolrZkClient zookeeper, String dir, Stats stats, int maxQueueSize)
 
- 
 - 
Method Detail- 
peekpublic byte[] peek() throws org.apache.zookeeper.KeeperException, InterruptedExceptionReturns the data at the first element of the queue, or null if the queue is empty.- Specified by:
- peekin interface- org.apache.solr.client.solrj.cloud.DistributedQueue
- Returns:
- data at the first element of the queue, or null.
- Throws:
- org.apache.zookeeper.KeeperException
- InterruptedException
 
 - 
peekpublic byte[] peek(boolean block) throws org.apache.zookeeper.KeeperException, InterruptedExceptionReturns the data at the first element of the queue, or null if the queue is empty and block is false.- Specified by:
- peekin interface- org.apache.solr.client.solrj.cloud.DistributedQueue
- Parameters:
- block- if true, blocks until an element enters the queue
- Returns:
- data at the first element of the queue, or null.
- Throws:
- org.apache.zookeeper.KeeperException
- InterruptedException
 
 - 
peekpublic byte[] peek(long wait) throws org.apache.zookeeper.KeeperException, InterruptedExceptionReturns the data at the first element of the queue, or null if the queue is empty after wait ms.- Specified by:
- peekin interface- org.apache.solr.client.solrj.cloud.DistributedQueue
- Parameters:
- wait- max wait time in ms.
- Returns:
- data at the first element of the queue, or null.
- Throws:
- org.apache.zookeeper.KeeperException
- InterruptedException
 
 - 
pollpublic byte[] poll() throws org.apache.zookeeper.KeeperException, InterruptedExceptionAttempts to remove the head of the queue and return it. Returns null if the queue is empty.- Specified by:
- pollin interface- org.apache.solr.client.solrj.cloud.DistributedQueue
- Returns:
- Head of the queue or null.
- Throws:
- org.apache.zookeeper.KeeperException
- InterruptedException
 
 - 
removepublic byte[] remove() throws NoSuchElementException, org.apache.zookeeper.KeeperException, InterruptedExceptionAttempts to remove the head of the queue and return it.- Specified by:
- removein interface- org.apache.solr.client.solrj.cloud.DistributedQueue
- Returns:
- The former head of the queue
- Throws:
- NoSuchElementException
- org.apache.zookeeper.KeeperException
- InterruptedException
 
 - 
removepublic void remove(Collection<String> paths) throws org.apache.zookeeper.KeeperException, InterruptedException - Throws:
- org.apache.zookeeper.KeeperException
- InterruptedException
 
 - 
takepublic byte[] take() throws org.apache.zookeeper.KeeperException, InterruptedExceptionRemoves the head of the queue and returns it, blocks until it succeeds.- Specified by:
- takein interface- org.apache.solr.client.solrj.cloud.DistributedQueue
- Returns:
- The former head of the queue
- Throws:
- org.apache.zookeeper.KeeperException
- InterruptedException
 
 - 
offerpublic void offer(byte[] data) throws org.apache.zookeeper.KeeperException, InterruptedExceptionInserts data into queue. If there are no other queue consumers, the offered element will be immediately visible when this method returns.- Specified by:
- offerin interface- org.apache.solr.client.solrj.cloud.DistributedQueue
- Throws:
- org.apache.zookeeper.KeeperException
- InterruptedException
 
 - 
getZkStatspublic Stats getZkStats() 
 - 
getStatspublic Map<String,Object> getStats() - Specified by:
- getStatsin interface- org.apache.solr.client.solrj.cloud.DistributedQueue
 
 - 
peekElementspublic Collection<org.apache.solr.common.util.Pair<String,byte[]>> peekElements(int max, long waitMillis, Predicate<String> acceptFilter) throws org.apache.zookeeper.KeeperException, InterruptedException Return the currently-known set of elements, using child names from memory. If no children are found, or no children passacceptFilter, waits up towaitMillisfor at least one child to become available.Package-private to support OverseerTaskQueuespecifically.- Specified by:
- peekElementsin interface- org.apache.solr.client.solrj.cloud.DistributedQueue
- Throws:
- org.apache.zookeeper.KeeperException
- InterruptedException
 
 
- 
 
-