View Javadoc

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.hbase;
19  
20  import org.apache.hadoop.hbase.HealthChecker.HealthCheckerExitStatus;
21  
22  /**
23   * The Class HealthReport containing information about health of the node.
24   */
25  class HealthReport {
26  
27    private HealthCheckerExitStatus status;
28    private String healthReport;
29  
30    HealthReport(HealthCheckerExitStatus status, String healthReport) {
31      super();
32      this.status = status;
33      this.healthReport = healthReport;
34    }
35  
36    /**
37     * Gets the status of the region server.
38     *
39     * @return HealthCheckerExitStatus
40     */
41    HealthCheckerExitStatus getStatus() {
42      return status;
43    }
44  
45    @Override
46    public String toString() {
47      return this.status + " " + this.healthReport;
48    }
49  
50    /**
51     * Gets the health report of the region server.
52     *
53     * @return String
54     */
55    String getHealthReport() {
56      return healthReport;
57    }
58  
59    @Override
60    public int hashCode() {
61      final int prime = 31;
62      int result = 1;
63      result = prime * result + ((healthReport == null) ? 0 : healthReport.hashCode());
64      result = prime * result + ((status == null) ? 0 : status.hashCode());
65      return result;
66    }
67  
68    @Override
69    public boolean equals(Object obj) {
70      if (this == obj) {
71        return true;
72      }
73      if (obj == null) {
74        return false;
75      }
76      if (!(obj instanceof HealthReport)) {
77        return false;
78      }
79      HealthReport other = (HealthReport) obj;
80      if (healthReport == null) {
81        if (other.healthReport != null) {
82          return false;
83        }
84      } else if (!healthReport.equals(other.healthReport)) {
85        return false;
86      }
87      if (status != other.status) {
88        return false;
89      }
90      return true;
91    }
92  }