001/* 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019 020package org.apache.hadoop.hbase.client; 021 022import org.apache.yetus.audience.InterfaceAudience; 023 024@InterfaceAudience.Private 025public final class RegionStatesCount { 026 027 private int openRegions; 028 private int splitRegions; 029 private int closedRegions; 030 private int regionsInTransition; 031 private int totalRegions; 032 033 private RegionStatesCount() { 034 } 035 036 public int getClosedRegions() { 037 return closedRegions; 038 } 039 040 public int getOpenRegions() { 041 return openRegions; 042 } 043 044 public int getSplitRegions() { 045 return splitRegions; 046 } 047 048 public int getRegionsInTransition() { 049 return regionsInTransition; 050 } 051 052 public int getTotalRegions() { 053 return totalRegions; 054 } 055 056 private void setClosedRegions(int closedRegions) { 057 this.closedRegions = closedRegions; 058 } 059 060 private void setOpenRegions(int openRegions) { 061 this.openRegions = openRegions; 062 } 063 064 private void setSplitRegions(int splitRegions) { 065 this.splitRegions = splitRegions; 066 } 067 068 private void setRegionsInTransition(int regionsInTransition) { 069 this.regionsInTransition = regionsInTransition; 070 } 071 072 private void setTotalRegions(int totalRegions) { 073 this.totalRegions = totalRegions; 074 } 075 076 public static class RegionStatesCountBuilder { 077 private int openRegions; 078 private int splitRegions; 079 private int closedRegions; 080 private int regionsInTransition; 081 private int totalRegions; 082 083 public RegionStatesCountBuilder setOpenRegions(int openRegions) { 084 this.openRegions = openRegions; 085 return this; 086 } 087 088 public RegionStatesCountBuilder setSplitRegions(int splitRegions) { 089 this.splitRegions = splitRegions; 090 return this; 091 } 092 093 public RegionStatesCountBuilder setClosedRegions(int closedRegions) { 094 this.closedRegions = closedRegions; 095 return this; 096 } 097 098 public RegionStatesCountBuilder setRegionsInTransition(int regionsInTransition) { 099 this.regionsInTransition = regionsInTransition; 100 return this; 101 } 102 103 public RegionStatesCountBuilder setTotalRegions(int totalRegions) { 104 this.totalRegions = totalRegions; 105 return this; 106 } 107 108 public RegionStatesCount build() { 109 RegionStatesCount regionStatesCount=new RegionStatesCount(); 110 regionStatesCount.setOpenRegions(openRegions); 111 regionStatesCount.setClosedRegions(closedRegions); 112 regionStatesCount.setRegionsInTransition(regionsInTransition); 113 regionStatesCount.setSplitRegions(splitRegions); 114 regionStatesCount.setTotalRegions(totalRegions); 115 return regionStatesCount; 116 } 117 } 118 119 @Override 120 public String toString() { 121 final StringBuilder sb = new StringBuilder("RegionStatesCount{"); 122 sb.append("openRegions=").append(openRegions); 123 sb.append(", splitRegions=").append(splitRegions); 124 sb.append(", closedRegions=").append(closedRegions); 125 sb.append(", regionsInTransition=").append(regionsInTransition); 126 sb.append(", totalRegions=").append(totalRegions); 127 sb.append('}'); 128 return sb.toString(); 129 } 130 131 @Override 132 public boolean equals(Object o) { 133 if (this == o) { 134 return true; 135 } 136 if (o == null || getClass() != o.getClass()) { 137 return false; 138 } 139 140 RegionStatesCount that = (RegionStatesCount) o; 141 142 if (openRegions != that.openRegions) { 143 return false; 144 } 145 if (splitRegions != that.splitRegions) { 146 return false; 147 } 148 if (closedRegions != that.closedRegions) { 149 return false; 150 } 151 if (regionsInTransition != that.regionsInTransition) { 152 return false; 153 } 154 return totalRegions == that.totalRegions; 155 } 156 157 @Override 158 public int hashCode() { 159 int result = openRegions; 160 result = 31 * result + splitRegions; 161 result = 31 * result + closedRegions; 162 result = 31 * result + regionsInTransition; 163 result = 31 * result + totalRegions; 164 return result; 165 } 166 167}