hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zg...@apache.org
Subject hbase git commit: HBASE-17289 Avoid adding a replication peer named lock
Date Thu, 19 Jan 2017 03:29:25 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.2 4f008bb01 -> 4778995c4


HBASE-17289 Avoid adding a replication peer named lock


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/4778995c
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/4778995c
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/4778995c

Branch: refs/heads/branch-1.2
Commit: 4778995c4eefa759b01fded7bf62aaa8953db5ed
Parents: 4f008bb
Author: Guanghao Zhang <zghao@apache.org>
Authored: Thu Jan 19 11:30:06 2017 +0800
Committer: Guanghao Zhang <zghao@apache.org>
Committed: Thu Jan 19 11:30:06 2017 +0800

----------------------------------------------------------------------
 .../hbase/replication/ReplicationPeersZKImpl.java  |  2 +-
 .../hbase/replication/ReplicationQueuesZKImpl.java |  2 +-
 .../client/replication/TestReplicationAdmin.java   | 17 +++++++++++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/4778995c/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationPeersZKImpl.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationPeersZKImpl.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationPeersZKImpl.java
index b72fa1e..5bceaa5 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationPeersZKImpl.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationPeersZKImpl.java
@@ -113,7 +113,7 @@ public class ReplicationPeersZKImpl extends ReplicationStateZKBase implements
Re
             + " because that id already exists.");
       }
 
-      if(id.contains("-")){
+      if(id.contains("-") || id.equals(ReplicationQueuesZKImpl.RS_LOCK_ZNODE)) {
         throw new IllegalArgumentException("Found invalid peer name:" + id);
       }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/4778995c/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueuesZKImpl.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueuesZKImpl.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueuesZKImpl.java
index cb0eb2a..35e5087 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueuesZKImpl.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueuesZKImpl.java
@@ -68,7 +68,7 @@ public class ReplicationQueuesZKImpl extends ReplicationStateZKBase implements
R
   /** Znode containing all replication queues for this region server. */
   private String myQueuesZnode;
   /** Name of znode we use to lock during failover */
-  private final static String RS_LOCK_ZNODE = "lock";
+  public final static String RS_LOCK_ZNODE = "lock";
 
   private static final Log LOG = LogFactory.getLog(ReplicationQueuesZKImpl.class);
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/4778995c/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdmin.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdmin.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdmin.java
index fae23fe..3e8f09f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdmin.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdmin.java
@@ -30,6 +30,7 @@ import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.replication.ReplicationException;
 import org.apache.hadoop.hbase.replication.ReplicationPeer;
 import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
+import org.apache.hadoop.hbase.replication.ReplicationQueuesZKImpl;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -98,6 +99,22 @@ public class TestReplicationAdmin {
       // OK!
     }
     assertEquals(1, admin.getPeersCount());
+
+    // try adding a peer contains "-"
+    try {
+      admin.addPeer(ID_ONE + "-" + ID_SECOND, KEY_ONE);
+    } catch (IllegalArgumentException iae) {
+      // OK!
+    }
+    assertEquals(1, admin.getPeersCount());
+    // try adding a peer named "lock"
+    try {
+      admin.addPeer(ReplicationQueuesZKImpl.RS_LOCK_ZNODE, KEY_ONE);
+    } catch (IllegalArgumentException iae) {
+      // OK!
+    }
+    assertEquals(1, admin.getPeersCount());
+
     // Try to remove an inexisting peer
     try {
       admin.removePeer(ID_SECOND);


Mime
View raw message