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
FieldsModifier and TypeFieldDescriptionprivate final Lockprivate final Conditionprivate static final longprivate BlockingQueue<T> -
Constructor Summary
ConstructorsConstructorDescriptionStealJobQueue(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 queuebooleantake()Methods inherited from class java.util.concurrent.PriorityBlockingQueue
add, clear, comparator, contains, drainTo, drainTo, iterator, offer, peek, poll, put, remainingCapacity, remove, size, spliterator, toArray, toArray, toStringMethods inherited from class java.util.AbstractQueue
addAll, element, removeMethods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAllMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
addAll, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, stream
-
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:
offerin interfaceBlockingQueue<T>- Specified by:
offerin interfaceQueue<T>- Overrides:
offerin classPriorityBlockingQueue<T>
-
take
- Specified by:
takein interfaceBlockingQueue<T>- Overrides:
takein classPriorityBlockingQueue<T>- Throws:
InterruptedException
-
poll
- Specified by:
pollin interfaceBlockingQueue<T>- Overrides:
pollin classPriorityBlockingQueue<T>- Throws:
InterruptedException
-