From commits-return-71096-archive-asf-public=cust-asf.ponee.io@hbase.apache.org Wed Apr 11 16:48:29 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 7DE9D18067B for ; Wed, 11 Apr 2018 16:48:26 +0200 (CEST) Received: (qmail 33448 invoked by uid 500); 11 Apr 2018 14:48:25 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 33188 invoked by uid 99); 11 Apr 2018 14:48:25 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Apr 2018 14:48:25 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 94AE6DFA00; Wed, 11 Apr 2018 14:48:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: git-site-role@apache.org To: commits@hbase.apache.org Date: Wed, 11 Apr 2018 14:48:28 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [05/16] hbase-site git commit: Published site at 37e5b0b1b790fef25a544c282c6556e009269a0e. http://git-wip-us.apache.org/repos/asf/hbase-site/blob/c8fd155e/devapidocs/src-html/org/apache/hadoop/hbase/client/RegionInfoBuilder.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/client/RegionInfoBuilder.html b/devapidocs/src-html/org/apache/hadoop/hbase/client/RegionInfoBuilder.html index 826ae09..a16d6c3 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/client/RegionInfoBuilder.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/client/RegionInfoBuilder.html @@ -157,329 +157,331 @@ 149 * old region name format. 150 */ 151 -152 // This flag is in the parent of a split while the parent is still referenced -153 // by daughter regions. We USED to set this flag when we disabled a table -154 // but now table state is kept up in zookeeper as of 0.90.0 HBase. -155 private boolean offLine = false; -156 private boolean split = false; -157 private final long regionId; -158 private final int replicaId; -159 private final byte[] regionName; -160 private final byte[] startKey; -161 private final byte[] endKey; -162 private final int hashCode; -163 private final String encodedName; -164 private final byte[] encodedNameAsBytes; -165 private final TableName tableName; -166 -167 private static int generateHashCode(final TableName tableName, final byte[] startKey, -168 final byte[] endKey, final long regionId, -169 final int replicaId, boolean offLine, byte[] regionName) { -170 int result = Arrays.hashCode(regionName); -171 result = (int) (result ^ regionId); -172 result ^= Arrays.hashCode(checkStartKey(startKey)); -173 result ^= Arrays.hashCode(checkEndKey(endKey)); -174 result ^= Boolean.valueOf(offLine).hashCode(); -175 result ^= Arrays.hashCode(tableName.getName()); -176 result ^= replicaId; -177 return result; -178 } -179 -180 private static byte[] checkStartKey(byte[] startKey) { -181 return startKey == null? HConstants.EMPTY_START_ROW: startKey; -182 } -183 -184 private static byte[] checkEndKey(byte[] endKey) { -185 return endKey == null? HConstants.EMPTY_END_ROW: endKey; -186 } -187 -188 private static TableName checkTableName(TableName tableName) { -189 if (tableName == null) { -190 throw new IllegalArgumentException("TableName cannot be null"); -191 } -192 return tableName; -193 } -194 -195 private static int checkReplicaId(int regionId) { -196 if (regionId > MAX_REPLICA_ID) { -197 throw new IllegalArgumentException("ReplicaId cannot be greater than" + MAX_REPLICA_ID); -198 } -199 return regionId; -200 } -201 -202 /** -203 * Private constructor used constructing MutableRegionInfo for the -204 * first meta regions -205 */ -206 private MutableRegionInfo(long regionId, TableName tableName, int replicaId) { -207 this(tableName, -208 HConstants.EMPTY_START_ROW, -209 HConstants.EMPTY_END_ROW, -210 false, -211 regionId, -212 replicaId, -213 false, -214 RegionInfo.createRegionName(tableName, null, regionId, replicaId, false)); -215 } -216 -217 MutableRegionInfo(final TableName tableName, final byte[] startKey, -218 final byte[] endKey, final boolean split, final long regionId, -219 final int replicaId, boolean offLine, byte[] regionName) { -220 this(checkTableName(tableName), -221 checkStartKey(startKey), -222 checkEndKey(endKey), -223 split, regionId, -224 checkReplicaId(replicaId), -225 offLine, -226 regionName, -227 RegionInfo.encodeRegionName(regionName)); -228 } -229 -230 MutableRegionInfo(final TableName tableName, final byte[] startKey, -231 final byte[] endKey, final boolean split, final long regionId, -232 final int replicaId, boolean offLine, byte[] regionName, String encodedName) { -233 this.tableName = checkTableName(tableName); -234 this.startKey = checkStartKey(startKey); -235 this.endKey = checkEndKey(endKey); -236 this.split = split; -237 this.regionId = regionId; -238 this.replicaId = checkReplicaId(replicaId); -239 this.offLine = offLine; -240 if (ArrayUtils.isEmpty(regionName)) { -241 this.regionName = RegionInfo.createRegionName(this.tableName, this.startKey, this.regionId, this.replicaId, -242 !this.tableName.equals(TableName.META_TABLE_NAME)); -243 this.encodedName = RegionInfo.encodeRegionName(this.regionName); -244 } else { -245 this.regionName = regionName; -246 this.encodedName = encodedName; -247 } -248 this.hashCode = generateHashCode( -249 this.tableName, -250 this.startKey, -251 this.endKey, -252 this.regionId, -253 this.replicaId, -254 this.offLine, -255 this.regionName); -256 this.encodedNameAsBytes = Bytes.toBytes(this.encodedName); -257 } -258 /** -259 * @return Return a short, printable name for this region -260 * (usually encoded name) for us logging. -261 */ -262 @Override -263 public String getShortNameToLog() { -264 return RegionInfo.prettyPrint(this.getEncodedName()); -265 } -266 -267 /** @return the regionId */ -268 @Override -269 public long getRegionId(){ -270 return regionId; -271 } -272 -273 -274 /** -275 * @return the regionName as an array of bytes. -276 * @see #getRegionNameAsString() -277 */ -278 @Override -279 public byte [] getRegionName(){ -280 return regionName; -281 } -282 -283 /** -284 * @return Region name as a String for use in logging, etc. -285 */ -286 @Override -287 public String getRegionNameAsString() { -288 if (RegionInfo.hasEncodedName(this.regionName)) { -289 // new format region names already have their encoded name. -290 return Bytes.toStringBinary(this.regionName); -291 } -292 -293 // old format. regionNameStr doesn't have the region name. -294 // -295 // -296 return Bytes.toStringBinary(this.regionName) + "." + this.getEncodedName(); -297 } -298 -299 /** @return the encoded region name */ -300 @Override -301 public String getEncodedName() { -302 return this.encodedName; -303 } -304 -305 @Override -306 public byte [] getEncodedNameAsBytes() { -307 return this.encodedNameAsBytes; -308 } -309 -310 /** @return the startKey */ -311 @Override -312 public byte [] getStartKey(){ -313 return startKey; -314 } -315 -316 -317 /** @return the endKey */ -318 @Override -319 public byte [] getEndKey(){ -320 return endKey; -321 } -322 -323 /** -324 * Get current table name of the region -325 * @return TableName -326 */ -327 @Override -328 public TableName getTable() { -329 return this.tableName; -330 } -331 -332 /** -333 * Returns true if the given inclusive range of rows is fully contained -334 * by this region. For example, if the region is foo,a,g and this is -335 * passed ["b","c"] or ["a","c"] it will return true, but if this is passed -336 * ["b","z"] it will return false. -337 * @throws IllegalArgumentException if the range passed is invalid (ie. end &lt; start) -338 */ -339 @Override -340 public boolean containsRange(byte[] rangeStartKey, byte[] rangeEndKey) { -341 if (Bytes.compareTo(rangeStartKey, rangeEndKey) > 0) { -342 throw new IllegalArgumentException( -343 "Invalid range: " + Bytes.toStringBinary(rangeStartKey) + -344 " > " + Bytes.toStringBinary(rangeEndKey)); -345 } -346 -347 boolean firstKeyInRange = Bytes.compareTo(rangeStartKey, startKey) >= 0; -348 boolean lastKeyInRange = -349 Bytes.compareTo(rangeEndKey, endKey) < 0 || -350 Bytes.equals(endKey, HConstants.EMPTY_BYTE_ARRAY); -351 return firstKeyInRange && lastKeyInRange; -352 } -353 -354 /** -355 * Return true if the given row falls in this region. -356 */ -357 @Override -358 public boolean containsRow(byte[] row) { -359 return Bytes.compareTo(row, startKey) >= 0 && -360 (Bytes.compareTo(row, endKey) < 0 || -361 Bytes.equals(endKey, HConstants.EMPTY_BYTE_ARRAY)); -362 } -363 -364 /** @return true if this region is a meta region */ -365 @Override -366 public boolean isMetaRegion() { -367 return tableName.equals(FIRST_META_REGIONINFO.getTable()); -368 } -369 -370 /** -371 * @return True if has been split and has daughters. -372 */ -373 @Override -374 public boolean isSplit() { -375 return this.split; -376 } -377 -378 /** -379 * @param split set split status -380 * @return MutableRegionInfo -381 */ -382 public MutableRegionInfo setSplit(boolean split) { -383 this.split = split; -384 return this; -385 } -386 -387 /** -388 * @return True if this region is offline. -389 */ -390 @Override -391 public boolean isOffline() { -392 return this.offLine; -393 } -394 -395 /** -396 * The parent of a region split is offline while split daughters hold -397 * references to the parent. Offlined regions are closed. -398 * @param offLine Set online/offline status. -399 * @return MutableRegionInfo -400 */ -401 public MutableRegionInfo setOffline(boolean offLine) { -402 this.offLine = offLine; -403 return this; -404 } -405 -406 /** -407 * @return True if this is a split parent region. -408 */ -409 @Override -410 public boolean isSplitParent() { -411 if (!isSplit()) return false; -412 if (!isOffline()) { -413 LOG.warn("Region is split but NOT offline: " + getRegionNameAsString()); -414 } -415 return true; -416 } -417 -418 /** -419 * Returns the region replica id -420 * @return returns region replica id -421 */ -422 @Override -423 public int getReplicaId() { -424 return replicaId; -425 } -426 -427 /** -428 * @see java.lang.Object#toString() -429 */ -430 @Override -431 public String toString() { -432 return "{ENCODED => " + getEncodedName() + ", " + -433 HConstants.NAME + " => '" + Bytes.toStringBinary(this.regionName) -434 + "', STARTKEY => '" + -435 Bytes.toStringBinary(this.startKey) + "', ENDKEY => '" + -436 Bytes.toStringBinary(this.endKey) + "'" + -437 (isOffline()? ", OFFLINE => true": "") + -438 (isSplit()? ", SPLIT => true": "") + -439 ((replicaId > 0)? ", REPLICA_ID => " + replicaId : "") + "}"; -440 } -441 -442 /** -443 * @param o -444 * @see java.lang.Object#equals(java.lang.Object) -445 */ -446 @Override -447 public boolean equals(Object o) { -448 if (this == o) { -449 return true; -450 } -451 if (o == null) { -452 return false; -453 } -454 if (!(o instanceof RegionInfo)) { -455 return false; -456 } -457 return this.compareTo((RegionInfo)o) == 0; -458 } -459 -460 /** -461 * @see java.lang.Object#hashCode() -462 */ -463 @Override -464 public int hashCode() { -465 return this.hashCode; -466 } -467 -468 @Override -469 public int compareTo(RegionInfo other) { -470 return RegionInfo.COMPARATOR.compare(this, other); -471 } -472 -473 } -474} +152 // This flag is in the parent of a split while the parent is still referenced by daughter +153 // regions. We USED to set this flag when we disabled a table but now table state is kept up in +154 // zookeeper as of 0.90.0 HBase. And now in DisableTableProcedure, finally we will create bunch +155 // of UnassignProcedures and at the last of the procedure we will set the region state to +156 // CLOSED, and will not change the offLine flag. +157 private boolean offLine = false; +158 private boolean split = false; +159 private final long regionId; +160 private final int replicaId; +161 private final byte[] regionName; +162 private final byte[] startKey; +163 private final byte[] endKey; +164 private final int hashCode; +165 private final String encodedName; +166 private final byte[] encodedNameAsBytes; +167 private final TableName tableName; +168 +169 private static int generateHashCode(final TableName tableName, final byte[] startKey, +170 final byte[] endKey, final long regionId, +171 final int replicaId, boolean offLine, byte[] regionName) { +172 int result = Arrays.hashCode(regionName); +173 result = (int) (result ^ regionId); +174 result ^= Arrays.hashCode(checkStartKey(startKey)); +175 result ^= Arrays.hashCode(checkEndKey(endKey)); +176 result ^= Boolean.valueOf(offLine).hashCode(); +177 result ^= Arrays.hashCode(tableName.getName()); +178 result ^= replicaId; +179 return result; +180 } +181 +182 private static byte[] checkStartKey(byte[] startKey) { +183 return startKey == null? HConstants.EMPTY_START_ROW: startKey; +184 } +185 +186 private static byte[] checkEndKey(byte[] endKey) { +187 return endKey == null? HConstants.EMPTY_END_ROW: endKey; +188 } +189 +190 private static TableName checkTableName(TableName tableName) { +191 if (tableName == null) { +192 throw new IllegalArgumentException("TableName cannot be null"); +193 } +194 return tableName; +195 } +196 +197 private static int checkReplicaId(int regionId) { +198 if (regionId > MAX_REPLICA_ID) { +199 throw new IllegalArgumentException("ReplicaId cannot be greater than" + MAX_REPLICA_ID); +200 } +201 return regionId; +202 } +203 +204 /** +205 * Private constructor used constructing MutableRegionInfo for the +206 * first meta regions +207 */ +208 private MutableRegionInfo(long regionId, TableName tableName, int replicaId) { +209 this(tableName, +210 HConstants.EMPTY_START_ROW, +211 HConstants.EMPTY_END_ROW, +212 false, +213 regionId, +214 replicaId, +215 false, +216 RegionInfo.createRegionName(tableName, null, regionId, replicaId, false)); +217 } +218 +219 MutableRegionInfo(final TableName tableName, final byte[] startKey, +220 final byte[] endKey, final boolean split, final long regionId, +221 final int replicaId, boolean offLine, byte[] regionName) { +222 this(checkTableName(tableName), +223 checkStartKey(startKey), +224 checkEndKey(endKey), +225 split, regionId, +226 checkReplicaId(replicaId), +227 offLine, +228 regionName, +229 RegionInfo.encodeRegionName(regionName)); +230 } +231 +232 MutableRegionInfo(final TableName tableName, final byte[] startKey, +233 final byte[] endKey, final boolean split, final long regionId, +234 final int replicaId, boolean offLine, byte[] regionName, String encodedName) { +235 this.tableName = checkTableName(tableName); +236 this.startKey = checkStartKey(startKey); +237 this.endKey = checkEndKey(endKey); +238 this.split = split; +239 this.regionId = regionId; +240 this.replicaId = checkReplicaId(replicaId); +241 this.offLine = offLine; +242 if (ArrayUtils.isEmpty(regionName)) { +243 this.regionName = RegionInfo.createRegionName(this.tableName, this.startKey, this.regionId, this.replicaId, +244 !this.tableName.equals(TableName.META_TABLE_NAME)); +245 this.encodedName = RegionInfo.encodeRegionName(this.regionName); +246 } else { +247 this.regionName = regionName; +248 this.encodedName = encodedName; +249 } +250 this.hashCode = generateHashCode( +251 this.tableName, +252 this.startKey, +253 this.endKey, +254 this.regionId, +255 this.replicaId, +256 this.offLine, +257 this.regionName); +258 this.encodedNameAsBytes = Bytes.toBytes(this.encodedName); +259 } +260 /** +261 * @return Return a short, printable name for this region +262 * (usually encoded name) for us logging. +263 */ +264 @Override +265 public String getShortNameToLog() { +266 return RegionInfo.prettyPrint(this.getEncodedName()); +267 } +268 +269 /** @return the regionId */ +270 @Override +271 public long getRegionId(){ +272 return regionId; +273 } +274 +275 +276 /** +277 * @return the regionName as an array of bytes. +278 * @see #getRegionNameAsString() +279 */ +280 @Override +281 public byte [] getRegionName(){ +282 return regionName; +283 } +284 +285 /** +286 * @return Region name as a String for use in logging, etc. +287 */ +288 @Override +289 public String getRegionNameAsString() { +290 if (RegionInfo.hasEncodedName(this.regionName)) { +291 // new format region names already have their encoded name. +292 return Bytes.toStringBinary(this.regionName); +293 } +294 +295 // old format. regionNameStr doesn't have the region name. +296 // +297 // +298 return Bytes.toStringBinary(this.regionName) + "." + this.getEncodedName(); +299 } +300 +301 /** @return the encoded region name */ +302 @Override +303 public String getEncodedName() { +304 return this.encodedName; +305 } +306 +307 @Override +308 public byte [] getEncodedNameAsBytes() { +309 return this.encodedNameAsBytes; +310 } +311 +312 /** @return the startKey */ +313 @Override +314 public byte [] getStartKey(){ +315 return startKey; +316 } +317 +318 +319 /** @return the endKey */ +320 @Override +321 public byte [] getEndKey(){ +322 return endKey; +323 } +324 +325 /** +326 * Get current table name of the region +327 * @return TableName +328 */ +329 @Override +330 public TableName getTable() { +331 return this.tableName; +332 } +333 +334 /** +335 * Returns true if the given inclusive range of rows is fully contained +336 * by this region. For example, if the region is foo,a,g and this is +337 * passed ["b","c"] or ["a","c"] it will return true, but if this is passed +338 * ["b","z"] it will return false. +339 * @throws IllegalArgumentException if the range passed is invalid (ie. end &lt; start) +340 */ +341 @Override +342 public boolean containsRange(byte[] rangeStartKey, byte[] rangeEndKey) { +343 if (Bytes.compareTo(rangeStartKey, rangeEndKey) > 0) { +344 throw new IllegalArgumentException( +345 "Invalid range: " + Bytes.toStringBinary(rangeStartKey) + +346 " > " + Bytes.toStringBinary(rangeEndKey)); +347 } +348 +349 boolean firstKeyInRange = Bytes.compareTo(rangeStartKey, startKey) >= 0; +350 boolean lastKeyInRange = +351 Bytes.compareTo(rangeEndKey, endKey) < 0 || +352 Bytes.equals(endKey, HConstants.EMPTY_BYTE_ARRAY); +353 return firstKeyInRange && lastKeyInRange; +354 } +355 +356 /** +357 * Return true if the given row falls in this region. +358 */ +359 @Override +360 public boolean containsRow(byte[] row) { +361 return Bytes.compareTo(row, startKey) >= 0 && +362 (Bytes.compareTo(row, endKey) < 0 || +363 Bytes.equals(endKey, HConstants.EMPTY_BYTE_ARRAY)); +364 } +365 +366 /** @return true if this region is a meta region */ +367 @Override +368 public boolean isMetaRegion() { +369 return tableName.equals(FIRST_META_REGIONINFO.getTable()); +370 } +371 +372 /** +373 * @return True if has been split and has daughters. +374 */ +375 @Override +376 public boolean isSplit() { +377 return this.split; +378 } +379 +380 /** +381 * @param split set split status +382 * @return MutableRegionInfo +383 */ +384 public MutableRegionInfo setSplit(boolean split) { +385 this.split = split; +386 return this; +387 } +388 +389 /** +390 * @return True if this region is offline. +391 */ +392 @Override +393 public boolean isOffline() { +394 return this.offLine; +395 } +396 +397 /** +398 * The parent of a region split is offline while split daughters hold +399 * references to the parent. Offlined regions are closed. +400 * @param offLine Set online/offline status. +401 * @return MutableRegionInfo +402 */ +403 public MutableRegionInfo setOffline(boolean offLine) { +404 this.offLine = offLine; +405 return this; +406 } +407 +408 /** +409 * @return True if this is a split parent region. +410 */ +411 @Override +412 public boolean isSplitParent() { +413 if (!isSplit()) return false; +414 if (!isOffline()) { +415 LOG.warn("Region is split but NOT offline: " + getRegionNameAsString()); +416 } +417 return true; +418 } +419 +420 /** +421 * Returns the region replica id +422 * @return returns region replica id +423 */ +424 @Override +425 public int getReplicaId() { +426 return replicaId; +427 } +428 +429 /** +430 * @see java.lang.Object#toString() +431 */ +432 @Override +433 public String toString() { +434 return "{ENCODED => " + getEncodedName() + ", " + +435 HConstants.NAME + " => '" + Bytes.toStringBinary(this.regionName) +436 + "', STARTKEY => '" + +437 Bytes.toStringBinary(this.startKey) + "', ENDKEY => '" + +438 Bytes.toStringBinary(this.endKey) + "'" + +439 (isOffline()? ", OFFLINE => true": "") + +440 (isSplit()? ", SPLIT => true": "") + +441 ((replicaId > 0)? ", REPLICA_ID => " + replicaId : "") + "}"; +442 } +443 +444 /** +445 * @param o +446 * @see java.lang.Object#equals(java.lang.Object) +447 */ +448 @Override +449 public boolean equals(Object o) { +450 if (this == o) { +451 return true; +452 } +453 if (o == null) { +454 return false; +455 } +456 if (!(o instanceof RegionInfo)) { +457 return false; +458 } +459 return this.compareTo((RegionInfo)o) == 0; +460 } +461 +462 /** +463 * @see java.lang.Object#hashCode() +464 */ +465 @Override +466 public int hashCode() { +467 return this.hashCode; +468 } +469 +470 @Override +471 public int compareTo(RegionInfo other) { +472 return RegionInfo.COMPARATOR.compare(this, other); +473 } +474 +475 } +476}