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    
019    package org.apache.hadoop.yarn.api.records;
020    
021    import java.nio.ByteBuffer;
022    import java.util.List;
023    import java.util.Map;
024    
025    import org.apache.hadoop.classification.InterfaceAudience.Public;
026    import org.apache.hadoop.classification.InterfaceStability.Stable;
027    import org.apache.hadoop.yarn.api.ContainerManager;
028    
029    /**
030     * <p><code>ContainerLaunchContext</code> represents the 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
053    public 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.
131       * @param localResources <code>LocalResource</code> required by the container
132       */
133      @Public
134      @Stable
135      void setLocalResources(Map<String, LocalResource> localResources);
136    
137      /**
138       * Get application-specific binary <em>service data</em>.
139       * @return application-specific binary <em>service data</em>
140       */
141      @Public
142      @Stable
143      Map<String, ByteBuffer> getServiceData();
144      
145      /**
146       * Set application-specific binary <em>service data</em>.
147       * @param serviceData application-specific binary <em>service data</em>
148       */
149      @Public
150      @Stable
151      void setServiceData(Map<String, ByteBuffer> serviceData);
152    
153      /**
154       * Get <em>environment variables</em> for the container.
155       * @return <em>environment variables</em> for the container
156       */
157      @Public
158      @Stable
159      Map<String, String> getEnvironment();
160        
161      /**
162       * Add <em>environment variables</em> for the container.
163       * @param environment <em>environment variables</em> for the container
164       */
165      @Public
166      @Stable
167      void setEnvironment(Map<String, String> environment);
168    
169      /**
170       * Get the list of <em>commands</em> for launching the container.
171       * @return the list of <em>commands</em> for launching the container
172       */
173      @Public
174      @Stable
175      List<String> getCommands();
176      
177      /**
178       * Add the list of <em>commands</em> for launching the container.
179       * @param commands the list of <em>commands</em> for launching the container
180       */
181      @Public
182      @Stable
183      void setCommands(List<String> commands);
184    
185      /**
186       * Get the <code>ApplicationACL</code>s for the application. 
187       * @return all the <code>ApplicationACL</code>s
188       */
189      @Public
190      @Stable
191      public Map<ApplicationAccessType, String> getApplicationACLs();
192    
193      /**
194       * Set the <code>ApplicationACL</code>s for the application. 
195       * @param acls
196       */
197      @Public
198      @Stable
199      public void setApplicationACLs(Map<ApplicationAccessType, String> acls);
200    }