public class GenericDistributedQueue extends Object implements DistributedQueue
DistribStateManager
as the underlying distributed store.
Implementation based on ZkDistributedQueue
Constructor and Description |
---|
GenericDistributedQueue(DistribStateManager stateManager,
String dir) |
GenericDistributedQueue(DistribStateManager stateManager,
String dir,
Stats stats) |
GenericDistributedQueue(DistribStateManager stateManager,
String dir,
Stats stats,
int maxQueueSize) |
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
getStats() |
Stats |
getZkStats() |
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.
|
Collection<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.
|
void |
remove(Collection<String> paths) |
byte[] |
take()
Removes the head of the queue and returns it, blocks until it succeeds.
|
public GenericDistributedQueue(DistribStateManager stateManager, String dir)
public GenericDistributedQueue(DistribStateManager stateManager, String dir, Stats stats)
public GenericDistributedQueue(DistribStateManager stateManager, String dir, Stats stats, int maxQueueSize)
public byte[] peek() throws Exception
peek
in interface DistributedQueue
Exception
public byte[] peek(boolean block) throws Exception
peek
in interface DistributedQueue
block
- if true, blocks until an element enters the queueException
public byte[] peek(long wait) throws Exception
peek
in interface DistributedQueue
wait
- max wait time in ms.Exception
public byte[] poll() throws Exception
poll
in interface DistributedQueue
Exception
public byte[] remove() throws Exception
remove
in interface DistributedQueue
Exception
public void remove(Collection<String> paths) throws Exception
Exception
public byte[] take() throws Exception
take
in interface DistributedQueue
Exception
public void offer(byte[] data) throws Exception
offer
in interface DistributedQueue
Exception
public Stats getZkStats()
public Map<String,Object> getStats()
getStats
in interface DistributedQueue
public Collection<Pair<String,byte[]>> peekElements(int max, long waitMillis, Predicate<String> acceptFilter) throws Exception
acceptFilter
, waits up to waitMillis
for at least one child to become available.
Package-private to support OverseerTaskQueue
specifically.
peekElements
in interface DistributedQueue
Exception
Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.