org.apache.solr.cloud
Class DistributedQueue

java.lang.Object
  extended by org.apache.solr.cloud.DistributedQueue

public class DistributedQueue
extends Object

A distributed queue from zk recipes.


Nested Class Summary
static class DistributedQueue.QueueEvent
           
 
Constructor Summary
DistributedQueue(SolrZkClient zookeeper, String dir, List<org.apache.zookeeper.data.ACL> acl)
           
 
Method Summary
 boolean offer(byte[] data)
          Inserts data into queue.
 DistributedQueue.QueueEvent offer(byte[] data, long timeout)
          Offer the data and wait for the response
 byte[] peek()
          Returns the data at the first element of the queue, or null if the queue is empty.
 DistributedQueue.QueueEvent peek(boolean block)
          Returns the data at the first element of the queue, or null if the queue is empty.
 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.
 byte[] remove(DistributedQueue.QueueEvent event)
          Remove the event and save the response into the other path.
 byte[] take()
          Removes the head of the queue and returns it, blocks until it succeeds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DistributedQueue

public DistributedQueue(SolrZkClient zookeeper,
                        String dir,
                        List<org.apache.zookeeper.data.ACL> acl)
Method Detail

remove

public byte[] remove()
              throws NoSuchElementException,
                     org.apache.zookeeper.KeeperException,
                     InterruptedException
Attempts to remove the head of the queue and return it.

Returns:
The former head of the queue
Throws:
NoSuchElementException
org.apache.zookeeper.KeeperException
InterruptedException

remove

public byte[] remove(DistributedQueue.QueueEvent event)
              throws org.apache.zookeeper.KeeperException,
                     InterruptedException
Remove the event and save the response into the other path.

Throws:
org.apache.zookeeper.KeeperException
InterruptedException

take

public byte[] take()
            throws org.apache.zookeeper.KeeperException,
                   InterruptedException
Removes the head of the queue and returns it, blocks until it succeeds.

Returns:
The former head of the queue
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

offer

public boolean offer(byte[] data)
              throws org.apache.zookeeper.KeeperException,
                     InterruptedException
Inserts data into queue.

Returns:
true if data was successfully added
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

offer

public DistributedQueue.QueueEvent offer(byte[] data,
                                         long timeout)
                                  throws org.apache.zookeeper.KeeperException,
                                         InterruptedException
Offer the data and wait for the response

Throws:
org.apache.zookeeper.KeeperException
InterruptedException

peek

public byte[] peek()
            throws org.apache.zookeeper.KeeperException,
                   InterruptedException
Returns the data at the first element of the queue, or null if the queue is empty.

Returns:
data at the first element of the queue, or null.
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

peek

public DistributedQueue.QueueEvent peek(boolean block)
                                 throws org.apache.zookeeper.KeeperException,
                                        InterruptedException
Returns the data at the first element of the queue, or null if the queue is empty.

Returns:
data at the first element of the queue, or null.
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

poll

public byte[] poll()
            throws org.apache.zookeeper.KeeperException,
                   InterruptedException
Attempts to remove the head of the queue and return it. Returns null if the queue is empty.

Returns:
Head of the queue or null.
Throws:
org.apache.zookeeper.KeeperException
InterruptedException


Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.