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.Unstable;
024import org.apache.hadoop.yarn.util.Records;
025
026/**
027 * {@code ContainerReport} is a report of an container.
028 * <p>
029 * It includes details such as:
030 * <ul>
031 *   <li>{@link ContainerId} of the container.</li>
032 *   <li>Allocated Resources to the container.</li>
033 *   <li>Assigned Node id.</li>
034 *   <li>Assigned Priority.</li>
035 *   <li>Creation Time.</li>
036 *   <li>Finish Time.</li>
037 *   <li>Container Exit Status.</li>
038 *   <li>{@link ContainerState} of the container.</li>
039 *   <li>Diagnostic information in case of errors.</li>
040 *   <li>Log URL.</li>
041 *   <li>nodeHttpAddress</li>
042 * </ul>
043 */
044
045@Public
046@Unstable
047public abstract class ContainerReport {
048  @Private
049  @Unstable
050  public static ContainerReport newInstance(ContainerId containerId,
051      Resource allocatedResource, NodeId assignedNode, Priority priority,
052      long creationTime, long finishTime, String diagnosticInfo, String logUrl,
053      int containerExitStatus, ContainerState containerState,
054      String nodeHttpAddress) {
055    ContainerReport report = Records.newRecord(ContainerReport.class);
056    report.setContainerId(containerId);
057    report.setAllocatedResource(allocatedResource);
058    report.setAssignedNode(assignedNode);
059    report.setPriority(priority);
060    report.setCreationTime(creationTime);
061    report.setFinishTime(finishTime);
062    report.setDiagnosticsInfo(diagnosticInfo);
063    report.setLogUrl(logUrl);
064    report.setContainerExitStatus(containerExitStatus);
065    report.setContainerState(containerState);
066    report.setNodeHttpAddress(nodeHttpAddress);
067    return report;
068  }
069
070  /**
071   * Get the <code>ContainerId</code> of the container.
072   * 
073   * @return <code>ContainerId</code> of the container.
074   */
075  @Public
076  @Unstable
077  public abstract ContainerId getContainerId();
078
079  @Public
080  @Unstable
081  public abstract void setContainerId(ContainerId containerId);
082
083  /**
084   * Get the allocated <code>Resource</code> of the container.
085   * 
086   * @return allocated <code>Resource</code> of the container.
087   */
088  @Public
089  @Unstable
090  public abstract Resource getAllocatedResource();
091
092  @Public
093  @Unstable
094  public abstract void setAllocatedResource(Resource resource);
095
096  /**
097   * Get the allocated <code>NodeId</code> where container is running.
098   * 
099   * @return allocated <code>NodeId</code> where container is running.
100   */
101  @Public
102  @Unstable
103  public abstract NodeId getAssignedNode();
104
105  @Public
106  @Unstable
107  public abstract void setAssignedNode(NodeId nodeId);
108
109  /**
110   * Get the allocated <code>Priority</code> of the container.
111   * 
112   * @return allocated <code>Priority</code> of the container.
113   */
114  @Public
115  @Unstable
116  public abstract Priority getPriority();
117
118  @Public
119  @Unstable
120  public abstract void setPriority(Priority priority);
121
122  /**
123   * Get the creation time of the container.
124   * 
125   * @return creation time of the container
126   */
127  @Public
128  @Unstable
129  public abstract long getCreationTime();
130
131  @Public
132  @Unstable
133  public abstract void setCreationTime(long creationTime);
134
135  /**
136   * Get the Finish time of the container.
137   * 
138   * @return Finish time of the container
139   */
140  @Public
141  @Unstable
142  public abstract long getFinishTime();
143
144  @Public
145  @Unstable
146  public abstract void setFinishTime(long finishTime);
147
148  /**
149   * Get the DiagnosticsInfo of the container.
150   * 
151   * @return DiagnosticsInfo of the container
152   */
153  @Public
154  @Unstable
155  public abstract String getDiagnosticsInfo();
156
157  @Public
158  @Unstable
159  public abstract void setDiagnosticsInfo(String diagnosticsInfo);
160
161  /**
162   * Get the LogURL of the container.
163   * 
164   * @return LogURL of the container
165   */
166  @Public
167  @Unstable
168  public abstract String getLogUrl();
169
170  @Public
171  @Unstable
172  public abstract void setLogUrl(String logUrl);
173
174  /**
175   * Get the final <code>ContainerState</code> of the container.
176   * 
177   * @return final <code>ContainerState</code> of the container.
178   */
179  @Public
180  @Unstable
181  public abstract ContainerState getContainerState();
182
183  @Public
184  @Unstable
185  public abstract void setContainerState(ContainerState containerState);
186
187  /**
188   * Get the final <code>exit status</code> of the container.
189   * 
190   * @return final <code>exit status</code> of the container.
191   */
192  @Public
193  @Unstable
194  public abstract int getContainerExitStatus();
195
196  @Public
197  @Unstable
198  public abstract void setContainerExitStatus(int containerExitStatus);
199
200  /**
201   * Get the Node Http address of the container
202   * 
203   * @return the node http address of the container
204   */
205  @Public
206  @Unstable
207  public abstract String getNodeHttpAddress();
208
209  @Private
210  @Unstable
211  public abstract void setNodeHttpAddress(String nodeHttpAddress);
212}