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 org.apache.hadoop.classification.InterfaceAudience.Private;
022import org.apache.hadoop.classification.InterfaceAudience.Public;
023import org.apache.hadoop.classification.InterfaceStability.Stable;
024import 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
041public 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   * <p>When threshold number of the nodemanager-local-directories or
078   * threshold number of the nodemanager-log-directories become bad, then
079   * container is not launched and is exited with exit status of
080   * {@literal -101}.</p>
081   *  
082   * @return <em>exit status</em> for the container
083   */
084  @Public
085  @Stable
086  int getExitStatus();
087  
088  @Private
089  @Unstable
090  void setExitStatus(int exitStatus);
091
092  /**
093   * Get <em>diagnostic messages</em> for failed containers.
094   * @return <em>diagnostic messages</em> for failed containers
095   */
096  @Public
097  @Stable
098  String getDiagnostics();
099  
100  @Private
101  @Unstable
102  void setDiagnostics(String diagnostics);
103}