You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2018/04/09 07:19:39 UTC
[19/22] hbase git commit: HBASE-20116 addendum fix javadoc and also a
simple optimization
HBASE-20116 addendum fix javadoc and also a simple optimization
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/40ad5aea
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/40ad5aea
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/40ad5aea
Branch: refs/heads/HBASE-20046-branch-2
Commit: 40ad5aeafe5019abf59c3d149df42d5f4afcc1a2
Parents: aec43bb
Author: zhangduo <zh...@apache.org>
Authored: Thu Mar 22 08:31:20 2018 +0800
Committer: zhangduo <zh...@apache.org>
Committed: Mon Apr 9 15:18:44 2018 +0800
----------------------------------------------------------------------
.../replication/ZKReplicationQueueStorage.java | 22 ++++++++++++--------
.../TestZKReplicationQueueStorage.java | 2 +-
2 files changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/40ad5aea/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ZKReplicationQueueStorage.java
----------------------------------------------------------------------
diff --git a/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ZKReplicationQueueStorage.java b/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ZKReplicationQueueStorage.java
index 6c9752a..1a5749e 100644
--- a/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ZKReplicationQueueStorage.java
+++ b/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ZKReplicationQueueStorage.java
@@ -133,26 +133,30 @@ class ZKReplicationQueueStorage extends ZKReplicationStorageBase
}
/**
+ * <p>
* Put all regions under /hbase/replication/regions znode will lead to too many children because
- * of the huge number of regions in real production environment. So here we use hash of encoded
- * region name to distribute the znode into multiple znodes. <br>
+ * of the huge number of regions in real production environment. So here we will distribute the
+ * znodes to multiple directories.
+ * </p>
+ * <p>
* So the final znode path will be format like this:
*
* <pre>
- * /hbase/replication/regions/e1/ff/dd04e76a6966d4ffa908ed0586764767-100
+ * /hbase/replication/regions/dd/04/e76a6966d4ffa908ed0586764767-100
* </pre>
*
- * The e1 indicate the first level hash of encoded region name, and the ff indicate the second
- * level hash of encoded region name, the 100 indicate the peer id. <br>
- * Note that here we use two-level hash because if only one-level hash (such as mod 65535), it
- * will still lead to too many children under the /hbase/replication/regions znode.
+ * Here the full encoded region name is dd04e76a6966d4ffa908ed0586764767, and we use the first two
+ * characters 'dd' as the first level directory name, and use the next two characters '04' as the
+ * second level directory name, and the rest part as the prefix of the znode, and the suffix '100'
+ * is the peer id.
+ * </p>
* @param encodedRegionName the encoded region name.
* @param peerId peer id for replication.
* @return ZNode path to persist the max sequence id that we've pushed for the given region and
* peer.
*/
@VisibleForTesting
- public String getSerialReplicationRegionPeerNode(String encodedRegionName, String peerId) {
+ String getSerialReplicationRegionPeerNode(String encodedRegionName, String peerId) {
if (encodedRegionName == null || encodedRegionName.length() != RegionInfo.MD5_HEX_LENGTH) {
throw new IllegalArgumentException(
"Invalid encoded region name: " + encodedRegionName + ", length should be 32.");
@@ -160,7 +164,7 @@ class ZKReplicationQueueStorage extends ZKReplicationStorageBase
return new StringBuilder(regionsZNode).append(ZNodePaths.ZNODE_PATH_SEPARATOR)
.append(encodedRegionName.substring(0, 2)).append(ZNodePaths.ZNODE_PATH_SEPARATOR)
.append(encodedRegionName.substring(2, 4)).append(ZNodePaths.ZNODE_PATH_SEPARATOR)
- .append(encodedRegionName).append("-").append(peerId).toString();
+ .append(encodedRegionName.substring(4)).append("-").append(peerId).toString();
}
@Override
http://git-wip-us.apache.org/repos/asf/hbase/blob/40ad5aea/hbase-replication/src/test/java/org/apache/hadoop/hbase/replication/TestZKReplicationQueueStorage.java
----------------------------------------------------------------------
diff --git a/hbase-replication/src/test/java/org/apache/hadoop/hbase/replication/TestZKReplicationQueueStorage.java b/hbase-replication/src/test/java/org/apache/hadoop/hbase/replication/TestZKReplicationQueueStorage.java
index 28cdff1..ca86a05 100644
--- a/hbase-replication/src/test/java/org/apache/hadoop/hbase/replication/TestZKReplicationQueueStorage.java
+++ b/hbase-replication/src/test/java/org/apache/hadoop/hbase/replication/TestZKReplicationQueueStorage.java
@@ -257,7 +257,7 @@ public class TestZKReplicationQueueStorage {
public void testRegionsZNodeLayout() throws Exception {
String peerId = "1";
String encodedRegionName = "31d9792f4435b99d9fb1016f6fbc8dc7";
- String expectedPath = "/hbase/replication/regions/31/d9/" + encodedRegionName + "-" + peerId;
+ String expectedPath = "/hbase/replication/regions/31/d9/792f4435b99d9fb1016f6fbc8dc7-" + peerId;
String path = STORAGE.getSerialReplicationRegionPeerNode(encodedRegionName, peerId);
Assert.assertEquals(expectedPath, path);
}