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 */
018package org.apache.hadoop.hbase;
019
020import org.apache.hadoop.hbase.HealthChecker.HealthCheckerExitStatus;
021
022/**
023 * The Class HealthReport containing information about health of the node.
024 */
025class HealthReport {
026
027  private HealthCheckerExitStatus status;
028  private String healthReport;
029
030  HealthReport(HealthCheckerExitStatus status, String healthReport) {
031    super();
032    this.status = status;
033    this.healthReport = healthReport;
034  }
035
036  /**
037   * Gets the status of the region server.
038   *
039   * @return HealthCheckerExitStatus
040   */
041  HealthCheckerExitStatus getStatus() {
042    return status;
043  }
044
045  @Override
046  public String toString() {
047    return this.status + " " + this.healthReport;
048  }
049
050  /**
051   * Gets the health report of the region server.
052   *
053   * @return String
054   */
055  String getHealthReport() {
056    return healthReport;
057  }
058
059  @Override
060  public int hashCode() {
061    final int prime = 31;
062    int result = 1;
063    result = prime * result + ((healthReport == null) ? 0 : healthReport.hashCode());
064    result = prime * result + ((status == null) ? 0 : status.hashCode());
065    return result;
066  }
067
068  @Override
069  public boolean equals(Object obj) {
070    if (this == obj) {
071      return true;
072    }
073    if (obj == null) {
074      return false;
075    }
076    if (!(obj instanceof HealthReport)) {
077      return false;
078    }
079    HealthReport other = (HealthReport) obj;
080    if (healthReport == null) {
081      if (other.healthReport != null) {
082        return false;
083      }
084    } else if (!healthReport.equals(other.healthReport)) {
085      return false;
086    }
087    if (status != other.status) {
088      return false;
089    }
090    return true;
091  }
092}