Class GenericDistributedQueue

    • Method Detail

      • peek

        public byte[] peek()
                    throws Exception
        Returns the data at the first element of the queue, or null if the queue is empty.
        Specified by:
        peek in interface DistributedQueue
        Returns:
        data at the first element of the queue, or null.
        Throws:
        Exception
      • peek

        public byte[] peek​(boolean block)
                    throws Exception
        Returns the data at the first element of the queue, or null if the queue is empty and block is false.
        Specified by:
        peek in interface DistributedQueue
        Parameters:
        block - if true, blocks until an element enters the queue
        Returns:
        data at the first element of the queue, or null.
        Throws:
        Exception
      • peek

        public byte[] peek​(long wait)
                    throws Exception
        Returns the data at the first element of the queue, or null if the queue is empty after wait ms.
        Specified by:
        peek in interface DistributedQueue
        Parameters:
        wait - max wait time in ms.
        Returns:
        data at the first element of the queue, or null.
        Throws:
        Exception
      • poll

        public byte[] poll()
                    throws Exception
        Attempts to remove the head of the queue and return it. Returns null if the queue is empty.
        Specified by:
        poll in interface DistributedQueue
        Returns:
        Head of the queue or null.
        Throws:
        Exception
      • remove

        public byte[] remove()
                      throws Exception
        Attempts to remove the head of the queue and return it.
        Specified by:
        remove in interface DistributedQueue
        Returns:
        The former head of the queue
        Throws:
        Exception
      • take

        public byte[] take()
                    throws Exception
        Removes the head of the queue and returns it, blocks until it succeeds.
        Specified by:
        take in interface DistributedQueue
        Returns:
        The former head of the queue
        Throws:
        Exception
      • offer

        public void offer​(byte[] data)
                   throws Exception
        Inserts data into queue. If there are no other queue consumers, the offered element will be immediately visible when this method returns.
        Specified by:
        offer in interface DistributedQueue
        Throws:
        Exception
      • getZkStats

        public Stats getZkStats()
      • peekElements

        public Collection<Pair<String,​byte[]>> peekElements​(int max,
                                                                  long waitMillis,
                                                                  Predicate<String> acceptFilter)
                                                           throws Exception
        Return the currently-known set of elements, using child names from memory. If no children are found, or no children pass acceptFilter, waits up to waitMillis for at least one child to become available.

        Package-private to support OverseerTaskQueue specifically.

        Specified by:
        peekElements in interface DistributedQueue
        Throws:
        Exception