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 * {@code NodeReport} is a summary of runtime information of a node
032 * in the cluster.
033 * <p>
034 * 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 *
044 * @see ApplicationClientProtocol#getClusterNodes(org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesRequest)
045 */
046@Public
047@Stable
048public abstract class NodeReport {
049  
050  @Private
051  @Unstable
052  public static NodeReport newInstance(NodeId nodeId, NodeState nodeState,
053      String httpAddress, String rackName, Resource used, Resource capability,
054      int numContainers, String healthReport, long lastHealthReportTime) {
055    return newInstance(nodeId, nodeState, httpAddress, rackName, used,
056        capability, numContainers, healthReport, lastHealthReportTime, null);
057  }
058
059  @Private
060  @Unstable
061  public static NodeReport newInstance(NodeId nodeId, NodeState nodeState,
062      String httpAddress, String rackName, Resource used, Resource capability,
063      int numContainers, String healthReport, long lastHealthReportTime,
064      Set<String> nodeLabels) {
065    NodeReport nodeReport = Records.newRecord(NodeReport.class);
066    nodeReport.setNodeId(nodeId);
067    nodeReport.setNodeState(nodeState);
068    nodeReport.setHttpAddress(httpAddress);
069    nodeReport.setRackName(rackName);
070    nodeReport.setUsed(used);
071    nodeReport.setCapability(capability);
072    nodeReport.setNumContainers(numContainers);
073    nodeReport.setHealthReport(healthReport);
074    nodeReport.setLastHealthReportTime(lastHealthReportTime);
075    nodeReport.setNodeLabels(nodeLabels);
076    return nodeReport;
077  }
078
079  /**
080   * Get the <code>NodeId</code> of the node.
081   * @return <code>NodeId</code> of the node
082   */
083  @Public
084  @Stable
085  public abstract NodeId getNodeId();
086  
087  @Private
088  @Unstable
089  public abstract void setNodeId(NodeId nodeId);
090  
091  /**
092   * Get the <code>NodeState</code> of the node.
093   * @return <code>NodeState</code> of the node
094   */
095  @Public
096  @Stable
097  public abstract NodeState getNodeState();
098  
099  @Private
100  @Unstable
101  public abstract void setNodeState(NodeState nodeState);
102  
103  /**
104   * Get the <em>http address</em> of the node.
105   * @return <em>http address</em> of the node
106   */
107  @Public
108  @Stable
109  public abstract String getHttpAddress();
110  
111  @Private
112  @Unstable
113  public abstract void setHttpAddress(String httpAddress);
114  
115  /**
116   * Get the <em>rack name</em> for the node.
117   * @return <em>rack name</em> for the node
118   */
119  @Public
120  @Stable
121  public abstract String getRackName();
122  
123  @Private
124  @Unstable
125  public abstract void setRackName(String rackName);
126  
127  /**
128   * Get <em>used</em> <code>Resource</code> on the node.
129   * @return <em>used</em> <code>Resource</code> on the node
130   */
131  @Public
132  @Stable
133  public abstract Resource getUsed();
134  
135  @Private
136  @Unstable
137  public abstract void setUsed(Resource used);
138  
139  /**
140   * Get the <em>total</em> <code>Resource</code> on the node.
141   * @return <em>total</em> <code>Resource</code> on the node
142   */
143  @Public
144  @Stable
145  public abstract Resource getCapability();
146  
147  @Private
148  @Unstable
149  public abstract void setCapability(Resource capability);
150  
151  /**
152   * Get the <em>number of allocated containers</em> on the node.
153   * @return <em>number of allocated containers</em> on the node
154   */
155  @Private
156  @Unstable
157  public abstract int getNumContainers();
158  
159  @Private
160  @Unstable
161  public abstract void setNumContainers(int numContainers);
162  
163
164  /** 
165   * Get the <em>diagnostic health report</em> of the node.
166   * @return <em>diagnostic health report</em> of the node
167   */
168  @Public
169  @Stable
170  public abstract String getHealthReport();
171
172  @Private
173  @Unstable
174  public abstract void setHealthReport(String healthReport);
175
176  /**
177   * Get the <em>last timestamp</em> at which the health report was received.
178   * @return <em>last timestamp</em> at which the health report was received
179   */
180  @Public
181  @Stable
182  public abstract long getLastHealthReportTime();
183
184  @Private
185  @Unstable
186  public abstract void setLastHealthReportTime(long lastHealthReport);
187  
188  /**
189   * Get labels of this node
190   * @return labels of this node
191   */
192  @Public
193  @Stable
194  public abstract Set<String> getNodeLabels();
195  
196  @Private
197  @Unstable
198  public abstract void setNodeLabels(Set<String> nodeLabels);
199
200  /**
201   * Get containers aggregated resource utilization in a node
202   * @return containers resource utilization
203   */
204  @Public
205  @Stable
206  public abstract ResourceUtilization getAggregatedContainersUtilization();
207
208  @Private
209  @Unstable
210  public abstract void setAggregatedContainersUtilization(ResourceUtilization
211      containersUtilization);
212
213  /**
214   * Get node resource utilization
215   * @return node resource utilization
216   */
217  @Public
218  @Stable
219  public abstract ResourceUtilization getNodeUtilization();
220
221  @Private
222  @Unstable
223  public abstract void setNodeUtilization(ResourceUtilization nodeUtilization);
224}