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.util.Set;
022
023import org.apache.hadoop.classification.InterfaceAudience.Private;
024import org.apache.hadoop.classification.InterfaceAudience.Public;
025import org.apache.hadoop.classification.InterfaceStability.Stable;
026import org.apache.hadoop.classification.InterfaceStability.Unstable;
027import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
028import org.apache.hadoop.yarn.util.Records;
029
030/**
031 * <p><code>NodeReport</code> is a summary of runtime information of a 
032 * node in the cluster.</p>
033 * 
034 * <p>It includes details such as:
035 *   <ul>
036 *     <li>{@link NodeId} of the node.</li>
037 *     <li>HTTP Tracking URL of the node.</li>
038 *     <li>Rack name for the node.</li>
039 *     <li>Used {@link Resource} on the node.</li>
040 *     <li>Total available {@link Resource} of the node.</li>
041 *     <li>Number of running containers on the node.</li>
042 *   </ul>
043 * </p>
044 *
045 * @see ApplicationClientProtocol#getClusterNodes(org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesRequest)
046 */
047@Public
048@Stable
049public abstract class NodeReport {
050  
051  @Private
052  @Unstable
053  public static NodeReport newInstance(NodeId nodeId, NodeState nodeState,
054      String httpAddress, String rackName, Resource used, Resource capability,
055      int numContainers, String healthReport, long lastHealthReportTime) {
056    return newInstance(nodeId, nodeState, httpAddress, rackName, used,
057        capability, numContainers, healthReport, lastHealthReportTime, null);
058  }
059
060  @Private
061  @Unstable
062  public static NodeReport newInstance(NodeId nodeId, NodeState nodeState,
063      String httpAddress, String rackName, Resource used, Resource capability,
064      int numContainers, String healthReport, long lastHealthReportTime,
065      Set<String> nodeLabels) {
066    NodeReport nodeReport = Records.newRecord(NodeReport.class);
067    nodeReport.setNodeId(nodeId);
068    nodeReport.setNodeState(nodeState);
069    nodeReport.setHttpAddress(httpAddress);
070    nodeReport.setRackName(rackName);
071    nodeReport.setUsed(used);
072    nodeReport.setCapability(capability);
073    nodeReport.setNumContainers(numContainers);
074    nodeReport.setHealthReport(healthReport);
075    nodeReport.setLastHealthReportTime(lastHealthReportTime);
076    nodeReport.setNodeLabels(nodeLabels);
077    return nodeReport;
078  }
079
080  /**
081   * Get the <code>NodeId</code> of the node.
082   * @return <code>NodeId</code> of the node
083   */
084  @Public
085  @Stable
086  public abstract NodeId getNodeId();
087  
088  @Private
089  @Unstable
090  public abstract void setNodeId(NodeId nodeId);
091  
092  /**
093   * Get the <code>NodeState</code> of the node.
094   * @return <code>NodeState</code> of the node
095   */
096  @Public
097  @Stable
098  public abstract NodeState getNodeState();
099  
100  @Private
101  @Unstable
102  public abstract void setNodeState(NodeState nodeState);
103  
104  /**
105   * Get the <em>http address</em> of the node.
106   * @return <em>http address</em> of the node
107   */
108  @Public
109  @Stable
110  public abstract String getHttpAddress();
111  
112  @Private
113  @Unstable
114  public abstract void setHttpAddress(String httpAddress);
115  
116  /**
117   * Get the <em>rack name</em> for the node.
118   * @return <em>rack name</em> for the node
119   */
120  @Public
121  @Stable
122  public abstract String getRackName();
123  
124  @Private
125  @Unstable
126  public abstract void setRackName(String rackName);
127  
128  /**
129   * Get <em>used</em> <code>Resource</code> on the node.
130   * @return <em>used</em> <code>Resource</code> on the node
131   */
132  @Public
133  @Stable
134  public abstract Resource getUsed();
135  
136  @Private
137  @Unstable
138  public abstract void setUsed(Resource used);
139  
140  /**
141   * Get the <em>total</em> <code>Resource</code> on the node.
142   * @return <em>total</em> <code>Resource</code> on the node
143   */
144  @Public
145  @Stable
146  public abstract Resource getCapability();
147  
148  @Private
149  @Unstable
150  public abstract void setCapability(Resource capability);
151  
152  /**
153   * Get the <em>number of allocated containers</em> on the node.
154   * @return <em>number of allocated containers</em> on the node
155   */
156  @Private
157  @Unstable
158  public abstract int getNumContainers();
159  
160  @Private
161  @Unstable
162  public abstract void setNumContainers(int numContainers);
163  
164
165  /** 
166   * Get the <em>diagnostic health report</em> of the node.
167   * @return <em>diagnostic health report</em> of the node
168   */
169  @Public
170  @Stable
171  public abstract String getHealthReport();
172
173  @Private
174  @Unstable
175  public abstract void setHealthReport(String healthReport);
176
177  /**
178   * Get the <em>last timestamp</em> at which the health report was received.
179   * @return <em>last timestamp</em> at which the health report was received
180   */
181  @Public
182  @Stable
183  public abstract long getLastHealthReportTime();
184
185  @Private
186  @Unstable
187  public abstract void setLastHealthReportTime(long lastHealthReport);
188  
189  /**
190   * Get labels of this node
191   * @return labels of this node
192   */
193  @Public
194  @Stable
195  public abstract Set<String> getNodeLabels();
196  
197  @Private
198  @Unstable
199  public abstract void setNodeLabels(Set<String> nodeLabels);
200}