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  HealthCheckerExitStatus getStatus() {
040    return status;
041  }
042
043  @Override
044  public String toString() {
045    return this.status + " " + this.healthReport;
046  }
047
048  /**
049   * Gets the health report of the region server.
050   */
051  String getHealthReport() {
052    return healthReport;
053  }
054
055  @Override
056  public int hashCode() {
057    final int prime = 31;
058    int result = 1;
059    result = prime * result + ((healthReport == null) ? 0 : healthReport.hashCode());
060    result = prime * result + ((status == null) ? 0 : status.hashCode());
061    return result;
062  }
063
064  @Override
065  public boolean equals(Object obj) {
066    if (this == obj) {
067      return true;
068    }
069    if (obj == null) {
070      return false;
071    }
072    if (!(obj instanceof HealthReport)) {
073      return false;
074    }
075    HealthReport other = (HealthReport) obj;
076    if (healthReport == null) {
077      if (other.healthReport != null) {
078        return false;
079      }
080    } else if (!healthReport.equals(other.healthReport)) {
081      return false;
082    }
083    if (status != other.status) {
084      return false;
085    }
086    return true;
087  }
088}