public class ClusterControllerImpl extends Object implements ClusterController
This class is designed to allow unit tests. In general, testing the controller on a live cluster is tedious. This class encapsulates the controller algorithm so it can be driven by a simulated cluster.
This object is shared between threads, thus synchronized.
| Modifier and Type | Class and Description |
|---|---|
static class |
ClusterControllerImpl.State
Controller lifecycle state.
|
| Modifier and Type | Field and Description |
|---|---|
protected int |
maxRetries
Maximum number of retries for each task launch.
|
| Constructor and Description |
|---|
ClusterControllerImpl(AMYarnFacade yarn) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancelTask(int id)
Cancels the given task, reducing the target task count.
|
void |
completionAck(Task task,
String propertyKey) |
void |
containerAllocated(Task task) |
void |
containerReleased(Task task) |
void |
containersAllocated(List<org.apache.hadoop.yarn.api.records.Container> containers)
The RM has allocated one or more containers in response to container
requests submitted to the RM.
|
void |
containersCompleted(List<org.apache.hadoop.yarn.api.records.ContainerStatus> statuses)
The Resource Manager reports that containers have completed with the given
statuses.
|
void |
containerStarted(org.apache.hadoop.yarn.api.records.ContainerId containerId)
The NM reports that a container has successfully started.
|
void |
containerStopped(org.apache.hadoop.yarn.api.records.ContainerId containerId)
The Node Manager reports that a container has stopped.
|
void |
enableFailureCheck(boolean flag) |
void |
fireLifecycleChange(TaskLifecycleListener.Event event,
EventContext context) |
int |
getFreeNodeCount()
Get the approximate number of free YARN nodes (those that can
accept a task request.) Starts with the number of nodes from
the node inventory, then subtracts any in-flight requests (which
do not, by definition, have node allocated.)
|
List<Task> |
getHistory() |
int |
getMaxRetries() |
NodeInventory |
getNodeInventory() |
List<SchedulerStateActions> |
getPools() |
float |
getProgress() |
Object |
getProperty(String key) |
ClusterControllerImpl.State |
getState() |
int |
getStopTimeoutMs() |
int |
getTargetCount()
Return the target number of tasks that the controller seeks to maintain.
|
AMYarnFacade |
getYarn() |
boolean |
isLive() |
boolean |
isTaskLive(int id) |
void |
registerLifecycleListener(TaskLifecycleListener listener) |
void |
registerScheduler(Scheduler scheduler)
Define a task type.
|
void |
registryDown() |
void |
releaseHost(String hostName) |
void |
reserveHost(String hostName) |
void |
resizeDelta(int delta)
Request to resize the Drill cluster by a relative amount.
|
int |
resizeTo(int n)
Request to resize the Drill cluster to the given size.
|
void |
setMaxRetries(int value) |
void |
setProperty(String key,
Object value) |
void |
shutDown()
Indicates a request to gracefully shut down the cluster.
|
void |
startAck(Task task,
String propertyKey,
Object value) |
void |
started()
Called when the caller has completed start-up and the controller should
become live.
|
void |
stopTaskFailed(org.apache.hadoop.yarn.api.records.ContainerId containerId,
Throwable t)
The Node Manager API reports that a request sent to the NM to stop a task
has failed.
|
boolean |
succeeded() |
boolean |
supportsDiskResource()
Whether this distribution of YARN supports disk resources.
|
void |
taskEnded(Task task) |
void |
taskGroupCompleted(SchedulerStateActions taskGroup) |
void |
taskRetried(Task task) |
void |
taskStartFailed(org.apache.hadoop.yarn.api.records.ContainerId containerId,
Throwable t)
The RM API reports that an attempt to start a container has failed locally.
|
void |
tick(long curTime)
Called by the timer ("pulse") thread to trigger time-based events.
|
void |
updateRMStatus()
Get an update from YARN on available resources.
|
void |
visit(ControllerVisitor visitor)
Allow an observer to see a consistent view of the controller's
state by performing the visit in a synchronized block.
|
void |
visitTasks(TaskVisitor visitor)
Allow an observer to see a consistent view of the controller's
task state by performing the visit in a synchronized block.
|
boolean |
waitForCompletion()
Called by the main thread to wait for the normal shutdown of the
controller.
|
public ClusterControllerImpl(AMYarnFacade yarn)
public void enableFailureCheck(boolean flag)
enableFailureCheck in interface ClusterControllerpublic void registerScheduler(Scheduler scheduler)
registerScheduler in interface ClusterControllerscheduler - public void started()
throws YarnFacadeException,
AMException
started in interface ClusterControllerYarnFacadeExceptionAMExceptionpublic void tick(long curTime)
ClusterControllertick in interface ClusterControllerpublic int getFreeNodeCount()
This approximation does not consider whether the node has sufficient resources to run a task; only whether the node itself exists.
getFreeNodeCount in interface ClusterControllerpublic void updateRMStatus()
updateRMStatus in interface ClusterControllerpublic void containersAllocated(List<org.apache.hadoop.yarn.api.records.Container> containers)
ClusterControllercontainersAllocated in interface ClusterControllercontainers - the set of containers provided by YARNpublic void containerStarted(org.apache.hadoop.yarn.api.records.ContainerId containerId)
ClusterControllercontainerStarted in interface ClusterControllercontainerId - the container which startedpublic void taskStartFailed(org.apache.hadoop.yarn.api.records.ContainerId containerId,
Throwable t)
ClusterControllertaskStartFailed in interface ClusterControllercontainerId - the container that failed to launcht - the error that occurredpublic void containerStopped(org.apache.hadoop.yarn.api.records.ContainerId containerId)
ClusterControllercontainerStopped in interface ClusterControllerpublic void containersCompleted(List<org.apache.hadoop.yarn.api.records.ContainerStatus> statuses)
ClusterControllercontainersCompleted in interface ClusterControllerpublic float getProgress()
getProgress in interface ClusterControllerpublic void stopTaskFailed(org.apache.hadoop.yarn.api.records.ContainerId containerId,
Throwable t)
ClusterControllerstopTaskFailed in interface ClusterControllercontainerId - the container that failed to stopt - the reason that the stop request failedpublic void resizeDelta(int delta)
ClusterControllerresizeDelta in interface ClusterControllerdelta - the amount of change. Can be positive (to grow) or negative (to
shrink the cluster)public int resizeTo(int n)
ClusterControllerresizeTo in interface ClusterControllern - the desired cluster sizepublic void shutDown()
ClusterControllershutDown in interface ClusterControllerpublic boolean waitForCompletion()
ClusterControllerwaitForCompletion in interface ClusterControllerpublic boolean isLive()
public boolean succeeded()
public void containerAllocated(Task task)
public AMYarnFacade getYarn()
public void containerReleased(Task task)
public void taskEnded(Task task)
public void taskRetried(Task task)
public void taskGroupCompleted(SchedulerStateActions taskGroup)
public int getMaxRetries()
public int getStopTimeoutMs()
public void reserveHost(String hostName)
reserveHost in interface RegistryHandlerpublic void releaseHost(String hostName)
releaseHost in interface RegistryHandlerpublic NodeInventory getNodeInventory()
public void setProperty(String key, Object value)
setProperty in interface ClusterControllerpublic Object getProperty(String key)
getProperty in interface ClusterControllerpublic void registerLifecycleListener(TaskLifecycleListener listener)
registerLifecycleListener in interface ClusterControllerpublic void fireLifecycleChange(TaskLifecycleListener.Event event, EventContext context)
public void setMaxRetries(int value)
setMaxRetries in interface ClusterControllerpublic int getTargetCount()
ClusterControllergetTargetCount in interface ClusterControllerpublic ClusterControllerImpl.State getState()
public void visit(ControllerVisitor visitor)
ClusterControllervisit in interface ClusterControllerpublic List<SchedulerStateActions> getPools()
public void visitTasks(TaskVisitor visitor)
ClusterControllervisitTasks in interface ClusterControllerpublic boolean isTaskLive(int id)
isTaskLive in interface ClusterControllerpublic boolean cancelTask(int id)
ClusterControllercancelTask in interface ClusterControllerpublic void completionAck(Task task, String propertyKey)
completionAck in interface RegistryHandlerpublic void startAck(Task task, String propertyKey, Object value)
startAck in interface RegistryHandlerpublic boolean supportsDiskResource()
ClusterControllersupportsDiskResource in interface ClusterControllerpublic void registryDown()
registryDown in interface RegistryHandlerCopyright © 2021 The Apache Software Foundation. All rights reserved.