public interface UsageTrackedQueue
There are effectively two sets of methods. One set is called during a scheduling iteration. These are:
The other set is called between consecutive scheduling iterations. Scheduling iteration is marked as completed by callingreset()
. The methods in this set are:
Modifier and Type | Interface and Description |
---|---|
static class |
UsageTrackedQueue.ResUsage |
Modifier and Type | Method and Description |
---|---|
void |
assignTask(QueuableTask t)
Mark the given task to be assigned resources.
|
java.util.Map<TaskQueue.TaskState,java.util.Collection<QueuableTask>> |
getAllTasks()
Get list of all tasks grouped by their state.
|
double |
getDominantUsageShare()
Get the usage of the dominant resource, expressed as a share of the total known available resources.
|
boolean |
launchTask(QueuableTask t)
Mark the given task as launched.
|
Assignable<QueuableTask> |
nextTaskToLaunch()
Get the next task to assign resources to.
|
void |
queueTask(QueuableTask t)
Add the given task to the queue.
|
QueuableTask |
removeTask(java.lang.String id,
QAttributes qAttributes)
Remove the given task from the queue, irrespective of whether it is queued or launched.
|
void |
reset()
Reset the queue to mark the end of a scheduling iteration.
|
void |
setTotalResources(java.util.Map<VMResource,java.lang.Double> totalResourcesMap)
Set the map of total resources available.
|
void queueTask(QueuableTask t) throws TaskQueueException
t
- The task to add to the queue.TaskQueueException
- if either the task already exists in the queue or if the queue is being iterated on.Assignable<QueuableTask> nextTaskToLaunch() throws TaskQueueException
null
is returned. The
first call to this method marks the queue as being iterated upon for scheduling. The reset()
method
must be called to mark the end of the scheduling iteration, after which other queue modification methods such as
queueTask(QueuableTask)
, launchTask(QueuableTask)
, and removeTask(String, QAttributes)
can be called.null
if there are no tasks left to assign resources to.TaskQueueException
- if there was an error getting next task from the queue.void assignTask(QueuableTask t) throws TaskQueueException
nextTaskToLaunch()
marks the queue as being iterated on.t
- The task to be marked as assigned.TaskQueueException
- if this method was called outside of a scheduling loop.boolean launchTask(QueuableTask t) throws TaskQueueException
assignTask(QueuableTask)
and
this method are called for the same task. This method indicates if the resource usage totals were updated
during this call.t
- The task to launch.TaskQueueException
- if the queue is being iterated on for a scheduling iteration.QueuableTask removeTask(java.lang.String id, QAttributes qAttributes) throws TaskQueueException
reset()
must be called before
calling this method.id
- The task id to removeqAttributes
- The queue attributes for the task to removeQueuableTask
that was removed, or null
if the task wasn't found.TaskQueueException
- if the queue is being iterated on for a scheduling iteration.double getDominantUsageShare()
void reset()
java.util.Map<TaskQueue.TaskState,java.util.Collection<QueuableTask>> getAllTasks() throws TaskQueueException
Map
with TaskQueue.TaskState
as key and Collection
of
QueuableTask
as values.TaskQueueException
- if called concurrently with a scheduling iteration in progress.void setTotalResources(java.util.Map<VMResource,java.lang.Double> totalResourcesMap)
totalResourcesMap
- Map of total resources to set.