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
Modifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
private long
private long
private boolean
private final ReentrantLock
private final Condition
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Inserts the specified element at the end of this queue.void
Inserts the specified element at the end of this queue.void
Inserts all elements in the iterator at the front of this queue.void
Inserts the specified element at the front of this queue.void
Inserts the specified element at the front of this queue.protected abstract Procedure
dequeue()
Fetch one Procedure from the queue NOTE: this method is called with the sched lock held.protected abstract void
Add the procedure to the queue.long
long
boolean
Returns 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 void
protected abstract boolean
Returns true if there are procedures available to process.protected abstract int
Returns the number of elements in this queue.protected void
protected void
void
In case the class is blocking on poll() waiting for items to be added, this method should awake poll() and poll() should return.int
size()
Returns the number of elements in this queue.void
start()
Start the schedulervoid
stop()
Stop the schedulertoString()
protected void
waitProcedure
(LockAndQueue lockAndQueue, Procedure proc) (package private) void
wakeEvents
(ProcedureEvent[] events) Wake up all the given events.protected void
wakePollIfNeeded
(int waitingCount) protected void
wakeProcedure
(Procedure procedure) protected int
wakeWaitingProcedures
(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, wait
Methods 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:ProcedureScheduler
Start the scheduler- Specified by:
start
in interfaceProcedureScheduler
-
stop
Description copied from interface:ProcedureScheduler
Stop the scheduler- Specified by:
stop
in interfaceProcedureScheduler
-
signalAll
Description copied from interface:ProcedureScheduler
In case the class is blocking on poll() waiting for items to be added, this method should awake poll() and poll() should return.- Specified by:
signalAll
in 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:ProcedureScheduler
Inserts the specified element at the front of this queue.- Specified by:
addFront
in interfaceProcedureScheduler
- Parameters:
procedure
- the Procedure to add
-
addFront
Description copied from interface:ProcedureScheduler
Inserts the specified element at the front of this queue.- Specified by:
addFront
in interfaceProcedureScheduler
- Parameters:
procedure
- the Procedure to addnotify
- whether need to notify worker
-
addFront
Description copied from interface:ProcedureScheduler
Inserts all elements in the iterator at the front of this queue.- Specified by:
addFront
in interfaceProcedureScheduler
-
addBack
Description copied from interface:ProcedureScheduler
Inserts the specified element at the end of this queue.- Specified by:
addBack
in interfaceProcedureScheduler
- Parameters:
procedure
- the Procedure to add
-
addBack
Description copied from interface:ProcedureScheduler
Inserts the specified element at the end of this queue.- Specified by:
addBack
in 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:ProcedureScheduler
Fetch one Procedure from the queue- Specified by:
poll
in interfaceProcedureScheduler
- Returns:
- the Procedure to execute, or null if nothing present.
-
poll
Description copied from interface:ProcedureScheduler
Fetch one Procedure from the queue- Specified by:
poll
in 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:ProcedureScheduler
Returns the number of elements in this queue.- Specified by:
size
in interfaceProcedureScheduler
- Returns:
- the number of elements in this queue.
-
hasRunnables
Description copied from interface:ProcedureScheduler
Returns true if there are procedures available to process, otherwise false.- Specified by:
hasRunnables
in 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
-