com.netflix.curator.framework.recipes.queue
Class DistributedPriorityQueue<T>

java.lang.Object
  extended by com.netflix.curator.framework.recipes.queue.DistributedPriorityQueue<T>
All Implemented Interfaces:
Closeable

public class DistributedPriorityQueue<T>
extends Object
implements Closeable

An implementation of the Distributed Priority Queue ZK recipe.

Internally, this uses a DistributedQueue. The only difference is that you specify a priority when putting into the queue.

IMPORTANT NOTE: The priority queue will perform far worse than a standard queue. Every time an item is added to/removed from the queue, every watcher must re-get all the nodes

s


Method Summary
 void close()
           
static String defaultPriorityToString(int priority)
          The default method of converting a priority into a sortable string
protected  String priorityToString(int priority)
           
 void put(T item, int priority)
          Add an item into the queue.
 void putMulti(MultiItem<T> items, int priority)
          Add a set of items with the same priority into the queue.
 void start()
          Start the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

start

public void start()
           throws Exception
Start the queue. No other methods work until this is called

Throws:
Exception - startup errors

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException

put

public void put(T item,
                int priority)
         throws Exception
Add an item into the queue. Adding is done in the background - thus, this method will return quickly.

Parameters:
item - item to add
priority - item's priority - lower numbers come out of the queue first
Throws:
Exception - connection issues

putMulti

public void putMulti(MultiItem<T> items,
                     int priority)
              throws Exception
Add a set of items with the same priority into the queue. Adding is done in the background - thus, this method will return quickly.

Parameters:
items - items to add
priority - item priority - lower numbers come out of the queue first
Throws:
Exception - connection issues

defaultPriorityToString

public static String defaultPriorityToString(int priority)
The default method of converting a priority into a sortable string

Parameters:
priority - the priority
Returns:
string

priorityToString

protected String priorityToString(int priority)


Copyright © 2012. All Rights Reserved.