@InterfaceAudience.Private public abstract class AbstractProcedureScheduler extends Object implements ProcedureScheduler
Constructor and Description |
---|
AbstractProcedureScheduler() |
Modifier and Type | Method and Description |
---|---|
void |
addBack(Procedure procedure)
Inserts the specified element at the end of this queue.
|
void |
addBack(Procedure procedure,
boolean notify)
Inserts the specified element at the end of this queue.
|
void |
addFront(Iterator<Procedure> procedureIterator)
Inserts all elements in the iterator at the front of this queue.
|
void |
addFront(Procedure procedure)
Inserts the specified element at the front of this queue.
|
void |
addFront(Procedure procedure,
boolean notify)
Inserts the specified element at the front of this queue.
|
protected Procedure |
dequeue()
Fetch one Procedure from the queue
NOTE: this method is called with the sched lock held.
|
protected abstract Procedure |
dequeue(boolean onlyUrgent) |
protected abstract void |
enqueue(Procedure procedure,
boolean addFront)
Add the procedure to the queue.
|
long |
getNullPollCalls() |
long |
getPollCalls() |
boolean |
hasRunnables() |
Procedure |
poll()
Fetch one Procedure from the queue
|
Procedure |
poll(boolean onlyUrgent)
Fetch one Procedure from the queue
|
Procedure |
poll(boolean onlyUrgent,
long nanos) |
Procedure |
poll(boolean onlyUrgent,
long timeout,
TimeUnit unit)
Fetch one Procedure from the queue
|
Procedure |
poll(long nanos) |
Procedure |
poll(long timeout,
TimeUnit unit)
Fetch one Procedure from the queue
|
protected void |
push(Procedure procedure,
boolean addFront,
boolean notify) |
protected abstract boolean |
queueHasRunnables()
Returns true if there are procedures available to process.
|
protected abstract int |
queueSize()
Returns the number of elements in this queue.
|
protected void |
schedLock() |
protected void |
schedUnlock() |
void |
signalAll()
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 scheduler
|
void |
stop()
Stop the scheduler
|
protected void |
waitProcedure(LockAndQueue lockAndQueue,
Procedure proc) |
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clear, completionCleanup, getLockResource, getLocks, yield
public void start()
ProcedureScheduler
start
in interface ProcedureScheduler
public void stop()
ProcedureScheduler
stop
in interface ProcedureScheduler
public void signalAll()
ProcedureScheduler
signalAll
in interface ProcedureScheduler
protected abstract void enqueue(Procedure procedure, boolean addFront)
procedure
- the Procedure to addaddFront
- true if the item should be added to the front of the queuepublic void addFront(Procedure procedure)
ProcedureScheduler
addFront
in interface ProcedureScheduler
procedure
- the Procedure to addpublic void addFront(Procedure procedure, boolean notify)
ProcedureScheduler
addFront
in interface ProcedureScheduler
procedure
- the Procedure to addnotify
- whether need to notify workerpublic void addFront(Iterator<Procedure> procedureIterator)
ProcedureScheduler
addFront
in interface ProcedureScheduler
public void addBack(Procedure procedure)
ProcedureScheduler
addBack
in interface ProcedureScheduler
procedure
- the Procedure to addpublic void addBack(Procedure procedure, boolean notify)
ProcedureScheduler
addBack
in interface ProcedureScheduler
procedure
- the Procedure to addnotify
- whether need to notify workerprotected void push(Procedure procedure, boolean addFront, boolean notify)
protected Procedure dequeue()
protected abstract Procedure dequeue(boolean onlyUrgent)
public Procedure poll(boolean onlyUrgent)
ProcedureScheduler
poll
in interface ProcedureScheduler
onlyUrgent
- Only poll the urgent procedure to executepublic Procedure poll()
ProcedureScheduler
poll
in interface ProcedureScheduler
public Procedure poll(boolean onlyUrgent, long timeout, TimeUnit unit)
ProcedureScheduler
poll
in interface ProcedureScheduler
onlyUrgent
- Only poll the urgent procedure to executetimeout
- how long to wait before giving up, in units of unitunit
- a TimeUnit determining how to interpret the timeout parameterpublic Procedure poll(long timeout, TimeUnit unit)
ProcedureScheduler
poll
in interface ProcedureScheduler
timeout
- how long to wait before giving up, in units of unitunit
- a TimeUnit determining how to interpret the timeout parameterpublic Procedure poll(long nanos)
public Procedure poll(boolean onlyUrgent, long nanos)
protected abstract int queueSize()
protected abstract boolean queueHasRunnables()
public int size()
ProcedureScheduler
size
in interface ProcedureScheduler
public boolean hasRunnables()
hasRunnables
in interface ProcedureScheduler
public long getPollCalls()
public long getNullPollCalls()
protected int wakeWaitingProcedures(LockAndQueue lockAndQueue)
waitQueue
.protected void waitProcedure(LockAndQueue lockAndQueue, Procedure proc)
protected void wakeProcedure(Procedure procedure)
protected void schedLock()
protected void schedUnlock()
protected void wakePollIfNeeded(int waitingCount)
Copyright © 2007–2019 Cloudera. All rights reserved.