Package org.apache.hadoop.hbase.util
Class StealJobQueue<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
java.util.concurrent.PriorityBlockingQueue<T>
org.apache.hadoop.hbase.util.StealJobQueue<T>
- All Implemented Interfaces:
Serializable
,Iterable<T>
,Collection<T>
,BlockingQueue<T>
,Queue<T>
This queue allows a ThreadPoolExecutor to steal jobs from another ThreadPoolExecutor. This queue
also acts as the factory for creating the PriorityBlockingQueue to be used in the steal-from
ThreadPoolExecutor. The behavior of this queue is the same as a normal PriorityBlockingQueue
except the take/poll(long,TimeUnit) methods would also check whether there are jobs in the
steal-from queue if this q ueue is empty. Note the workers in ThreadPoolExecutor must be
pre-started so that they can steal job from the other queue, otherwise the worker will only be
started after there are jobs submitted to main queue.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Lock
private final Condition
private static final long
private BlockingQueue<T>
-
Constructor Summary
ConstructorDescriptionStealJobQueue
(int initCapacity, int stealFromQueueInitCapacity, Comparator<? super T> comparator) StealJobQueue
(Comparator<? super T> comparator) -
Method Summary
Modifier and TypeMethodDescriptionGet a queue whose job might be stolen by the consumer of this original queueboolean
take()
Methods inherited from class java.util.concurrent.PriorityBlockingQueue
add, clear, comparator, contains, drainTo, drainTo, forEach, iterator, offer, peek, poll, put, remainingCapacity, remove, removeAll, removeIf, retainAll, size, spliterator, toArray, toArray, toString
Methods inherited from class java.util.AbstractQueue
addAll, element, remove
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
addAll, containsAll, equals, hashCode, isEmpty, parallelStream, stream, toArray
-
Field Details
-
serialVersionUID
- See Also:
-
stealFromQueue
-
lock
-
notEmpty
-
-
Constructor Details
-
StealJobQueue
-
StealJobQueue
public StealJobQueue(int initCapacity, int stealFromQueueInitCapacity, Comparator<? super T> comparator)
-
-
Method Details
-
getStealFromQueue
Get a queue whose job might be stolen by the consumer of this original queue- Returns:
- the queue whose job could be stolen
-
offer
- Specified by:
offer
in interfaceBlockingQueue<T>
- Specified by:
offer
in interfaceQueue<T>
- Overrides:
offer
in classPriorityBlockingQueue<T>
-
take
- Specified by:
take
in interfaceBlockingQueue<T>
- Overrides:
take
in classPriorityBlockingQueue<T>
- Throws:
InterruptedException
-
poll
- Specified by:
poll
in interfaceBlockingQueue<T>
- Overrides:
poll
in classPriorityBlockingQueue<T>
- Throws:
InterruptedException
-