Class AbstractProcedureScheduler
java.lang.Object
org.apache.hadoop.hbase.procedure2.AbstractProcedureScheduler
- All Implemented Interfaces:
ProcedureScheduler
- Direct Known Subclasses:
MasterProcedureScheduler,SimpleProcedureScheduler
@Private
public abstract class AbstractProcedureScheduler
extends Object
implements ProcedureScheduler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Loggerprivate longprivate longprivate booleanprivate final ReentrantLockprivate final Condition -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInserts the specified element at the end of this queue.voidInserts the specified element at the end of this queue.voidInserts all elements in the iterator at the front of this queue.voidInserts the specified element at the front of this queue.voidInserts the specified element at the front of this queue.protected abstract Proceduredequeue()Fetch one Procedure from the queue NOTE: this method is called with the sched lock held.protected abstract voidAdd the procedure to the queue.longlongbooleanReturns true if there are procedures available to process, otherwise false.poll()Fetch one Procedure from the queuepoll(long nanos) Fetch one Procedure from the queueprotected voidprotected abstract booleanReturns true if there are procedures available to process.protected abstract intReturns the number of elements in this queue.protected voidprotected voidvoidIn case the class is blocking on poll() waiting for items to be added, this method should awake poll() and poll() should return.intsize()Returns the number of elements in this queue.voidstart()Start the schedulervoidstop()Stop the schedulertoString()protected voidwaitProcedure(LockAndQueue lockAndQueue, Procedure proc) (package private) voidwakeEvents(ProcedureEvent[] events) Wake up all the given events.protected voidwakePollIfNeeded(int waitingCount) protected voidwakeProcedure(Procedure procedure) protected intwakeWaitingProcedures(LockAndQueue lockAndQueue) Wakes up given waiting procedures by pushing them back into scheduler queues.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.hbase.procedure2.ProcedureScheduler
clear, completionCleanup, getLockResource, getLocks, yield
-
Field Details
-
LOG
-
schedulerLock
-
schedWaitCond
-
running
-
pollCalls
-
nullPollCalls
-
-
Constructor Details
-
AbstractProcedureScheduler
public AbstractProcedureScheduler()
-
-
Method Details
-
start
Description copied from interface:ProcedureSchedulerStart the scheduler- Specified by:
startin interfaceProcedureScheduler
-
stop
Description copied from interface:ProcedureSchedulerStop the scheduler- Specified by:
stopin interfaceProcedureScheduler
-
signalAll
Description copied from interface:ProcedureSchedulerIn case the class is blocking on poll() waiting for items to be added, this method should awake poll() and poll() should return.- Specified by:
signalAllin interfaceProcedureScheduler
-
enqueue
Add the procedure to the queue. NOTE: this method is called with the sched lock held.- Parameters:
procedure- the Procedure to addaddFront- true if the item should be added to the front of the queue
-
addFront
Description copied from interface:ProcedureSchedulerInserts the specified element at the front of this queue.- Specified by:
addFrontin interfaceProcedureScheduler- Parameters:
procedure- the Procedure to add
-
addFront
Description copied from interface:ProcedureSchedulerInserts the specified element at the front of this queue.- Specified by:
addFrontin interfaceProcedureScheduler- Parameters:
procedure- the Procedure to addnotify- whether need to notify worker
-
addFront
Description copied from interface:ProcedureSchedulerInserts all elements in the iterator at the front of this queue.- Specified by:
addFrontin interfaceProcedureScheduler
-
addBack
Description copied from interface:ProcedureSchedulerInserts the specified element at the end of this queue.- Specified by:
addBackin interfaceProcedureScheduler- Parameters:
procedure- the Procedure to add
-
addBack
Description copied from interface:ProcedureSchedulerInserts the specified element at the end of this queue.- Specified by:
addBackin interfaceProcedureScheduler- Parameters:
procedure- the Procedure to addnotify- whether need to notify worker
-
push
-
dequeue
Fetch one Procedure from the queue NOTE: this method is called with the sched lock held.- Returns:
- the Procedure to execute, or null if nothing is available.
-
poll
Description copied from interface:ProcedureSchedulerFetch one Procedure from the queue- Specified by:
pollin interfaceProcedureScheduler- Returns:
- the Procedure to execute, or null if nothing present.
-
poll
Description copied from interface:ProcedureSchedulerFetch one Procedure from the queue- Specified by:
pollin interfaceProcedureScheduler- Parameters:
timeout- how long to wait before giving up, in units of unitunit- a TimeUnit determining how to interpret the timeout parameter- Returns:
- the Procedure to execute, or null if nothing present.
-
poll
-
queueSize
Returns the number of elements in this queue. NOTE: this method is called with the sched lock held.- Returns:
- the number of elements in this queue.
-
queueHasRunnables
Returns true if there are procedures available to process. NOTE: this method is called with the sched lock held.- Returns:
- true if there are procedures available to process, otherwise false.
-
size
Description copied from interface:ProcedureSchedulerReturns the number of elements in this queue.- Specified by:
sizein interfaceProcedureScheduler- Returns:
- the number of elements in this queue.
-
hasRunnables
Description copied from interface:ProcedureSchedulerReturns true if there are procedures available to process, otherwise false.- Specified by:
hasRunnablesin interfaceProcedureScheduler
-
getPollCalls
-
getNullPollCalls
-
wakeEvents
Wake up all the given events. Note that we first take scheduler lock and then wakeInternal() synchronizes on the event. Access should remain package-private. Use ProcedureEvent class to wake/suspend events.- Parameters:
events- the list of events to wake
-
wakeWaitingProcedures
Wakes up given waiting procedures by pushing them back into scheduler queues.- Returns:
- size of given
waitQueue.
-
waitProcedure
-
wakeProcedure
-
schedLock
-
schedUnlock
-
wakePollIfNeeded
-
toString
-