001/**
002* Licensed to the Apache Software Foundation (ASF) under one
003* or more contributor license agreements.  See the NOTICE file
004* distributed with this work for additional information
005* regarding copyright ownership.  The ASF licenses this file
006* to you under the Apache License, Version 2.0 (the
007* "License"); you may not use this file except in compliance
008* with the License.  You may obtain a copy of the License at
009*
010*     http://www.apache.org/licenses/LICENSE-2.0
011*
012* Unless required by applicable law or agreed to in writing, software
013* distributed under the License is distributed on an "AS IS" BASIS,
014* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015* See the License for the specific language governing permissions and
016* limitations under the License.
017*/
018
019package org.apache.hadoop.yarn.api.records;
020
021import java.nio.ByteBuffer;
022import java.util.List;
023import java.util.Map;
024
025import org.apache.hadoop.classification.InterfaceAudience.Public;
026import org.apache.hadoop.classification.InterfaceStability.Stable;
027import org.apache.hadoop.yarn.api.ContainerManager;
028
029/**
030 * <p><code>ContainerLaunchContext</code> represents all of the information
031 * needed by the <code>NodeManager</code> to launch a container.</p>
032 * 
033 * <p>It includes details such as:
034 *   <ul>
035 *     <li>{@link ContainerId} of the container.</li>
036 *     <li>{@link Resource} allocated to the container.</li>
037 *     <li>User to whom the container is allocated.</li>
038 *     <li>Security tokens (if security is enabled).</li>
039 *     <li>
040 *       {@link LocalResource} necessary for running the container such
041 *       as binaries, jar, shared-objects, side-files etc. 
042 *     </li>
043 *     <li>Optional, application-specific binary service data.</li>
044 *     <li>Environment variables for the launched process.</li>
045 *     <li>Command to launch the container.</li>
046 *   </ul>
047 * </p>
048 * 
049 * @see ContainerManager#startContainer(org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest)
050 */
051@Public
052@Stable
053public interface ContainerLaunchContext {
054  /**
055   * Get <code>ContainerId</code> of container to be launched.
056   * @return <code>ContainerId</code> of container to be launched
057   */
058  @Public
059  @Stable
060  ContainerId getContainerId();
061
062  /**
063   * Set <code>ContainerId</code> of container to be launched.
064   * @param containerId et <code>ContainerId</code> of container to be launched
065   */
066  @Public
067  @Stable
068  void setContainerId(ContainerId containerId);
069
070  /**
071   * Get the <em>user</em> to whom the container has been allocated.
072   * @return the <em>user</em> to whom the container has been allocated
073   */
074  @Public
075  @Stable
076  String getUser();
077  
078  /**
079   * Set the <em>user</em> to whom the container has been allocated
080   * @param user <em>user</em> to whom the container has been allocated
081   */
082  @Public
083  @Stable
084  void setUser(String user);
085
086  /**
087   * Get the <code>Resource</code> allocated to the container by the
088   * <code>ResourceManager</code>.
089   * @return <code>Resource</code> allocated to the container by the
090   *         <code>ResourceManager</code>
091   */
092  @Public
093  @Stable
094  Resource getResource();
095
096  /**
097   * Set the <code>Resource</code> allocated to the container by the
098   * <code>ResourceManager</code>.
099   * @param resource allocated resource
100   */
101  @Public
102  @Stable
103  void setResource(Resource resource);
104
105  /**
106   * Get security tokens (if security is enabled).
107   * @return security tokens (if security is enabled)
108   */
109  @Public
110  @Stable
111  ByteBuffer getContainerTokens();
112
113  /**
114   * Set security tokens (if security is enabled).
115   * @param containerToken security tokens 
116   */
117  @Public
118  @Stable
119  void setContainerTokens(ByteBuffer containerToken);
120
121  /**
122   * Get <code>LocalResource</code> required by the container.
123   * @return all <code>LocalResource</code> required by the container
124   */
125  @Public
126  @Stable
127  Map<String, LocalResource> getLocalResources();
128  
129  /**
130   * Set <code>LocalResource</code> required by the container. All pre-existing
131   * Map entries are cleared before adding the new Map
132   * @param localResources <code>LocalResource</code> required by the container
133   */
134  @Public
135  @Stable
136  void setLocalResources(Map<String, LocalResource> localResources);
137
138  /**
139   * Get application-specific binary <em>service data</em>.
140   * @return application-specific binary <em>service data</em>
141   */
142  @Public
143  @Stable
144  Map<String, ByteBuffer> getServiceData();
145  
146  /**
147   * Set application-specific binary <em>service data</em>. All pre-existing Map
148   * entries are preserved.
149   * @param serviceData application-specific binary <em>service data</em>
150   */
151  @Public
152  @Stable
153  void setServiceData(Map<String, ByteBuffer> serviceData);
154
155  /**
156   * Get <em>environment variables</em> for the container.
157   * @return <em>environment variables</em> for the container
158   */
159  @Public
160  @Stable
161  Map<String, String> getEnvironment();
162    
163  /**
164   * Add <em>environment variables</em> for the container. All pre-existing Map
165   * entries are cleared before adding the new Map
166   * @param environment <em>environment variables</em> for the container
167   */
168  @Public
169  @Stable
170  void setEnvironment(Map<String, String> environment);
171
172  /**
173   * Get the list of <em>commands</em> for launching the container.
174   * @return the list of <em>commands</em> for launching the container
175   */
176  @Public
177  @Stable
178  List<String> getCommands();
179  
180  /**
181   * Add the list of <em>commands</em> for launching the container. All
182   * pre-existing List entries are cleared before adding the new List
183   * @param commands the list of <em>commands</em> for launching the container
184   */
185  @Public
186  @Stable
187  void setCommands(List<String> commands);
188
189  /**
190   * Get the <code>ApplicationACL</code>s for the application. 
191   * @return all the <code>ApplicationACL</code>s
192   */
193  @Public
194  @Stable
195  public Map<ApplicationAccessType, String> getApplicationACLs();
196
197  /**
198   * Set the <code>ApplicationACL</code>s for the application. All pre-existing
199   * Map entries are cleared before adding the new Map
200   * @param acls <code>ApplicationACL</code>s for the application
201   */
202  @Public
203  @Stable
204  public void setApplicationACLs(Map<ApplicationAccessType, String> acls);
205}