1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 package org.apache.hadoop.yarn.server.api.records; 19 20 import org.apache.hadoop.classification.InterfaceAudience.Private; 21 import org.apache.hadoop.classification.InterfaceAudience.Public; 22 import org.apache.hadoop.classification.InterfaceStability.Stable; 23 import org.apache.hadoop.classification.InterfaceStability.Unstable; 24 import org.apache.hadoop.yarn.api.ApplicationClientProtocol; 25 import org.apache.hadoop.yarn.api.records.NodeReport; 26 import org.apache.hadoop.yarn.util.Records; 27 28 /** 29 * {@code NodeHealthStatus} is a summary of the health status of the node. 30 * <p> 31 * It includes information such as: 32 * <ul> 33 * <li> 34 * An indicator of whether the node is healthy, as determined by the 35 * health-check script. 36 * </li> 37 * <li>The previous time at which the health status was reported.</li> 38 * <li>A diagnostic report on the health status.</li> 39 * </ul> 40 * 41 * @see NodeReport 42 * @see ApplicationClientProtocol#getClusterNodes(org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesRequest) 43 */ 44 @Public 45 @Stable 46 public abstract class NodeHealthStatus { 47 48 @Private newInstance(boolean isNodeHealthy, String healthReport, long lastHealthReport)49 public static NodeHealthStatus newInstance(boolean isNodeHealthy, 50 String healthReport, long lastHealthReport) { 51 NodeHealthStatus status = Records.newRecord(NodeHealthStatus.class); 52 status.setIsNodeHealthy(isNodeHealthy); 53 status.setHealthReport(healthReport); 54 status.setLastHealthReportTime(lastHealthReport); 55 return status; 56 } 57 58 /** 59 * Is the node healthy? 60 * @return <code>true</code> if the node is healthy, else <code>false</code> 61 */ 62 @Public 63 @Stable getIsNodeHealthy()64 public abstract boolean getIsNodeHealthy(); 65 66 @Private 67 @Unstable setIsNodeHealthy(boolean isNodeHealthy)68 public abstract void setIsNodeHealthy(boolean isNodeHealthy); 69 70 /** 71 * Get the <em>diagnostic health report</em> of the node. 72 * @return <em>diagnostic health report</em> of the node 73 */ 74 @Public 75 @Stable getHealthReport()76 public abstract String getHealthReport(); 77 78 @Private 79 @Unstable setHealthReport(String healthReport)80 public abstract void setHealthReport(String healthReport); 81 82 /** 83 * Get the <em>last timestamp</em> at which the health report was received. 84 * @return <em>last timestamp</em> at which the health report was received 85 */ 86 @Public 87 @Stable getLastHealthReportTime()88 public abstract long getLastHealthReportTime(); 89 90 @Private 91 @Unstable setLastHealthReportTime(long lastHealthReport)92 public abstract void setLastHealthReportTime(long lastHealthReport); 93 }