Class DockerCommandExecutor
java.lang.Object
org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.docker.DockerCommandExecutor
Utility class for executing common docker operations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumPotential states that the docker status can return. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringexecuteDockerCommand(DockerCommand dockerCommand, String containerId, Map<String, String> env, PrivilegedOperationExecutor privilegedOperationExecutor, boolean disableFailureLogging, Context nmContext) Execute a docker command and return the output.getContainerStatus(String containerId, PrivilegedOperationExecutor privilegedOperationExecutor, Context nmContext) Get the status of the docker container.static booleanisKillable(DockerCommandExecutor.DockerContainerStatus containerStatus) Is the container in a killable state?static booleanisRemovable(DockerCommandExecutor.DockerContainerStatus containerStatus) Is the container in a removable state?static booleanisStartable(DockerCommandExecutor.DockerContainerStatus containerStatus) Is the container in a startable state?static booleanisStoppable(DockerCommandExecutor.DockerContainerStatus containerStatus) Is the container in a stoppable state?parseContainerStatus(String containerStatusStr) Parses the container status string.
-
Method Details
-
executeDockerCommand
public static String executeDockerCommand(DockerCommand dockerCommand, String containerId, Map<String, String> env, PrivilegedOperationExecutor privilegedOperationExecutor, boolean disableFailureLogging, Context nmContext) throws ContainerExecutionExceptionExecute a docker command and return the output.- Parameters:
dockerCommand- the docker command to run.containerId- the id of the container.env- environment for the container.privilegedOperationExecutor- the privileged operations executor.disableFailureLogging- disable logging for known rc failures.- Returns:
- the output of the operation.
- Throws:
ContainerExecutionException- if the operation fails.
-
getContainerStatus
public static DockerCommandExecutor.DockerContainerStatus getContainerStatus(String containerId, PrivilegedOperationExecutor privilegedOperationExecutor, Context nmContext) Get the status of the docker container. This runs a docker inspect to get the status. If the container no longer exists, docker inspect throws an exception and the nonexistent status is returned.- Parameters:
containerId- the id of the container.privilegedOperationExecutor- the privileged operations executor.- Returns:
- a
DockerCommandExecutor.DockerContainerStatusrepresenting the current status.
-
parseContainerStatus
public static DockerCommandExecutor.DockerContainerStatus parseContainerStatus(String containerStatusStr) Parses the container status string.- Parameters:
containerStatusStr- container status.- Returns:
- a
DockerCommandExecutor.DockerContainerStatusrepresenting the status.
-
isStoppable
Is the container in a stoppable state?- Parameters:
containerStatus- the container'sDockerCommandExecutor.DockerContainerStatus.- Returns:
- is the container in a stoppable state.
-
isKillable
Is the container in a killable state?- Parameters:
containerStatus- the container'sDockerCommandExecutor.DockerContainerStatus.- Returns:
- is the container in a killable state.
-
isRemovable
Is the container in a removable state?- Parameters:
containerStatus- the container'sDockerCommandExecutor.DockerContainerStatus.- Returns:
- is the container in a removable state.
-
isStartable
Is the container in a startable state?- Parameters:
containerStatus- the container'sDockerCommandExecutor.DockerContainerStatus.- Returns:
- is the container in a startable state.
-