org.apache.solr.cloud

## Class DistributedQueue

- java.lang.Object
- - org.apache.solr.cloud.DistributedQueue

- Direct Known Subclasses:
    OverseerTaskQueue

      public class DistributedQueue
      extends Object

  A distributed queue.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DistributedQueue(SolrZkClient zookeeper, String dir)`
    `DistributedQueue(SolrZkClient zookeeper, String dir, Overseer.Stats stats)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Overseer.Stats` | `getStats()`
    `void` | `offer(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.
    `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[]` | `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)

    - #### DistributedQueue

          public DistributedQueue(SolrZkClient zookeeper,
                                  String dir,
                                  Overseer.Stats stats)

  - ### Method Detail

    - #### 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 byte[] 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 and block is false.
      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`

    - #### peek

          public byte[] peek(long wait)
                      throws org.apache.zookeeper.KeeperException,
                             InterruptedException

      Returns the data at the first element of the queue, or null if the queue is empty after wait ms.
      Parameters:
        `wait` - max wait time in ms.
      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`

    - #### 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`

    - #### 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 void offer(byte[] data)
                     throws org.apache.zookeeper.KeeperException,
                            InterruptedException

      Inserts data into queue. Successfully calling this method does NOT guarantee that the element will be immediately available in the in-memory queue. In particular, calling this method on an empty queue will not necessarily cause `poll()` to return the offered element. Use a blocking method if you must wait for the offered element to become visible.
      Throws:
        `org.apache.zookeeper.KeeperException`
        `InterruptedException`

    - #### getStats

          public Overseer.Stats getStats()

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