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.master.normalizer;
019
020import java.util.Objects;
021import org.apache.commons.lang3.builder.EqualsBuilder;
022import org.apache.commons.lang3.builder.HashCodeBuilder;
023import org.apache.commons.lang3.builder.ToStringBuilder;
024import org.apache.commons.lang3.builder.ToStringStyle;
025import org.apache.hadoop.hbase.client.RegionInfo;
026import org.apache.yetus.audience.InterfaceAudience;
027
028/**
029 * A POJO that caries details about a region selected for normalization through the pipeline.
030 */
031@InterfaceAudience.Private
032class NormalizationTarget {
033  private final RegionInfo regionInfo;
034  private final long regionSizeMb;
035
036  NormalizationTarget(final RegionInfo regionInfo, final long regionSizeMb) {
037    this.regionInfo = Objects.requireNonNull(regionInfo);
038    this.regionSizeMb = regionSizeMb;
039  }
040
041  public RegionInfo getRegionInfo() {
042    return regionInfo;
043  }
044
045  public long getRegionSizeMb() {
046    return regionSizeMb;
047  }
048
049  @Override
050  public boolean equals(Object o) {
051    if (this == o) {
052      return true;
053    }
054
055    if (o == null || getClass() != o.getClass()) {
056      return false;
057    }
058
059    NormalizationTarget that = (NormalizationTarget) o;
060
061    return new EqualsBuilder().append(regionSizeMb, that.regionSizeMb)
062      .append(regionInfo, that.regionInfo).isEquals();
063  }
064
065  @Override
066  public int hashCode() {
067    return new HashCodeBuilder(17, 37).append(regionInfo).append(regionSizeMb).toHashCode();
068  }
069
070  @Override
071  public String toString() {
072    return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
073      .append("regionInfo", regionInfo).append("regionSizeMb", regionSizeMb).toString();
074  }
075}