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 org.apache.commons.lang3.builder.EqualsBuilder; 021import org.apache.commons.lang3.builder.HashCodeBuilder; 022import org.apache.commons.lang3.builder.ToStringBuilder; 023import org.apache.commons.lang3.builder.ToStringStyle; 024import org.apache.hadoop.hbase.client.RegionInfo; 025import org.apache.yetus.audience.InterfaceAudience; 026 027/** 028 * Normalization plan to split a region. 029 */ 030@InterfaceAudience.Private 031final class SplitNormalizationPlan implements NormalizationPlan { 032 033 private final NormalizationTarget splitTarget; 034 035 SplitNormalizationPlan(final RegionInfo splitTarget, final long splitTargetSizeMb) { 036 this.splitTarget = new NormalizationTarget(splitTarget, splitTargetSizeMb); 037 } 038 039 @Override 040 public PlanType getType() { 041 return PlanType.SPLIT; 042 } 043 044 public NormalizationTarget getSplitTarget() { 045 return splitTarget; 046 } 047 048 @Override 049 public long getPlanSizeMb() { 050 return splitTarget.getRegionSizeMb(); 051 } 052 053 @Override 054 public String toString() { 055 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) 056 .append("splitTarget", splitTarget).toString(); 057 } 058 059 @Override 060 public boolean equals(Object o) { 061 if (this == o) { 062 return true; 063 } 064 065 if (o == null || getClass() != o.getClass()) { 066 return false; 067 } 068 069 SplitNormalizationPlan that = (SplitNormalizationPlan) o; 070 071 return new EqualsBuilder().append(splitTarget, that.splitTarget).isEquals(); 072 } 073 074 @Override 075 public int hashCode() { 076 return new HashCodeBuilder(17, 37).append(splitTarget).toHashCode(); 077 } 078}