public final class SchedulerStateImpl extends Object implements SchedulerState, SchedulerStateActions
Schedulers, and hence their groups, define a priority. When starting, higher priority (lower priority value) groups run before lower priority groups. Similarly, when shrinking the cluster, lower priority groups shrink before higher priority groups.
Modifier and Type | Field and Description |
---|---|
protected Map<org.apache.hadoop.yarn.api.records.ContainerId,Task> |
activeContainers
Tracks running tasks: those that have been allocated containers and are
starting, running, failed or ended.
|
protected List<Task> |
allocatingTasks
Tracks the tasks for which containers have been requested.
|
protected List<Task> |
pendingTasks
Tracks the tasks to be started, but for which no work has yet been done.
|
Constructor and Description |
---|
SchedulerStateImpl(ClusterControllerImpl controller,
Scheduler scheduler) |
Modifier and Type | Method and Description |
---|---|
void |
adjustTasks()
Adjust the number of running tasks as needed to balance the number of
running tasks with the desired number.
|
void |
cancel(Task task) |
void |
checkTasks(EventContext context,
long curTime) |
void |
containerAllocated(EventContext context,
org.apache.hadoop.yarn.api.records.Container container)
A container request has been granted.
|
void |
containerAllocated(Task task)
Mark that a task has become active and should be tracked by its container
ID.
|
void |
containerReleased(Task task)
Mark that a task has completed: its container has expired or been revoked
or the task has completed: successfully or a failure, as given by the
task's disposition.
|
void |
dequeueAllocatingTask(Task task)
Remove a task from the list of those waiting for a container allocation.
|
void |
dequeuePendingRequest(Task task)
Remove a task from the queue of tasks waiting to send a container request.
|
void |
enqueueAllocatingTask(Task task)
Put a task onto the queue awaiting an allocation response from YARN.
|
void |
enqueuePendingRequest(Task task)
Put a task into the queue waiting to send a container request to YARN.
|
List<Task> |
getActiveTasks()
Returns the list of active tasks that have not yet been cancelled.
|
int |
getCancelledTaskCount()
The number of active tasks that have been cancelled, but have not yet
ended.
|
ClusterController |
getController() |
int |
getLiveCount() |
int |
getMaxRetries() |
String |
getName()
Returns the name of the scheduler associated with this task action group.
|
int |
getRequestCount() |
Scheduler |
getScheduler()
Returns the scheduler associated with this task group.
|
List<Task> |
getStartingTasks()
Returns the list of tasks awaiting a container request to be sent to YARN
or for which a container request has been sent to YARN, but no container
allocation has yet been received.
|
int |
getStopTimeoutMs() |
Task |
getTask(int id) |
int |
getTaskCount()
The number of tasks in any active (non-ended) lifecycle state.
|
boolean |
hasTasks()
Report if this task group has any tasks in the active part of their
life-cycle: pending, allocating or active.
|
boolean |
isDone()
Determine if this task group is done.
|
int |
maxCurrentRequests() |
boolean |
requestContainers(EventContext context,
int maxRequests)
Request a container the first task that we wish to start.
|
boolean |
requestStop(Task task)
Request a graceful stop of the task.
|
void |
shutDown(EventContext context)
Shut down this task group by canceling all tasks not already cancelled.
|
void |
start(Task task)
Define a new task in this group.
|
void |
taskEnded(Task task)
Mark that a task has completed successfully or a failure, as given by the
task's disposition.
|
void |
taskRetried(Task task)
Mark that a task is about to be retried.
|
void |
visitTaskModels(TaskVisitor visitor) |
protected List<Task> pendingTasks
protected List<Task> allocatingTasks
protected Map<org.apache.hadoop.yarn.api.records.ContainerId,Task> activeContainers
public SchedulerStateImpl(ClusterControllerImpl controller, Scheduler scheduler)
public String getName()
SchedulerStateActions
getName
in interface SchedulerStateActions
public int getMaxRetries()
public int getStopTimeoutMs()
public Scheduler getScheduler()
SchedulerStateActions
getScheduler
in interface SchedulerStateActions
public void start(Task task)
start
in interface SchedulerState
task
- public void enqueuePendingRequest(Task task)
task
- public int maxCurrentRequests()
public boolean requestContainers(EventContext context, int maxRequests)
SchedulerStateActions
requestContainers
in interface SchedulerStateActions
public void dequeuePendingRequest(Task task)
task
- public void enqueueAllocatingTask(Task task)
task
- public void containerAllocated(EventContext context, org.apache.hadoop.yarn.api.records.Container container)
SchedulerStateActions
containerAllocated
in interface SchedulerStateActions
public void checkTasks(EventContext context, long curTime)
checkTasks
in interface SchedulerStateActions
public void dequeueAllocatingTask(Task task)
task
- public void containerAllocated(Task task)
task
- public void containerReleased(Task task)
task
- public void taskEnded(Task task)
task
- public void taskRetried(Task task)
task
- public void shutDown(EventContext context)
SchedulerStateActions
shutDown
in interface SchedulerStateActions
public boolean hasTasks()
public boolean isDone()
SchedulerStateActions
isDone
in interface SchedulerStateActions
public void adjustTasks()
SchedulerStateActions
adjustTasks
in interface SchedulerStateActions
public boolean requestStop(Task task)
public int getTaskCount()
SchedulerState
getTaskCount
in interface SchedulerState
getTaskCount
in interface SchedulerStateActions
public int getCancelledTaskCount()
SchedulerState
getCancelledTaskCount
in interface SchedulerState
public List<Task> getStartingTasks()
SchedulerState
getStartingTasks
in interface SchedulerState
public List<Task> getActiveTasks()
SchedulerState
getActiveTasks
in interface SchedulerState
public void cancel(Task task)
cancel
in interface SchedulerState
cancel
in interface SchedulerStateActions
public int getLiveCount()
getLiveCount
in interface SchedulerStateActions
public void visitTaskModels(TaskVisitor visitor)
visitTaskModels
in interface SchedulerStateActions
public Task getTask(int id)
getTask
in interface SchedulerStateActions
public int getRequestCount()
getRequestCount
in interface SchedulerStateActions
public ClusterController getController()
getController
in interface SchedulerState
Copyright © 1970 The Apache Software Foundation. All rights reserved.