HBASE-17289 Avoid adding a replication peer named "lock"
This commit is contained in:
parent
f13283bc05
commit
30576991bc
|
@ -113,7 +113,7 @@ public class ReplicationPeersZKImpl extends ReplicationStateZKBase implements Re
|
||||||
+ " because that id already exists.");
|
+ " 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);
|
throw new IllegalArgumentException("Found invalid peer name:" + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.replication.ReplicationFactory;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationPeer;
|
import org.apache.hadoop.hbase.replication.ReplicationPeer;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
|
import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationQueues;
|
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.testclassification.MediumTests;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
@ -108,6 +109,22 @@ public class TestReplicationAdmin {
|
||||||
// OK!
|
// OK!
|
||||||
}
|
}
|
||||||
assertEquals(1, admin.getPeersCount());
|
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 to remove an inexisting peer
|
||||||
try {
|
try {
|
||||||
admin.removePeer(ID_SECOND);
|
admin.removePeer(ID_SECOND);
|
||||||
|
|
Loading…
Reference in New Issue