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()
SchedulerStateActionsgetName in interface SchedulerStateActionspublic int getMaxRetries()
public int getStopTimeoutMs()
public Scheduler getScheduler()
SchedulerStateActionsgetScheduler in interface SchedulerStateActionspublic void start(Task task)
start in interface SchedulerStatetask - public void enqueuePendingRequest(Task task)
task - public int maxCurrentRequests()
public boolean requestContainers(EventContext context, int maxRequests)
SchedulerStateActionsrequestContainers in interface SchedulerStateActionspublic void dequeuePendingRequest(Task task)
task - public void enqueueAllocatingTask(Task task)
task - public void containerAllocated(EventContext context, org.apache.hadoop.yarn.api.records.Container container)
SchedulerStateActionscontainerAllocated in interface SchedulerStateActionspublic void checkTasks(EventContext context, long curTime)
checkTasks in interface SchedulerStateActionspublic 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)
SchedulerStateActionsshutDown in interface SchedulerStateActionspublic boolean hasTasks()
public boolean isDone()
SchedulerStateActionsisDone in interface SchedulerStateActionspublic void adjustTasks()
SchedulerStateActionsadjustTasks in interface SchedulerStateActionspublic boolean requestStop(Task task)
public int getTaskCount()
SchedulerStategetTaskCount in interface SchedulerStategetTaskCount in interface SchedulerStateActionspublic int getCancelledTaskCount()
SchedulerStategetCancelledTaskCount in interface SchedulerStatepublic List<Task> getStartingTasks()
SchedulerStategetStartingTasks in interface SchedulerStatepublic List<Task> getActiveTasks()
SchedulerStategetActiveTasks in interface SchedulerStatepublic void cancel(Task task)
cancel in interface SchedulerStatecancel in interface SchedulerStateActionspublic int getLiveCount()
getLiveCount in interface SchedulerStateActionspublic void visitTaskModels(TaskVisitor visitor)
visitTaskModels in interface SchedulerStateActionspublic Task getTask(int id)
getTask in interface SchedulerStateActionspublic int getRequestCount()
getRequestCount in interface SchedulerStateActionspublic ClusterController getController()
getController in interface SchedulerStateCopyright © 2021 The Apache Software Foundation. All rights reserved.