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 org.apache.hadoop.classification.InterfaceAudience.Private;
022    import org.apache.hadoop.classification.InterfaceAudience.Public;
023    import org.apache.hadoop.classification.InterfaceStability.Stable;
024    import org.apache.hadoop.classification.InterfaceStability.Unstable;
025    
026    /**
027     * <p><code>ContainerStatus</code> represents the current status of a 
028     * <code>Container</code>.</p>
029     * 
030     * <p>It provides details such as:
031     *   <ul>
032     *     <li><code>ContainerId</code> of the container.</li>
033     *     <li><code>ContainerState</code> of the container.</li>
034     *     <li><em>Exit status</em> of a completed container.</li>
035     *     <li><em>Diagnostic</em> message for a failed container.</li>
036     *   </ul>
037     * </p>
038     */
039    @Public
040    @Stable
041    public interface ContainerStatus {
042      /**
043       * Get the <code>ContainerId</code> of the container.
044       * @return <code>ContainerId</code> of the container
045       */
046      @Public
047      @Stable
048      ContainerId getContainerId();
049      
050      @Private
051      @Unstable
052      void setContainerId(ContainerId containerId);
053    
054      /**
055       * Get the <code>ContainerState</code> of the container.
056       * @return <code>ContainerState</code> of the container
057       */
058      @Public
059      @Stable
060      ContainerState getState();
061      
062      @Private
063      @Unstable
064      void setState(ContainerState state);
065    
066      /**
067       * <p>Get the <em>exit status</em> for the container.</p>
068       *  
069       * <p>Note: This is valid only for completed containers i.e. containers
070       * with state {@link ContainerState#COMPLETE}. 
071       * Otherwise, it returns an invalid exit code equal to {@literal -1000};</p>
072       * 
073       * <p>Container killed by the framework, either due to being released by
074       * the application or being 'lost' due to node failures etc. have a special
075       * exit code of {@literal -100}.</p>
076       *  
077       * @return <em>exit status</em> for the container
078       */
079      @Public
080      @Stable
081      int getExitStatus();
082      
083      @Private
084      @Unstable
085      void setExitStatus(int exitStatus);
086    
087      /**
088       * Get <em>diagnostic messages</em> for failed containers.
089       * @return <em>diagnostic messages</em> for failed containers
090       */
091      @Public
092      @Stable
093      String getDiagnostics();
094      
095      @Private
096      @Unstable
097      void setDiagnostics(String diagnostics);
098    }