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