HBASE-17289 Avoid adding a replication peer named "lock"

This commit is contained in:
tedyu 2016-12-12 09:38:55 -08:00
parent f13283bc05
commit 30576991bc
2 changed files with 18 additions and 1 deletions

View File

@ -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);
}

View File

@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.replication.ReplicationFactory;
import org.apache.hadoop.hbase.replication.ReplicationPeer;
import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
import org.apache.hadoop.hbase.replication.ReplicationQueues;
import org.apache.hadoop.hbase.replication.ReplicationQueuesZKImpl;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.junit.AfterClass;
@ -108,6 +109,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);