Revert "YARN-7677. Docker image cannot set HADOOP_CONF_DIR. Contributed by Jim Brennan"
[hadoop.git] / hadoop-yarn-project / hadoop-yarn / hadoop-yarn-server / hadoop-yarn-server-nodemanager / src / main / java / org / apache / hadoop / yarn / server / nodemanager / containermanager / runtime / ContainerRuntime.java
1 /*
2 * *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * /
19 */
20
21 package org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime;
22
23 import org.apache.hadoop.classification.InterfaceAudience;
24 import org.apache.hadoop.classification.InterfaceStability;
25 import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container;
26
27 import java.util.Map;
28
29 /**
30 * An abstraction for various container runtime implementations. Examples
31 * include Process Tree, Docker, Appc runtimes etc. These implementations
32 * are meant for low-level OS container support - dependencies on
33 * higher-level node mananger constructs should be avoided.
34 */
35
36 @InterfaceAudience.Private
37 @InterfaceStability.Unstable
38 public interface ContainerRuntime {
39 /**
40 * Prepare a container to be ready for launch.
41 *
42 * @param ctx the {@link ContainerRuntimeContext}
43 * @throws ContainerExecutionException if an error occurs while preparing
44 * the container
45 */
46 void prepareContainer(ContainerRuntimeContext ctx)
47 throws ContainerExecutionException;
48
49 /**
50 * Launch a container.
51 *
52 * @param ctx the {@link ContainerRuntimeContext}
53 * @throws ContainerExecutionException if an error occurs while launching
54 * the container
55 */
56 void launchContainer(ContainerRuntimeContext ctx)
57 throws ContainerExecutionException;
58
59 /**
60 * Signal a container. Signals may be a request to terminate, a status check,
61 * etc.
62 *
63 * @param ctx the {@link ContainerRuntimeContext}
64 * @throws ContainerExecutionException if an error occurs while signaling
65 * the container
66 */
67 void signalContainer(ContainerRuntimeContext ctx)
68 throws ContainerExecutionException;
69
70 /**
71 * Perform any container cleanup that may be required.
72 *
73 * @param ctx the {@link ContainerRuntimeContext}
74 * @throws ContainerExecutionException if an error occurs while reaping
75 * the container
76 */
77 void reapContainer(ContainerRuntimeContext ctx)
78 throws ContainerExecutionException;
79
80 /**
81 * Return the host and ip of the container
82 *
83 * @param container the {@link Container}
84 * @throws ContainerExecutionException if an error occurs while getting the ip
85 * and hostname
86 */
87 String[] getIpAndHost(Container container) throws ContainerExecutionException;
88
89 /**
90 * Whether to propagate the whitelist of environment variables from the
91 * nodemanager environment into the container environment.
92 * @param env the container's environment variables
93 * @return true if whitelist variables should be propagated, false otherwise
94 * @see org.apache.hadoop.yarn.conf.YarnConfiguration#NM_ENV_WHITELIST
95 */
96 boolean useWhitelistEnv(Map<String, String> env);
97 }