public class TieredQueue extends java.lang.Object implements InternalTaskQueue
0 to N-1 for N tiers, with
0 being the highest priority level.TaskQueue.TaskState| Constructor and Description |
|---|
TieredQueue(int numTiers)
Construct a tiered queue system with the given number of tiers.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<TaskQueue.TaskState,java.util.Collection<QueuableTask>> |
getAllTasks()
Get all of the tasks in the queue.
|
UsageTrackedQueue |
getUsageTracker()
This method provides a bridge to the usage tracked queues contained within the tiered queues implementation.
|
Assignable<QueuableTask> |
next()
This implementation dynamically picks the next task to consider for resource assignment based on tiers and then
based on current dominant resource usage.
|
void |
queueTask(QueuableTask task)
Add a task to the queue.
|
boolean |
reset()
Reset the queue and make it ready for next scheduling iteration.
|
void |
setSla(TaskQueueSla sla)
Set SLA for the queue.
|
public TieredQueue(int numTiers)
numTiers - The number of tiers.public void queueTask(QueuableTask task)
TaskQueueTaskSchedulingService.initializeRunningTask(QueuableTask, String).
This operation is designed to be performed asynchronously, when it is safe to modify the queue. The queue implementations generally do not modify the queue while a scheduling iteration is in progress.
public void setSla(TaskQueueSla sla) throws java.lang.IllegalArgumentException
TaskQueueTaskQueueSla that is
accepted.setSla in interface TaskQueuesla - The SLA to set for the queue.java.lang.IllegalArgumentException - if the implementation of the TaskQueueSla is incompatible with the
queue implementation.public Assignable<QueuableTask> next() throws TaskQueueException
next in interface TaskIteratornull if none
remain for consideration.TaskQueueException - if there is an unknown error getting the next task to launch from any of the tiers or
queue buckets.public boolean reset()
throws TaskQueueMultiException
InternalTaskQueuereset in interface InternalTaskQueuetrue if the queue was changed as part of this operation, false otherwise. The queue is
deemed changed if any queue modifications that were held for safety are carried out during this method, such as
adding to or removing from the queue.TaskQueueMultiException - If any exceptions that may have occurred during resetting the pointer to the head
of the queue. Or, this may include exceptions that arose when applying any deferred operations from
TaskQueue.queueTask(QueuableTask) method.public UsageTrackedQueue getUsageTracker()
getUsageTracker in interface InternalTaskQueueUsageTrackedQueue to account for all the queues within this tiered queue
implementation. This implementation focuses on usage tracking only and therefore does not allow invoking
UsageTrackedQueue.nextTaskToLaunch() and UsageTrackedQueue.getAllTasks().public java.util.Map<TaskQueue.TaskState,java.util.Collection<QueuableTask>> getAllTasks()
InternalTaskQueuegetAllTasks in interface InternalTaskQueueMap with TaskState as key and Collection of
QueuableTask as values.