Interface ProcedureScheduler
- All Known Implementing Classes:
AbstractProcedureScheduler
,MasterProcedureScheduler
,SimpleProcedureScheduler
Keep track of the runnable procedures
-
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.void
clear()
Clear current state of scheduler such that it is equivalent to newly created scheduler.void
completionCleanup
(Procedure proc) The procedure in execution completed.getLockResource
(LockedResourceType resourceType, String resourceName) getLocks()
List lock queues.boolean
Returns true if there are procedures available to process, otherwise false.poll()
Fetch one Procedure from the queueFetch one Procedure from the queuevoid
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 schedulervoid
The procedure can't run at the moment.
-
Method Details
-
start
void start()Start the scheduler -
stop
void stop()Stop the scheduler -
signalAll
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. -
addFront
Inserts the specified element at the front of this queue.- Parameters:
proc
- the Procedure to add
-
addFront
Inserts the specified element at the front of this queue.- Parameters:
proc
- the Procedure to addnotify
- whether need to notify worker
-
addFront
Inserts all elements in the iterator at the front of this queue. -
addBack
Inserts the specified element at the end of this queue.- Parameters:
proc
- the Procedure to add
-
addBack
Inserts the specified element at the end of this queue.- Parameters:
proc
- the Procedure to addnotify
- whether need to notify worker
-
yield
The procedure can't run at the moment. add it back to the queue, giving priority to someone else.- Parameters:
proc
- the Procedure to add back to the list
-
completionCleanup
The procedure in execution completed. This can be implemented to perform cleanups.- Parameters:
proc
- the Procedure that completed the execution.
-
hasRunnables
boolean hasRunnables()Returns true if there are procedures available to process, otherwise false. -
poll
Fetch one Procedure from the queue- Returns:
- the Procedure to execute, or null if nothing present.
-
poll
Fetch one Procedure from the queue- 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.
-
getLocks
List lock queues.- Returns:
- the locks
-
getLockResource
- Returns:
LockedResource
for resource of specified type & name. null if resource is not locked.
-
size
int size()Returns the number of elements in this queue.- Returns:
- the number of elements in this queue.
-
clear
void clear()Clear current state of scheduler such that it is equivalent to newly created scheduler. Used for testing failure and recovery. To emulate server crash/restart,ProcedureExecutor
resets its own state and calls clear() on scheduler.
-