listChildrenNoWatch =
@@ -493,7 +493,7 @@ public class TestMasterReplication {
utility.startMiniCluster();
utilities[i] = utility;
configurations[i] = conf;
- new ZooKeeperWatcher(conf, "cluster" + i, null, true);
+ new ZKWatcher(conf, "cluster" + i, null, true);
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMultiSlaveReplication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMultiSlaveReplication.java
index a9896ce8c89..2e555a92f9f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMultiSlaveReplication.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMultiSlaveReplication.java
@@ -28,7 +28,6 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.Arrays;
-import java.util.List;
import java.util.concurrent.CountDownLatch;
import org.apache.commons.logging.Log;
@@ -39,20 +38,18 @@ import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Admin;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.client.replication.ReplicationAdmin;
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
import org.apache.hadoop.hbase.regionserver.HRegion;
-import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -104,7 +101,7 @@ public class TestMultiSlaveReplication {
utility1.startMiniZKCluster();
MiniZooKeeperCluster miniZK = utility1.getZkCluster();
utility1.setZkCluster(miniZK);
- new ZooKeeperWatcher(conf1, "cluster1", null, true);
+ new ZKWatcher(conf1, "cluster1", null, true);
conf2 = new Configuration(conf1);
conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
@@ -114,11 +111,11 @@ public class TestMultiSlaveReplication {
utility2 = new HBaseTestingUtility(conf2);
utility2.setZkCluster(miniZK);
- new ZooKeeperWatcher(conf2, "cluster2", null, true);
+ new ZKWatcher(conf2, "cluster2", null, true);
utility3 = new HBaseTestingUtility(conf3);
utility3.setZkCluster(miniZK);
- new ZooKeeperWatcher(conf3, "cluster3", null, true);
+ new ZKWatcher(conf3, "cluster3", null, true);
table = new HTableDescriptor(tableName);
HColumnDescriptor fam = new HColumnDescriptor(famName);
@@ -190,7 +187,7 @@ public class TestMultiSlaveReplication {
// Even if the log was rolled in the middle of the replication
// "row" is still replication.
checkRow(row, 1, htable2);
- // Replication thread of cluster 2 may be sleeping, and since row2 is not there in it,
+ // Replication thread of cluster 2 may be sleeping, and since row2 is not there in it,
// we should wait before checking.
checkWithWait(row, 1, htable3);
@@ -244,7 +241,7 @@ public class TestMultiSlaveReplication {
region.getWAL().unregisterWALActionsListener(listener);
}
-
+
private void checkWithWait(byte[] row, int count, Table table) throws Exception {
Get get = new Get(row);
for (int i = 0; i < NB_RETRIES; i++) {
@@ -267,7 +264,7 @@ public class TestMultiSlaveReplication {
}
}
}
-
+
private void checkRow(byte[] row, int count, Table... tables) throws IOException {
Get get = new Get(row);
for (Table table : tables) {
@@ -299,7 +296,7 @@ public class TestMultiSlaveReplication {
if (removedFromAll) {
break;
} else {
- Thread.sleep(SLEEP_TIME);
+ Thread.sleep(SLEEP_TIME);
}
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestPerTableCFReplication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestPerTableCFReplication.java
index 6572404326b..84ce9a3b99c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestPerTableCFReplication.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestPerTableCFReplication.java
@@ -50,7 +50,7 @@ import org.apache.hadoop.hbase.testclassification.FlakeyTests;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -114,7 +114,7 @@ public class TestPerTableCFReplication {
utility1 = new HBaseTestingUtility(conf1);
utility1.startMiniZKCluster();
MiniZooKeeperCluster miniZK = utility1.getZkCluster();
- new ZooKeeperWatcher(conf1, "cluster1", null, true);
+ new ZKWatcher(conf1, "cluster1", null, true);
conf2 = new Configuration(conf1);
conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
@@ -124,11 +124,11 @@ public class TestPerTableCFReplication {
utility2 = new HBaseTestingUtility(conf2);
utility2.setZkCluster(miniZK);
- new ZooKeeperWatcher(conf2, "cluster3", null, true);
+ new ZKWatcher(conf2, "cluster3", null, true);
utility3 = new HBaseTestingUtility(conf3);
utility3.setZkCluster(miniZK);
- new ZooKeeperWatcher(conf3, "cluster3", null, true);
+ new ZKWatcher(conf3, "cluster3", null, true);
table = new HTableDescriptor(tableName);
HColumnDescriptor fam = new HColumnDescriptor(famName);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java
index 58b97b9c5b7..f7d1009e6b9 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java
@@ -40,7 +40,7 @@ import org.apache.hadoop.hbase.client.replication.ReplicationAdmin;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.wal.AbstractFSWALProvider;
import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runners.Parameterized.Parameter;
@@ -64,8 +64,8 @@ public class TestReplicationBase {
protected static Configuration conf2;
protected static Configuration CONF_WITH_LOCALFS;
- protected static ZooKeeperWatcher zkw1;
- protected static ZooKeeperWatcher zkw2;
+ protected static ZKWatcher zkw1;
+ protected static ZKWatcher zkw2;
protected static ReplicationAdmin admin;
protected static Admin hbaseAdmin;
@@ -127,8 +127,8 @@ public class TestReplicationBase {
MiniZooKeeperCluster miniZK = utility1.getZkCluster();
// Have to reget conf1 in case zk cluster location different
// than default
- conf1 = utility1.getConfiguration();
- zkw1 = new ZooKeeperWatcher(conf1, "cluster1", null, true);
+ conf1 = utility1.getConfiguration();
+ zkw1 = new ZKWatcher(conf1, "cluster1", null, true);
admin = new ReplicationAdmin(conf1);
LOG.info("Setup first Zk");
@@ -140,7 +140,7 @@ public class TestReplicationBase {
utility2 = new HBaseTestingUtility(conf2);
utility2.setZkCluster(miniZK);
- zkw2 = new ZooKeeperWatcher(conf2, "cluster2", null, true);
+ zkw2 = new ZKWatcher(conf2, "cluster2", null, true);
LOG.info("Setup second Zk");
CONF_WITH_LOCALFS = HBaseConfiguration.create(conf1);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateHBaseImpl.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateHBaseImpl.java
index cc09751a20a..97daa639e32 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateHBaseImpl.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateHBaseImpl.java
@@ -30,8 +30,8 @@ import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.zookeeper.KeeperException;
import org.junit.After;
import org.junit.AfterClass;
@@ -54,7 +54,7 @@ public class TestReplicationStateHBaseImpl {
private static Configuration conf;
private static HBaseTestingUtility utility;
- private static ZooKeeperWatcher zkw;
+ private static ZKWatcher zkw;
private static String replicationZNode;
private static ReplicationQueues rq1;
@@ -413,7 +413,7 @@ public class TestReplicationStateHBaseImpl {
}
@Override
- public ZooKeeperWatcher getZooKeeper() {
+ public ZKWatcher getZooKeeper() {
return null;
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java
index dde78680e32..bb9f66594b6 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java
@@ -41,8 +41,8 @@ import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
import org.apache.hadoop.hbase.zookeeper.ZKConfig;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.zookeeper.KeeperException;
import org.junit.After;
import org.junit.AfterClass;
@@ -58,7 +58,7 @@ public class TestReplicationStateZKImpl extends TestReplicationStateBasic {
private static Configuration conf;
private static HBaseTestingUtility utility;
- private static ZooKeeperWatcher zkw;
+ private static ZKWatcher zkw;
private static String replicationZNode;
private ReplicationQueuesZKImpl rqZK;
@@ -80,7 +80,7 @@ public class TestReplicationStateZKImpl extends TestReplicationStateBasic {
// Add a dummy region server and set up the cluster id
Configuration testConf = new Configuration(conf);
testConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, baseZKNode);
- ZooKeeperWatcher zkw1 = new ZooKeeperWatcher(testConf, "test1", null);
+ ZKWatcher zkw1 = new ZKWatcher(testConf, "test1", null);
String fakeRs = ZNodePaths.joinZNode(zkw1.znodePaths.rsZNode, "hostname1.example.org:1234");
ZKUtil.createWithParents(zkw1, fakeRs);
ZKClusterId.setClusterId(zkw1, new ClusterId());
@@ -152,7 +152,7 @@ public class TestReplicationStateZKImpl extends TestReplicationStateBasic {
}
@Override
- public ZooKeeperWatcher getZooKeeper() {
+ public ZKWatcher getZooKeeper() {
return zkw;
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationTableBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationTableBase.java
index 83fdad75168..665eedb1dcb 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationTableBase.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationTableBase.java
@@ -23,7 +23,7 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.Waiter;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -43,7 +43,7 @@ public class TestReplicationTableBase {
private static long TIME_OUT_MILLIS = 3000;
private static Configuration conf;
private static HBaseTestingUtility utility;
- private static ZooKeeperWatcher zkw;
+ private static ZKWatcher zkw;
private static ReplicationTableBase rb;
private static ReplicationQueues rq;
private static ReplicationQueuesClient rqc;
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationTrackerZKImpl.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationTrackerZKImpl.java
index f6e7b39bb48..2db4f76332a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationTrackerZKImpl.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationTrackerZKImpl.java
@@ -43,8 +43,8 @@ import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -67,7 +67,7 @@ public class TestReplicationTrackerZKImpl {
private static HBaseTestingUtility utility;
// Each one of the below variables are reinitialized before every test case
- private ZooKeeperWatcher zkw;
+ private ZKWatcher zkw;
private ReplicationPeers rp;
private ReplicationTracker rt;
private AtomicInteger rsRemovedCount;
@@ -82,7 +82,7 @@ public class TestReplicationTrackerZKImpl {
utility = new HBaseTestingUtility();
utility.startMiniZKCluster();
conf = utility.getConfiguration();
- ZooKeeperWatcher zk = HBaseTestingUtility.getZooKeeperWatcher(utility);
+ ZKWatcher zk = HBaseTestingUtility.getZooKeeperWatcher(utility);
ZKUtil.createWithParents(zk, zk.znodePaths.rsZNode);
}
@@ -193,7 +193,7 @@ public class TestReplicationTrackerZKImpl {
int exists = 0;
int hyphen = 0;
rp.registerPeer("6", new ReplicationPeerConfig().setClusterKey(utility.getClusterKey()));
-
+
try{
rp.registerPeer("6", new ReplicationPeerConfig().setClusterKey(utility.getClusterKey()));
}catch(IllegalArgumentException e){
@@ -207,11 +207,11 @@ public class TestReplicationTrackerZKImpl {
}
assertEquals(1, exists);
assertEquals(1, hyphen);
-
+
// clean up
rp.unregisterPeer("6");
}
-
+
private class DummyReplicationListener implements ReplicationListener {
@Override
@@ -252,7 +252,7 @@ public class TestReplicationTrackerZKImpl {
}
@Override
- public ZooKeeperWatcher getZooKeeper() {
+ public ZKWatcher getZooKeeper() {
return zkw;
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestSerialReplication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestSerialReplication.java
index 7a8e6390fa2..1c5aa7190ea 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestSerialReplication.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestSerialReplication.java
@@ -54,7 +54,7 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.util.Threads;
import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -102,14 +102,14 @@ public class TestSerialReplication {
utility1 = new HBaseTestingUtility(conf1);
utility1.startMiniZKCluster();
MiniZooKeeperCluster miniZK = utility1.getZkCluster();
- new ZooKeeperWatcher(conf1, "cluster1", null, true);
+ new ZKWatcher(conf1, "cluster1", null, true);
conf2 = new Configuration(conf1);
conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
utility2 = new HBaseTestingUtility(conf2);
utility2.setZkCluster(miniZK);
- new ZooKeeperWatcher(conf2, "cluster2", null, true);
+ new ZKWatcher(conf2, "cluster2", null, true);
utility1.startMiniCluster(1, 10);
utility2.startMiniCluster(1, 1);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestTableCFsUpdater.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestTableCFsUpdater.java
index 1a0231748fb..cb895caa193 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestTableCFsUpdater.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestTableCFsUpdater.java
@@ -33,7 +33,7 @@ import org.apache.hadoop.hbase.testclassification.ReplicationTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.zookeeper.KeeperException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -55,7 +55,7 @@ public class TestTableCFsUpdater extends TableCFsUpdater {
private static final Log LOG = LogFactory.getLog(TestTableCFsUpdater.class);
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
- private static ZooKeeperWatcher zkw = null;
+ private static ZKWatcher zkw = null;
private static Abortable abortable = null;
@Rule
@@ -80,7 +80,7 @@ public class TestTableCFsUpdater extends TableCFsUpdater {
return false;
}
};
- zkw = new ZooKeeperWatcher(conf, "TableCFs", abortable, true);
+ zkw = new ZKWatcher(conf, "TableCFs", abortable, true);
}
@AfterClass
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestGlobalThrottler.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestGlobalThrottler.java
index 2469c7c726e..9b1648f6319 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestGlobalThrottler.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestGlobalThrottler.java
@@ -48,7 +48,7 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.Threads;
import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -86,14 +86,14 @@ public class TestGlobalThrottler {
utility1 = new HBaseTestingUtility(conf1);
utility1.startMiniZKCluster();
MiniZooKeeperCluster miniZK = utility1.getZkCluster();
- new ZooKeeperWatcher(conf1, "cluster1", null, true);
+ new ZKWatcher(conf1, "cluster1", null, true);
conf2 = new Configuration(conf1);
conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
utility2 = new HBaseTestingUtility(conf2);
utility2.setZkCluster(miniZK);
- new ZooKeeperWatcher(conf2, "cluster2", null, true);
+ new ZKWatcher(conf2, "cluster2", null, true);
ReplicationAdmin admin1 = new ReplicationAdmin(conf1);
ReplicationPeerConfig rpc = new ReplicationPeerConfig();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java
index dd1e19a8060..77301005421 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java
@@ -83,7 +83,7 @@ import org.apache.hadoop.hbase.wal.WALKey;
import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -116,7 +116,7 @@ public abstract class TestReplicationSourceManager {
protected static ReplicationSourceManager manager;
- protected static ZooKeeperWatcher zkw;
+ protected static ZKWatcher zkw;
protected static HTableDescriptor htd;
@@ -149,7 +149,7 @@ public abstract class TestReplicationSourceManager {
protected static void setupZkAndReplication() throws Exception {
// The implementing class should set up the conf
assertNotNull(conf);
- zkw = new ZooKeeperWatcher(conf, "test", null);
+ zkw = new ZKWatcher(conf, "test", null);
ZKUtil.createWithParents(zkw, "/hbase/replication");
ZKUtil.createWithParents(zkw, "/hbase/replication/peers/1");
ZKUtil.setData(zkw, "/hbase/replication/peers/1",
@@ -668,7 +668,7 @@ public abstract class TestReplicationSourceManager {
}
@Override
- public ZooKeeperWatcher getZooKeeper() {
+ public ZKWatcher getZooKeeper() {
return zkw;
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
index ad8cb140675..f9d0b1c219f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
@@ -56,7 +56,7 @@ import org.apache.hadoop.hbase.testclassification.SecurityTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.TestTableName;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -509,7 +509,7 @@ public class TestAccessController2 extends SecureTestUtil {
// Namespace needs this, as they follow the lazy creation of ACL znode.
grantOnNamespace(TEST_UTIL, TESTGROUP1_USER1.getShortName(), ns, Action.ADMIN);
- ZooKeeperWatcher zkw = TEST_UTIL.getMiniHBaseCluster().getMaster().getZooKeeper();
+ ZKWatcher zkw = TEST_UTIL.getMiniHBaseCluster().getMaster().getZooKeeper();
assertTrue("The acl znode for table should exist", ZKUtil.checkExists(zkw, baseAclZNode +
table.getNameAsString()) != -1);
assertTrue("The acl znode for namespace should exist", ZKUtil.checkExists(zkw, baseAclZNode +
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java
index 30e8396359a..607ea8c5f22 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java
@@ -44,7 +44,7 @@ import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.SecurityTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -61,7 +61,7 @@ import org.apache.hadoop.hbase.shaded.com.google.common.collect.ListMultimap;
public class TestTablePermissions {
private static final Log LOG = LogFactory.getLog(TestTablePermissions.class);
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
- private static ZooKeeperWatcher ZKW;
+ private static ZKWatcher ZKW;
private final static Abortable ABORTABLE = new Abortable() {
private final AtomicBoolean abort = new AtomicBoolean(false);
@@ -97,7 +97,7 @@ public class TestTablePermissions {
// Wait for the ACL table to become available
UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME);
- ZKW = new ZooKeeperWatcher(UTIL.getConfiguration(),
+ ZKW = new ZKWatcher(UTIL.getConfiguration(),
"TestTablePermissions", ABORTABLE);
UTIL.createTable(TEST_TABLE, TEST_FAMILY);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestZKPermissionWatcher.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestZKPermissionWatcher.java
index 76de0c6048c..18fb15fd522 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestZKPermissionWatcher.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestZKPermissionWatcher.java
@@ -34,7 +34,7 @@ import org.apache.hadoop.hbase.Waiter.Predicate;
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.SecurityTests;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -75,9 +75,9 @@ public class TestZKPermissionWatcher {
// start minicluster
UTIL.startMiniCluster();
- AUTH_A = TableAuthManager.getOrCreate(new ZooKeeperWatcher(conf,
+ AUTH_A = TableAuthManager.getOrCreate(new ZKWatcher(conf,
"TestZKPermissionsWatcher_1", ABORTABLE), conf);
- AUTH_B = TableAuthManager.getOrCreate(new ZooKeeperWatcher(conf,
+ AUTH_B = TableAuthManager.getOrCreate(new ZKWatcher(conf,
"TestZKPermissionsWatcher_2", ABORTABLE), conf);
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
index 5a0b6bdb3c4..3e0bddcb247 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
@@ -76,7 +76,7 @@ import org.apache.hadoop.hbase.util.Threads;
import org.apache.hadoop.hbase.util.Writables;
import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.hadoop.net.DNS;
import org.apache.hadoop.security.authorize.PolicyProvider;
import org.apache.hadoop.security.authorize.Service;
@@ -127,7 +127,7 @@ public class TestTokenAuthentication {
private HBaseTestingUtility TEST_UTIL;
private RpcServerInterface rpcServer;
private InetSocketAddress isa;
- private ZooKeeperWatcher zookeeper;
+ private ZKWatcher zookeeper;
private Sleeper sleeper;
private boolean started = false;
private boolean aborted = false;
@@ -220,7 +220,7 @@ public class TestTokenAuthentication {
}
@Override
- public ZooKeeperWatcher getZooKeeper() {
+ public ZKWatcher getZooKeeper() {
return zookeeper;
}
@@ -261,7 +261,7 @@ public class TestTokenAuthentication {
// ZK configuration must _not_ have hbase.security.authentication or it will require SASL auth
Configuration zkConf = new Configuration(conf);
zkConf.set(User.HBASE_SECURITY_CONF_KEY, "simple");
- this.zookeeper = new ZooKeeperWatcher(zkConf, TokenServer.class.getSimpleName(),
+ this.zookeeper = new ZKWatcher(zkConf, TokenServer.class.getSimpleName(),
this, true);
this.rpcServer.start();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestZKSecretWatcher.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestZKSecretWatcher.java
index 857cdd0ad16..ea0733874d7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestZKSecretWatcher.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestZKSecretWatcher.java
@@ -35,7 +35,7 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.SecurityTests;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -71,13 +71,13 @@ public class TestZKSecretWatcher {
private static class AuthenticationTokenSecretManagerForTest
extends AuthenticationTokenSecretManager {
private CountDownLatch latch = new CountDownLatch(1);
-
+
public AuthenticationTokenSecretManagerForTest(Configuration conf,
- ZooKeeperWatcher zk, String serverName,
- long keyUpdateInterval, long tokenMaxLifetime) {
+ ZKWatcher zk, String serverName,
+ long keyUpdateInterval, long tokenMaxLifetime) {
super(conf, zk, serverName, keyUpdateInterval, tokenMaxLifetime);
}
-
+
@Override
synchronized boolean removeKey(Integer keyId) {
boolean b = super.removeKey(keyId);
@@ -86,19 +86,19 @@ public class TestZKSecretWatcher {
}
return b;
}
-
+
CountDownLatch getLatch() {
return latch;
}
}
-
+
@BeforeClass
public static void setupBeforeClass() throws Exception {
TEST_UTIL = new HBaseTestingUtility();
TEST_UTIL.startMiniZKCluster();
Configuration conf = TEST_UTIL.getConfiguration();
- ZooKeeperWatcher zk = newZK(conf, "server1", new MockAbortable());
+ ZKWatcher zk = newZK(conf, "server1", new MockAbortable());
AuthenticationTokenSecretManagerForTest[] tmp = new AuthenticationTokenSecretManagerForTest[2];
tmp[0] = new AuthenticationTokenSecretManagerForTest(
conf, zk, "server1", 60*60*1000, 60*1000);
@@ -179,7 +179,7 @@ public class TestZKSecretWatcher {
// bring up a new slave
Configuration conf = TEST_UTIL.getConfiguration();
- ZooKeeperWatcher zk = newZK(conf, "server3", new MockAbortable());
+ ZKWatcher zk = newZK(conf, "server3", new MockAbortable());
KEY_SLAVE2 = new AuthenticationTokenSecretManager(
conf, zk, "server3", 60*60*1000, 60*1000);
KEY_SLAVE2.start();
@@ -233,7 +233,7 @@ public class TestZKSecretWatcher {
assertTrue(newCurrent.getKeyId() > current.getKeyId());
// add another slave
- ZooKeeperWatcher zk3 = newZK(conf, "server4", new MockAbortable());
+ ZKWatcher zk3 = newZK(conf, "server4", new MockAbortable());
KEY_SLAVE3 = new AuthenticationTokenSecretManager(
conf, zk3, "server4", 60*60*1000, 60*1000);
KEY_SLAVE3.start();
@@ -275,10 +275,10 @@ public class TestZKSecretWatcher {
assertTrue(newCurrent2.getKeyId() > current2.getKeyId());
}
- private static ZooKeeperWatcher newZK(Configuration conf, String name,
- Abortable abort) throws Exception {
+ private static ZKWatcher newZK(Configuration conf, String name,
+ Abortable abort) throws Exception {
Configuration copy = HBaseConfiguration.create(conf);
- ZooKeeperWatcher zk = new ZooKeeperWatcher(copy, name, abort);
+ ZKWatcher zk = new ZKWatcher(copy, name, abort);
return zk;
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestZKSecretWatcherRefreshKeys.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestZKSecretWatcherRefreshKeys.java
index fcadc9dc9d7..1757ddd0b17 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestZKSecretWatcherRefreshKeys.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestZKSecretWatcherRefreshKeys.java
@@ -28,8 +28,8 @@ import org.apache.hadoop.hbase.testclassification.SecurityTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Writables;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -55,7 +55,7 @@ public class TestZKSecretWatcherRefreshKeys {
return abort;
}
}
-
+
@BeforeClass
public static void setupBeforeClass() throws Exception {
TEST_UTIL = new HBaseTestingUtility();
@@ -67,19 +67,19 @@ public class TestZKSecretWatcherRefreshKeys {
TEST_UTIL.shutdownMiniZKCluster();
}
- private static ZooKeeperWatcher newZK(Configuration conf, String name,
- Abortable abort) throws Exception {
+ private static ZKWatcher newZK(Configuration conf, String name,
+ Abortable abort) throws Exception {
Configuration copy = HBaseConfiguration.create(conf);
- ZooKeeperWatcher zk = new ZooKeeperWatcher(copy, name, abort);
+ ZKWatcher zk = new ZKWatcher(copy, name, abort);
return zk;
}
@Test
public void testRefreshKeys() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
- ZooKeeperWatcher zk = newZK(conf, "127.0.0.1", new MockAbortable());
- AuthenticationTokenSecretManager keyManager =
- new AuthenticationTokenSecretManager(conf, zk, "127.0.0.1",
+ ZKWatcher zk = newZK(conf, "127.0.0.1", new MockAbortable());
+ AuthenticationTokenSecretManager keyManager =
+ new AuthenticationTokenSecretManager(conf, zk, "127.0.0.1",
60 * 60 * 1000, 60 * 1000);
ZKSecretWatcher watcher = new ZKSecretWatcher(conf, zk, keyManager);
ZKUtil.deleteChildrenRecursively(zk, watcher.getKeysParentZNode());
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelReplicationWithExpAsString.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelReplicationWithExpAsString.java
index e5b1c393917..c2da3ecda69 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelReplicationWithExpAsString.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelReplicationWithExpAsString.java
@@ -52,7 +52,7 @@ import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.SecurityTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.junit.Before;
import org.junit.experimental.categories.Category;
@@ -109,7 +109,7 @@ public class TestVisibilityLabelReplicationWithExpAsString extends TestVisibilit
TEST_UTIL = new HBaseTestingUtility(conf);
TEST_UTIL.startMiniZKCluster();
MiniZooKeeperCluster miniZK = TEST_UTIL.getZkCluster();
- zkw1 = new ZooKeeperWatcher(conf, "cluster1", null, true);
+ zkw1 = new ZKWatcher(conf, "cluster1", null, true);
admin = TEST_UTIL.getAdmin();
// Base conf2 on conf1 so it gets the right zk cluster.
@@ -124,7 +124,7 @@ public class TestVisibilityLabelReplicationWithExpAsString extends TestVisibilit
setVisibilityLabelServiceImpl(conf1, ExpAsStringVisibilityLabelServiceImpl.class);
TEST_UTIL1 = new HBaseTestingUtility(conf1);
TEST_UTIL1.setZkCluster(miniZK);
- zkw2 = new ZooKeeperWatcher(conf1, "cluster2", null, true);
+ zkw2 = new ZKWatcher(conf1, "cluster2", null, true);
TEST_UTIL.startMiniCluster(1);
// Wait for the labels table to become available
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsReplication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsReplication.java
index 513c76511aa..678227b6557 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsReplication.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsReplication.java
@@ -74,7 +74,7 @@ import org.apache.hadoop.hbase.testclassification.SecurityTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.wal.WAL.Entry;
import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
@@ -109,8 +109,8 @@ public class TestVisibilityLabelsReplication {
public final static byte[] fam = Bytes.toBytes("info");
public final static byte[] qual = Bytes.toBytes("qual");
public final static byte[] value = Bytes.toBytes("value");
- protected static ZooKeeperWatcher zkw1;
- protected static ZooKeeperWatcher zkw2;
+ protected static ZKWatcher zkw1;
+ protected static ZKWatcher zkw2;
protected static int expected[] = { 4, 6, 4, 0, 3 };
private static final String NON_VISIBILITY = "non-visibility";
protected static String[] expectedVisString = {
@@ -160,7 +160,7 @@ public class TestVisibilityLabelsReplication {
TEST_UTIL = new HBaseTestingUtility(conf);
TEST_UTIL.startMiniZKCluster();
MiniZooKeeperCluster miniZK = TEST_UTIL.getZkCluster();
- zkw1 = new ZooKeeperWatcher(conf, "cluster1", null, true);
+ zkw1 = new ZKWatcher(conf, "cluster1", null, true);
admin = TEST_UTIL.getAdmin();
// Base conf2 on conf1 so it gets the right zk cluster.
@@ -176,7 +176,7 @@ public class TestVisibilityLabelsReplication {
USER1 = User.createUserForTesting(conf1, "user1", new String[] {});
TEST_UTIL1 = new HBaseTestingUtility(conf1);
TEST_UTIL1.setZkCluster(miniZK);
- zkw2 = new ZooKeeperWatcher(conf1, "cluster2", null, true);
+ zkw2 = new ZKWatcher(conf1, "cluster2", null, true);
TEST_UTIL.startMiniCluster(1);
// Wait for the labels table to become available
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MockServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MockServer.java
index db442192a5f..4acec769725 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MockServer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MockServer.java
@@ -31,7 +31,7 @@ import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import org.apache.hadoop.hbase.client.ClusterConnection;
import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
/**
* Basic mock Server for handler tests.
@@ -39,10 +39,10 @@ import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
public class MockServer implements Server {
private static final Log LOG = LogFactory.getLog(MockServer.class);
final static ServerName NAME = ServerName.valueOf("MockServer", 123, -1);
-
+
boolean stopped;
boolean aborted;
- final ZooKeeperWatcher zk;
+ final ZKWatcher zk;
final HBaseTestingUtility htu;
@SuppressWarnings("unused")
@@ -66,7 +66,7 @@ public class MockServer implements Server {
throws ZooKeeperConnectionException, IOException {
this.htu = htu;
this.zk = zkw?
- new ZooKeeperWatcher(htu.getConfiguration(), NAME.toString(), this, true):
+ new ZKWatcher(htu.getConfiguration(), NAME.toString(), this, true):
null;
}
@@ -94,7 +94,7 @@ public class MockServer implements Server {
}
@Override
- public ZooKeeperWatcher getZooKeeper() {
+ public ZKWatcher getZooKeeper() {
return this.zk;
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
index 7463da101ba..ba3475e6341 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
@@ -86,7 +86,7 @@ import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.util.hbck.HFileCorruptionChecker;
import org.apache.hadoop.hbase.util.hbck.HbckTestingUtil;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
@@ -1493,7 +1493,7 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck {
Assert.assertEquals(1, replicationAdmin.getPeersCount());
// create replicator
- ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf, "Test Hbase Fsck", connection);
+ ZKWatcher zkw = new ZKWatcher(conf, "Test Hbase Fsck", connection);
ReplicationQueues repQueues =
ReplicationFactory.getReplicationQueues(new ReplicationQueuesArguments(conf, connection,
zkw));
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestRecoverableZooKeeper.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestRecoverableZooKeeper.java
index e71210d0675..6fa99fd9145 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestRecoverableZooKeeper.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestRecoverableZooKeeper.java
@@ -71,7 +71,7 @@ public class TestRecoverableZooKeeper {
public void testSetDataVersionMismatchInLoop() throws Exception {
String znode = "/hbase/splitWAL/9af7cfc9b15910a0b3d714bf40a3248f";
Configuration conf = TEST_UTIL.getConfiguration();
- ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf, "testSetDataVersionMismatchInLoop",
+ ZKWatcher zkw = new ZKWatcher(conf, "testSetDataVersionMismatchInLoop",
abortable, true);
String ensemble = ZKConfig.getZKQuorumServersString(conf);
RecoverableZooKeeper rzk = ZKUtil.connect(conf, ensemble, zkw);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKLeaderManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKLeaderManager.java
index 1faf8e52e05..69915a5e326 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKLeaderManager.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKLeaderManager.java
@@ -61,12 +61,12 @@ public class TestZKLeaderManager {
private static class MockLeader extends Thread implements Stoppable {
private boolean stopped;
- private ZooKeeperWatcher watcher;
+ private ZKWatcher watcher;
private ZKLeaderManager zkLeader;
private AtomicBoolean master = new AtomicBoolean(false);
private int index;
- public MockLeader(ZooKeeperWatcher watcher, int index) {
+ public MockLeader(ZKWatcher watcher, int index) {
setDaemon(true);
setName("TestZKLeaderManager-leader-" + index);
this.index = index;
@@ -83,7 +83,7 @@ public class TestZKLeaderManager {
return index;
}
- public ZooKeeperWatcher getWatcher() {
+ public ZKWatcher getWatcher() {
return watcher;
}
@@ -132,7 +132,7 @@ public class TestZKLeaderManager {
MockAbortable abortable = new MockAbortable();
CANDIDATES = new MockLeader[3];
for (int i = 0; i < 3; i++) {
- ZooKeeperWatcher watcher = newZK(conf, "server"+i, abortable);
+ ZKWatcher watcher = newZK(conf, "server"+i, abortable);
CANDIDATES[i] = new MockLeader(watcher, i);
CANDIDATES[i].start();
}
@@ -225,10 +225,10 @@ public class TestZKLeaderManager {
return currentLeader;
}
- private static ZooKeeperWatcher newZK(Configuration conf, String name,
- Abortable abort) throws Exception {
+ private static ZKWatcher newZK(Configuration conf, String name,
+ Abortable abort) throws Exception {
Configuration copy = HBaseConfiguration.create(conf);
- ZooKeeperWatcher zk = new ZooKeeperWatcher(copy, name, abort);
+ ZKWatcher zk = new ZKWatcher(copy, name, abort);
return zk;
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperMainServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMainServer.java
similarity index 95%
rename from hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperMainServer.java
rename to hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMainServer.java
index 368919ceb54..c99bd0526ee 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperMainServer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMainServer.java
@@ -31,7 +31,7 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
@Category({MiscTests.class, SmallTests.class})
-public class TestZooKeeperMainServer {
+public class TestZKMainServer {
// ZKMS calls System.exit. Catch the call and prevent exit using trick described up in
// http://stackoverflow.com/questions/309396/java-how-to-test-methods-that-call-system-exit
protected static class ExitException extends SecurityException {
@@ -72,13 +72,13 @@ public class TestZooKeeperMainServer {
htu.getConfiguration().setInt(HConstants.ZK_SESSION_TIMEOUT, 1000);
htu.startMiniZKCluster();
try {
- ZooKeeperWatcher zkw = htu.getZooKeeperWatcher();
+ ZKWatcher zkw = htu.getZooKeeperWatcher();
String znode = "/testCommandLineWorks";
ZKUtil.createWithParents(zkw, znode, HConstants.EMPTY_BYTE_ARRAY);
ZKUtil.checkExists(zkw, znode);
boolean exception = false;
try {
- ZooKeeperMainServer.main(new String [] {"-server",
+ ZKMainServer.main(new String [] {"-server",
"localhost:" + htu.getZkCluster().getClientPort(), "delete", znode});
} catch (ExitException ee) {
// ZKMS calls System.exit which should trigger this exception.
@@ -94,7 +94,7 @@ public class TestZooKeeperMainServer {
@Test
public void testHostPortParse() {
- ZooKeeperMainServer parser = new ZooKeeperMainServer();
+ ZKMainServer parser = new ZKMainServer();
Configuration c = HBaseConfiguration.create();
assertEquals("localhost:" + c.get(HConstants.ZOOKEEPER_CLIENT_PORT), parser.parse(c));
final String port = "1234";
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMulti.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMulti.java
index 7971417ca43..614d4be9fa5 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMulti.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMulti.java
@@ -53,7 +53,7 @@ import org.junit.experimental.categories.Category;
public class TestZKMulti {
private static final Log LOG = LogFactory.getLog(TestZKMulti.class);
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
- private static ZooKeeperWatcher zkw = null;
+ private static ZKWatcher zkw = null;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
@@ -70,7 +70,7 @@ public class TestZKMulti {
return false;
}
};
- zkw = new ZooKeeperWatcher(conf,
+ zkw = new ZKWatcher(conf,
"TestZKMulti", abortable, true);
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperNodeTracker.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKNodeTracker.java
similarity index 92%
rename from hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperNodeTracker.java
rename to hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKNodeTracker.java
index 951c6ba47d0..ac5c11af4ca 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperNodeTracker.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKNodeTracker.java
@@ -48,8 +48,8 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
@Category({MiscTests.class, MediumTests.class})
-public class TestZooKeeperNodeTracker {
- private static final Log LOG = LogFactory.getLog(TestZooKeeperNodeTracker.class);
+public class TestZKNodeTracker {
+ private static final Log LOG = LogFactory.getLog(TestZKNodeTracker.class);
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private final static Random rand = new Random();
@@ -71,7 +71,7 @@ public class TestZooKeeperNodeTracker {
*/
@Test public void testInterruptible() throws IOException, InterruptedException {
Abortable abortable = new StubAbortable();
- ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
+ ZKWatcher zk = new ZKWatcher(TEST_UTIL.getConfiguration(),
"testInterruptible", abortable);
final TestTracker tracker = new TestTracker(zk, "/xyz", abortable);
tracker.start();
@@ -95,7 +95,7 @@ public class TestZooKeeperNodeTracker {
@Test
public void testNodeTracker() throws Exception {
Abortable abortable = new StubAbortable();
- ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
+ ZKWatcher zk = new ZKWatcher(TEST_UTIL.getConfiguration(),
"testNodeTracker", abortable);
ZKUtil.createAndFailSilent(zk, zk.znodePaths.baseZNode);
@@ -213,15 +213,15 @@ public class TestZooKeeperNodeTracker {
TestTracker tracker;
boolean hasData;
- public WaitToGetDataThread(ZooKeeperWatcher zk, String node) {
+ public WaitToGetDataThread(ZKWatcher zk, String node) {
tracker = new TestTracker(zk, node, null);
tracker.start();
zk.registerListener(tracker);
hasData = false;
}
- public WaitToGetDataThread(ZooKeeperWatcher zk, String node,
- TestTracker tracker) {
+ public WaitToGetDataThread(ZKWatcher zk, String node,
+ TestTracker tracker) {
this.tracker = tracker;
hasData = false;
}
@@ -239,14 +239,14 @@ public class TestZooKeeperNodeTracker {
}
}
- public static class TestTracker extends ZooKeeperNodeTracker {
- public TestTracker(ZooKeeperWatcher watcher, String node,
- Abortable abortable) {
+ public static class TestTracker extends ZKNodeTracker {
+ public TestTracker(ZKWatcher watcher, String node,
+ Abortable abortable) {
super(watcher, node, abortable);
}
}
- public static class TestingZKListener extends ZooKeeperListener {
+ public static class TestingZKListener extends ZKListener {
private static final Log LOG = LogFactory.getLog(NodeDeletionListener.class);
private Semaphore deletedLock;
@@ -254,7 +254,7 @@ public class TestZooKeeperNodeTracker {
private Semaphore changedLock;
private String node;
- public TestingZKListener(ZooKeeperWatcher watcher, String node) {
+ public TestingZKListener(ZKWatcher watcher, String node) {
super(watcher);
deletedLock = new Semaphore(0);
createdLock = new Semaphore(0);
@@ -302,12 +302,12 @@ public class TestZooKeeperNodeTracker {
public static class StubAbortable implements Abortable {
@Override
public void abort(final String msg, final Throwable t) {}
-
+
@Override
public boolean isAborted() {
return false;
}
-
+
}
public static class StubWatcher implements Watcher {
@@ -317,8 +317,8 @@ public class TestZooKeeperNodeTracker {
@Test
public void testCleanZNode() throws Exception {
- ZooKeeperWatcher zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
- "testNodeTracker", new TestZooKeeperNodeTracker.StubAbortable());
+ ZKWatcher zkw = new ZKWatcher(TEST_UTIL.getConfiguration(),
+ "testNodeTracker", new TestZKNodeTracker.StubAbortable());
final ServerName sn = ServerName.valueOf("127.0.0.1:52", 45L);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperACL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperACL.java
index 05ad73e9745..c5bce009872 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperACL.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperACL.java
@@ -49,9 +49,9 @@ public class TestZooKeeperACL {
private final static HBaseTestingUtility TEST_UTIL =
new HBaseTestingUtility();
- private static ZooKeeperWatcher zkw;
+ private static ZKWatcher zkw;
private static boolean secureZKAvailable;
-
+
@BeforeClass
public static void setUpBeforeClass() throws Exception {
File saslConfFile = File.createTempFile("tmp", "jaas.conf");
@@ -76,7 +76,7 @@ public class TestZooKeeperACL {
TEST_UTIL.getConfiguration().setInt("hbase.zookeeper.property.maxClientCnxns", 1000);
// If Hadoop is missing HADOOP-7070 the cluster will fail to start due to
- // the JAAS configuration required by ZK being clobbered by Hadoop
+ // the JAAS configuration required by ZK being clobbered by Hadoop
try {
TEST_UTIL.startMiniCluster();
} catch (IOException e) {
@@ -84,7 +84,7 @@ public class TestZooKeeperACL {
secureZKAvailable = false;
return;
}
- zkw = new ZooKeeperWatcher(
+ zkw = new ZKWatcher(
new Configuration(TEST_UTIL.getConfiguration()),
TestZooKeeper.class.getName(), null);
}
@@ -112,7 +112,7 @@ public class TestZooKeeperACL {
}
/**
- * Create a node and check its ACL. When authentication is enabled on
+ * Create a node and check its ACL. When authentication is enabled on
* ZooKeeper, all nodes (except /hbase/root-region-server, /hbase/master
* and /hbase/hbaseid) should be created so that only the hbase server user
* (master or region server user) that created them can access them, and
@@ -285,7 +285,7 @@ public class TestZooKeeperACL {
assertEquals(testJaasConfig, false);
saslConfFile.delete();
}
-
+
/**
* Check if Programmatic way of setting zookeeper security settings is valid.
*/
diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb
index 0ce38cc5e33..9f8551cd967 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -328,7 +328,7 @@ module Hbase
#----------------------------------------------------------------------------------------------
# Returns ZooKeeper status dump
def zk_dump
- @zk_wrapper = org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.new(
+ @zk_wrapper = org.apache.hadoop.hbase.zookeeper.ZKWatcher.new(
@admin.getConfiguration,
'admin',
nil
diff --git a/hbase-zookeeper/pom.xml b/hbase-zookeeper/pom.xml
new file mode 100644
index 00000000000..a2544181c33
--- /dev/null
+++ b/hbase-zookeeper/pom.xml
@@ -0,0 +1,412 @@
+
+
+
+ 4.0.0
+
+ hbase-build-configuration
+ org.apache.hbase
+ 2.0.0-beta-1.SNAPSHOT
+ ../hbase-build-configuration
+
+ hbase-zookeeper
+ Apache HBase - Zookeeper
+ Zookeeper Helpers for HBase
+
+
+
+
+
+
+ src/test/resources/META-INF/
+ META-INF/
+
+ NOTICE
+
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-site-plugin
+
+ true
+
+
+
+
+
+ maven-assembly-plugin
+
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+ package
+
+ jar
+ test-jar
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-eclipse-plugin
+
+
+ org.jamon.project.jamonnature
+
+
+ org.jamon.project.templateBuilder
+ org.eclipse.jdt.core.javabuilder
+ org.jamon.project.markerUpdater
+
+
+
+ .settings/org.jamon.prefs
+ # now
+ eclipse.preferences.version=1
+ templateSourceDir=src/main/jamon
+ templateOutputDir=target/generated-jamon
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ findbugs-maven-plugin
+
+
+
+ maven-surefire-plugin
+
+
+
+ listener
+ org.apache.hadoop.hbase.ResourceCheckerJUnitListener
+
+
+
+
+
+
+
+
+
+
+ org.eclipse.m2e
+ lifecycle-mapping
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+ [1.6,)
+
+ run
+
+
+
+
+ false
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ [2.8,)
+
+ build-classpath
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ [3.2,)
+
+ compile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.hbase.thirdparty
+ hbase-shaded-protobuf
+
+
+ org.apache.hbase.thirdparty
+ hbase-shaded-miscellaneous
+
+
+
+ org.apache.hbase
+ hbase-common
+
+
+ org.apache.hbase
+ hbase-common
+ test-jar
+ test
+
+
+ org.apache.hbase
+ hbase-client
+
+
+ org.apache.hbase
+ hbase-annotations
+ test-jar
+ test
+
+
+ org.apache.hbase
+ hbase-protocol-shaded
+
+
+ org.apache.hbase
+ hbase-hadoop-compat
+
+
+ org.apache.hbase
+ hbase-hadoop2-compat
+
+
+
+ org.apache.hadoop
+ hadoop-mapreduce-client-core
+
+
+
+
+
+ com.github.stephenc.findbugs
+ findbugs-annotations
+ true
+
+
+ org.apache.commons
+ commons-lang3
+
+
+ commons-logging
+ commons-logging
+
+
+ log4j
+ log4j
+
+
+ org.apache.zookeeper
+ zookeeper
+
+
+
+ junit
+ junit
+ test
+
+
+ org.mockito
+ mockito-core
+ test
+
+
+
+
+
+ apache-release
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+
+
+ license-javadocs
+ prepare-package
+
+ copy-resources
+
+
+ ${project.build.directory}/apidocs
+
+
+ src/main/javadoc/META-INF/
+ META-INF/
+
+ LICENSE
+ NOTICE
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+ skipZooKeeperTests
+
+
+ skipZooKeeperTests
+
+
+
+ true
+ true
+
+
+
+
+
+
+
+ hadoop-2.0
+
+
+
+ !hadoop.profile
+
+
+
+
+ org.apache.hadoop
+ hadoop-common
+
+
+ org.apache.hadoop
+ hadoop-auth
+
+
+
+
+
+ maven-dependency-plugin
+
+
+ create-mrapp-generated-classpath
+ generate-test-resources
+
+ build-classpath
+
+
+
+ ${project.build.directory}/test-classes/mrapp-generated-classpath
+
+
+
+
+
+
+
+
+
+ hadoop-3.0
+
+
+ hadoop.profile
+ 3.0
+
+
+
+ ${hadoop-three.version}
+
+
+
+ org.apache.hadoop
+ hadoop-common
+
+
+ org.apache.hadoop
+ hadoop-auth
+
+
+
+
+
+ maven-dependency-plugin
+
+
+ create-mrapp-generated-classpath
+ generate-test-resources
+
+ build-classpath
+
+
+
+ ${project.build.directory}/test-classes/mrapp-generated-classpath
+
+
+
+
+
+
+
+
+
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ClusterStatusTracker.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ClusterStatusTracker.java
similarity index 94%
rename from hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ClusterStatusTracker.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ClusterStatusTracker.java
index fd60765a42c..d145d0825ac 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ClusterStatusTracker.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ClusterStatusTracker.java
@@ -1,4 +1,4 @@
-/**
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -28,13 +28,13 @@ import org.apache.zookeeper.KeeperException;
/**
* Tracker on cluster settings up in zookeeper.
- * This is not related to {@link org.apache.hadoop.hbase.ClusterStatus}. That class
- * is a data structure that holds snapshot of current view on cluster. This class
+ * This is not related to {@link org.apache.hadoop.hbase.ClusterStatus}. That class
+ * is a data structure that holds snapshot of current view on cluster. This class
* is about tracking cluster attributes up in zookeeper.
*
*/
@InterfaceAudience.Private
-public class ClusterStatusTracker extends ZooKeeperNodeTracker {
+public class ClusterStatusTracker extends ZKNodeTracker {
private static final Log LOG = LogFactory.getLog(ClusterStatusTracker.class);
/**
@@ -45,7 +45,7 @@ public class ClusterStatusTracker extends ZooKeeperNodeTracker {
* @param watcher
* @param abortable
*/
- public ClusterStatusTracker(ZooKeeperWatcher watcher, Abortable abortable) {
+ public ClusterStatusTracker(ZKWatcher watcher, Abortable abortable) {
super(watcher, watcher.znodePaths.clusterStateZNode, abortable);
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/DeletionListener.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/DeletionListener.java
similarity index 94%
rename from hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/DeletionListener.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/DeletionListener.java
index c58a840f2b7..7c028912066 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/DeletionListener.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/DeletionListener.java
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright The Apache Software Foundation
*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -30,7 +30,7 @@ import org.apache.zookeeper.KeeperException;
* A ZooKeeper watcher meant to detect deletions of ZNodes.
*/
@InterfaceAudience.Private
-public class DeletionListener extends ZooKeeperListener {
+public class DeletionListener extends ZKListener {
private static final Log LOG = LogFactory.getLog(DeletionListener.class);
@@ -46,8 +46,8 @@ public class DeletionListener extends ZooKeeperListener {
* be deleted.
* @param deletedLatch Count down on this latch when deletion has occurred.
*/
- public DeletionListener(ZooKeeperWatcher zkWatcher, String pathToWatch,
- CountDownLatch deletedLatch) {
+ public DeletionListener(ZKWatcher zkWatcher, String pathToWatch,
+ CountDownLatch deletedLatch) {
super(zkWatcher);
this.pathToWatch = pathToWatch;
this.deletedLatch = deletedLatch;
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/EmptyWatcher.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/EmptyWatcher.java
similarity index 99%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/EmptyWatcher.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/EmptyWatcher.java
index 191943a46e4..6470faa4e92 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/EmptyWatcher.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/EmptyWatcher.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java
similarity index 98%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java
index 5f3904aabca..f07b8416ff1 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java
@@ -1,4 +1,4 @@
-/**
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -142,7 +142,7 @@ public class HQuorumPeer {
// Set the max session timeout from the provided client-side timeout
properties.setProperty("maxSessionTimeout",
- conf.get(ZK_SESSION_TIMEOUT, Integer.toString(DEFAULT_ZK_SESSION_TIMEOUT)));
+ conf.get(HConstants.ZK_SESSION_TIMEOUT, Integer.toString(HConstants.DEFAULT_ZK_SESSION_TIMEOUT)));
if (myId == -1) {
throw new IOException("Could not find my address: " + myAddress +
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/InstancePending.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/InstancePending.java
similarity index 100%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/InstancePending.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/InstancePending.java
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/LoadBalancerTracker.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/LoadBalancerTracker.java
similarity index 96%
rename from hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/LoadBalancerTracker.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/LoadBalancerTracker.java
index 527bc17c4b8..55dafcb3b20 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/LoadBalancerTracker.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/LoadBalancerTracker.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -33,10 +33,10 @@ import org.apache.zookeeper.KeeperException;
* Tracks the load balancer state up in ZK
*/
@InterfaceAudience.Private
-public class LoadBalancerTracker extends ZooKeeperNodeTracker {
+public class LoadBalancerTracker extends ZKNodeTracker {
private static final Log LOG = LogFactory.getLog(LoadBalancerTracker.class);
- public LoadBalancerTracker(ZooKeeperWatcher watcher,
+ public LoadBalancerTracker(ZKWatcher watcher,
Abortable abortable) {
super(watcher, watcher.znodePaths.balancerZNode, abortable);
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTracker.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTracker.java
similarity index 92%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTracker.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTracker.java
index fba637fbe63..85668ad18b7 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTracker.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTracker.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -41,17 +41,17 @@ import org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferE
* NodeDeleted
and NodeCreated
events on
* /master
.
*
- * Utilizes {@link ZooKeeperNodeTracker} for zk interactions.
+ * Utilizes {@link ZKNodeTracker} for zk interactions.
*
* You can get the current master via {@link #getMasterAddress()} or via
- * {@link #getMasterAddress(ZooKeeperWatcher)} if you do not have a running
+ * {@link #getMasterAddress(ZKWatcher)} if you do not have a running
* instance of this Tracker in your context.
*
* This class also includes utility for interacting with the master znode, for
* writing and reading the znode content.
*/
@InterfaceAudience.Private
-public class MasterAddressTracker extends ZooKeeperNodeTracker {
+public class MasterAddressTracker extends ZKNodeTracker {
/**
* Construct a master address listener with the specified
* zookeeper
reference.
@@ -63,7 +63,7 @@ public class MasterAddressTracker extends ZooKeeperNodeTracker {
* @param watcher zk reference and watcher
* @param abortable abortable in case of fatal error
*/
- public MasterAddressTracker(ZooKeeperWatcher watcher, Abortable abortable) {
+ public MasterAddressTracker(ZKWatcher watcher, Abortable abortable) {
super(watcher, watcher.znodePaths.masterAddressZNode, abortable);
}
@@ -136,13 +136,13 @@ public class MasterAddressTracker extends ZooKeeperNodeTracker {
* Get master address.
* Use this instead of {@link #getMasterAddress()} if you do not have an
* instance of this tracker in your context.
- * @param zkw ZooKeeperWatcher to use
+ * @param zkw ZKWatcher to use
* @return ServerName stored in the the master address znode or null if no
* znode present.
- * @throws KeeperException
- * @throws IOException
+ * @throws KeeperException
+ * @throws IOException
*/
- public static ServerName getMasterAddress(final ZooKeeperWatcher zkw)
+ public static ServerName getMasterAddress(final ZKWatcher zkw)
throws KeeperException, IOException {
byte [] data;
try {
@@ -167,14 +167,14 @@ public class MasterAddressTracker extends ZooKeeperNodeTracker {
* Get master info port.
* Use this instead of {@link #getMasterInfoPort()} if you do not have an
* instance of this tracker in your context.
- * @param zkw ZooKeeperWatcher to use
+ * @param zkw ZKWatcher to use
* @return master info port in the the master address znode or null if no
* znode present.
* // TODO can't return null for 'int' return type. non-static verison returns 0
* @throws KeeperException
* @throws IOException
*/
- public static int getMasterInfoPort(final ZooKeeperWatcher zkw) throws KeeperException,
+ public static int getMasterInfoPort(final ZKWatcher zkw) throws KeeperException,
IOException {
byte[] data;
try {
@@ -199,14 +199,14 @@ public class MasterAddressTracker extends ZooKeeperNodeTracker {
* Set master address into the master
znode or into the backup
* subdirectory of backup masters; switch off the passed in znode
* path.
- * @param zkw The ZooKeeperWatcher to use.
+ * @param zkw The ZKWatcher to use.
* @param znode Where to create the znode; could be at the top level or it
* could be under backup masters
* @param master ServerName of the current master must not be null.
* @return true if node created, false if not; a watch is set in both cases
* @throws KeeperException
*/
- public static boolean setMasterAddress(final ZooKeeperWatcher zkw,
+ public static boolean setMasterAddress(final ZKWatcher zkw,
final String znode, final ServerName master, int infoPort)
throws KeeperException {
return ZKUtil.createEphemeralNodeAndWatch(zkw, znode, toByteArray(master, infoPort));
@@ -258,7 +258,7 @@ public class MasterAddressTracker extends ZooKeeperNodeTracker {
* @param zkw must not be null
* @param content must not be null
*/
- public static boolean deleteIfEquals(ZooKeeperWatcher zkw, final String content) {
+ public static boolean deleteIfEquals(ZKWatcher zkw, final String content) {
if (content == null){
throw new IllegalArgumentException("Content must not be null");
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterMaintenanceModeTracker.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterMaintenanceModeTracker.java
similarity index 93%
rename from hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterMaintenanceModeTracker.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterMaintenanceModeTracker.java
index 7d6f9fdd917..952da6f2e64 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterMaintenanceModeTracker.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterMaintenanceModeTracker.java
@@ -1,4 +1,4 @@
-/**
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -27,10 +27,10 @@ import org.apache.zookeeper.KeeperException;
* Tracks the master Maintenance Mode via ZK.
*/
@InterfaceAudience.Private
-public class MasterMaintenanceModeTracker extends ZooKeeperListener {
+public class MasterMaintenanceModeTracker extends ZKListener {
private boolean hasChildren;
- public MasterMaintenanceModeTracker(ZooKeeperWatcher watcher) {
+ public MasterMaintenanceModeTracker(ZKWatcher watcher) {
super(watcher);
hasChildren = false;
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java
similarity index 93%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java
index cddde2f521b..f6c7a2d6909 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -65,7 +65,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ZooKeeperProtos.MetaReg
* which keeps hbase:meta region server location.
*
* Stateless class with a bunch of static methods. Doesn't manage resources passed in
- * (e.g. Connection, ZooKeeperWatcher etc).
+ * (e.g. Connection, ZKWatcher etc).
*
* Meta region location is set by RegionServerServices
.
* This class doesn't use ZK watchers, rather accesses ZK directly.
@@ -86,7 +86,7 @@ public class MetaTableLocator {
* Checks if the meta region location is available.
* @return true if meta region location is available, false if not
*/
- public boolean isLocationAvailable(ZooKeeperWatcher zkw) {
+ public boolean isLocationAvailable(ZKWatcher zkw) {
return getMetaRegionLocation(zkw) != null;
}
@@ -94,7 +94,7 @@ public class MetaTableLocator {
* @param zkw ZooKeeper watcher to be used
* @return meta table regions and their locations.
*/
- public List> getMetaRegionsAndLocations(ZooKeeperWatcher zkw) {
+ public List> getMetaRegionsAndLocations(ZKWatcher zkw) {
return getMetaRegionsAndLocations(zkw, RegionInfo.DEFAULT_REPLICA_ID);
}
@@ -104,7 +104,7 @@ public class MetaTableLocator {
* @param replicaId
* @return meta table regions and their locations.
*/
- public List> getMetaRegionsAndLocations(ZooKeeperWatcher zkw,
+ public List> getMetaRegionsAndLocations(ZKWatcher zkw,
int replicaId) {
ServerName serverName = getMetaRegionLocation(zkw, replicaId);
List> list = new ArrayList<>(1);
@@ -117,7 +117,7 @@ public class MetaTableLocator {
* @param zkw ZooKeeper watcher to be used
* @return List of meta regions
*/
- public List getMetaRegions(ZooKeeperWatcher zkw) {
+ public List getMetaRegions(ZKWatcher zkw) {
return getMetaRegions(zkw, RegionInfo.DEFAULT_REPLICA_ID);
}
@@ -127,7 +127,7 @@ public class MetaTableLocator {
* @param replicaId
* @return List of meta regions
*/
- public List getMetaRegions(ZooKeeperWatcher zkw, int replicaId) {
+ public List getMetaRegions(ZKWatcher zkw, int replicaId) {
List> result;
result = getMetaRegionsAndLocations(zkw, replicaId);
return getListOfRegionInfos(result);
@@ -148,7 +148,7 @@ public class MetaTableLocator {
* @param zkw zookeeper connection to use
* @return server name or null if we failed to get the data.
*/
- public ServerName getMetaRegionLocation(final ZooKeeperWatcher zkw) {
+ public ServerName getMetaRegionLocation(final ZKWatcher zkw) {
try {
RegionState state = getMetaRegionState(zkw);
return state.isOpened() ? state.getServerName() : null;
@@ -163,7 +163,7 @@ public class MetaTableLocator {
* @param replicaId
* @return server name
*/
- public ServerName getMetaRegionLocation(final ZooKeeperWatcher zkw, int replicaId) {
+ public ServerName getMetaRegionLocation(final ZKWatcher zkw, int replicaId) {
try {
RegionState state = getMetaRegionState(zkw, replicaId);
return state.isOpened() ? state.getServerName() : null;
@@ -184,7 +184,7 @@ public class MetaTableLocator {
* @throws InterruptedException if interrupted while waiting
* @throws NotAllMetaRegionsOnlineException
*/
- public ServerName waitMetaRegionLocation(ZooKeeperWatcher zkw, long timeout)
+ public ServerName waitMetaRegionLocation(ZKWatcher zkw, long timeout)
throws InterruptedException, NotAllMetaRegionsOnlineException {
return waitMetaRegionLocation(zkw, RegionInfo.DEFAULT_REPLICA_ID, timeout);
}
@@ -202,7 +202,7 @@ public class MetaTableLocator {
* @throws InterruptedException
* @throws NotAllMetaRegionsOnlineException
*/
- public ServerName waitMetaRegionLocation(ZooKeeperWatcher zkw, int replicaId, long timeout)
+ public ServerName waitMetaRegionLocation(ZKWatcher zkw, int replicaId, long timeout)
throws InterruptedException, NotAllMetaRegionsOnlineException {
try {
if (ZKUtil.checkExists(zkw, zkw.znodePaths.baseZNode) == -1) {
@@ -227,10 +227,10 @@ public class MetaTableLocator {
* Waits indefinitely for availability of hbase:meta
. Used during
* cluster startup. Does not verify meta, just that something has been
* set up in zk.
- * @see #waitMetaRegionLocation(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher, long)
+ * @see #waitMetaRegionLocation(ZKWatcher, long)
* @throws InterruptedException if interrupted while waiting
*/
- public void waitMetaRegionLocation(ZooKeeperWatcher zkw) throws InterruptedException {
+ public void waitMetaRegionLocation(ZKWatcher zkw) throws InterruptedException {
long startTime = System.currentTimeMillis();
while (!stopped) {
try {
@@ -260,7 +260,7 @@ public class MetaTableLocator {
* @throws InterruptedException
*/
public boolean verifyMetaRegionLocation(ClusterConnection hConnection,
- ZooKeeperWatcher zkw, final long timeout)
+ ZKWatcher zkw, final long timeout)
throws InterruptedException, IOException {
return verifyMetaRegionLocation(hConnection, zkw, timeout, RegionInfo.DEFAULT_REPLICA_ID);
}
@@ -276,7 +276,7 @@ public class MetaTableLocator {
* @throws IOException
*/
public boolean verifyMetaRegionLocation(ClusterConnection connection,
- ZooKeeperWatcher zkw, final long timeout, int replicaId)
+ ZKWatcher zkw, final long timeout, int replicaId)
throws InterruptedException, IOException {
AdminProtos.AdminService.BlockingInterface service = null;
try {
@@ -360,7 +360,7 @@ public class MetaTableLocator {
* @throws IOException
*/
private AdminService.BlockingInterface getMetaServerConnection(ClusterConnection connection,
- ZooKeeperWatcher zkw, long timeout, int replicaId)
+ ZKWatcher zkw, long timeout, int replicaId)
throws InterruptedException, NotAllMetaRegionsOnlineException, IOException {
return getCachedConnection(connection, waitMetaRegionLocation(zkw, replicaId, timeout));
}
@@ -424,7 +424,7 @@ public class MetaTableLocator {
* @param state The region transition state
* @throws KeeperException unexpected zookeeper exception
*/
- public static void setMetaLocation(ZooKeeperWatcher zookeeper,
+ public static void setMetaLocation(ZKWatcher zookeeper,
ServerName serverName, RegionState.State state) throws KeeperException {
setMetaLocation(zookeeper, serverName, RegionInfo.DEFAULT_REPLICA_ID, state);
}
@@ -438,7 +438,7 @@ public class MetaTableLocator {
* @param state
* @throws KeeperException
*/
- public static void setMetaLocation(ZooKeeperWatcher zookeeper,
+ public static void setMetaLocation(ZKWatcher zookeeper,
ServerName serverName, int replicaId, RegionState.State state) throws KeeperException {
if (serverName == null) {
LOG.warn("Tried to set null ServerName in hbase:meta; skipping -- ServerName required");
@@ -470,7 +470,7 @@ public class MetaTableLocator {
/**
* Load the meta region state from the meta server ZNode.
*/
- public static RegionState getMetaRegionState(ZooKeeperWatcher zkw) throws KeeperException {
+ public static RegionState getMetaRegionState(ZKWatcher zkw) throws KeeperException {
return getMetaRegionState(zkw, RegionInfo.DEFAULT_REPLICA_ID);
}
@@ -481,7 +481,7 @@ public class MetaTableLocator {
* @return regionstate
* @throws KeeperException
*/
- public static RegionState getMetaRegionState(ZooKeeperWatcher zkw, int replicaId)
+ public static RegionState getMetaRegionState(ZKWatcher zkw, int replicaId)
throws KeeperException {
RegionState.State state = RegionState.State.OPEN;
ServerName serverName = null;
@@ -524,12 +524,12 @@ public class MetaTableLocator {
* @param zookeeper zookeeper reference
* @throws KeeperException unexpected zookeeper exception
*/
- public void deleteMetaLocation(ZooKeeperWatcher zookeeper)
+ public void deleteMetaLocation(ZKWatcher zookeeper)
throws KeeperException {
deleteMetaLocation(zookeeper, RegionInfo.DEFAULT_REPLICA_ID);
}
- public void deleteMetaLocation(ZooKeeperWatcher zookeeper, int replicaId)
+ public void deleteMetaLocation(ZKWatcher zookeeper, int replicaId)
throws KeeperException {
if (replicaId == RegionInfo.DEFAULT_REPLICA_ID) {
LOG.info("Deleting hbase:meta region location in ZooKeeper");
@@ -552,7 +552,7 @@ public class MetaTableLocator {
* @return ServerName or null if we timed out.
* @throws InterruptedException
*/
- public List blockUntilAvailable(final ZooKeeperWatcher zkw,
+ public List blockUntilAvailable(final ZKWatcher zkw,
final long timeout, Configuration conf)
throws InterruptedException {
int numReplicasConfigured = 1;
@@ -584,7 +584,7 @@ public class MetaTableLocator {
* @return ServerName or null if we timed out.
* @throws InterruptedException
*/
- public ServerName blockUntilAvailable(final ZooKeeperWatcher zkw,
+ public ServerName blockUntilAvailable(final ZKWatcher zkw,
final long timeout)
throws InterruptedException {
return blockUntilAvailable(zkw, RegionInfo.DEFAULT_REPLICA_ID, timeout);
@@ -598,8 +598,8 @@ public class MetaTableLocator {
* @return ServerName or null if we timed out.
* @throws InterruptedException
*/
- public ServerName blockUntilAvailable(final ZooKeeperWatcher zkw, int replicaId,
- final long timeout)
+ public ServerName blockUntilAvailable(final ZKWatcher zkw, int replicaId,
+ final long timeout)
throws InterruptedException {
if (timeout < 0) throw new IllegalArgumentException();
if (zkw == null) throw new IllegalArgumentException();
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java
similarity index 100%
rename from hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/PendingWatcher.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/PendingWatcher.java
similarity index 100%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/PendingWatcher.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/PendingWatcher.java
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java
similarity index 97%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java
index 04f709f92d3..d6c11af7576 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java
@@ -1,4 +1,4 @@
-/**
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,9 +18,6 @@
*/
package org.apache.hadoop.hbase.zookeeper;
-import static org.apache.hadoop.hbase.zookeeper.ZKMetadata.appendMetaData;
-import static org.apache.hadoop.hbase.zookeeper.ZKMetadata.removeMetaData;
-
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
@@ -36,7 +33,6 @@ import org.apache.hadoop.hbase.util.RetryCounterFactory;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.trace.TraceUtil;
import org.apache.htrace.core.TraceScope;
-import org.apache.yetus.audience.InterfaceAudience;
import org.apache.zookeeper.AsyncCallback;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
@@ -86,7 +82,7 @@ public class RecoverableZooKeeper {
private Watcher watcher;
private int sessionTimeout;
private String quorumServers;
- private final ZooKeeperMetricsListener metrics;
+ private final ZKMetricsListener metrics;
public RecoverableZooKeeper(String quorumServers, int sessionTimeout,
Watcher watcher, int maxRetries, int retryIntervalMillis, int maxSleepTime)
@@ -116,7 +112,7 @@ public class RecoverableZooKeeper {
this.watcher = watcher;
this.sessionTimeout = sessionTimeout;
this.quorumServers = quorumServers;
- this.metrics = new MetricsZooKeeper();
+ this.metrics = new ZKMetrics();
try {checkZk();} catch (Exception x) {/* ignore */}
}
@@ -360,7 +356,7 @@ public class RecoverableZooKeeper {
long startTime = EnvironmentEdgeManager.currentTime();
byte[] revData = checkZk().getData(path, watcher, stat);
this.metrics.registerReadOperationLatency(Math.min(EnvironmentEdgeManager.currentTime() - startTime, 1));
- return removeMetaData(revData);
+ return ZKMetadata.removeMetaData(revData);
} catch (KeeperException e) {
this.metrics.registerFailedZKCall();
switch (e.code()) {
@@ -395,7 +391,7 @@ public class RecoverableZooKeeper {
long startTime = EnvironmentEdgeManager.currentTime();
byte[] revData = checkZk().getData(path, watch, stat);
this.metrics.registerReadOperationLatency(Math.min(EnvironmentEdgeManager.currentTime() - startTime, 1));
- return removeMetaData(revData);
+ return ZKMetadata.removeMetaData(revData);
} catch (KeeperException e) {
this.metrics.registerFailedZKCall();
switch (e.code()) {
@@ -427,7 +423,7 @@ public class RecoverableZooKeeper {
throws KeeperException, InterruptedException {
try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.setData")) {
RetryCounter retryCounter = retryCounterFactory.create();
- byte[] newData = appendMetaData(id, data);
+ byte[] newData = ZKMetadata.appendMetaData(id, data);
boolean isRetry = false;
long startTime;
while (true) {
@@ -565,7 +561,7 @@ public class RecoverableZooKeeper {
CreateMode createMode)
throws KeeperException, InterruptedException {
try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.create")) {
- byte[] newData = appendMetaData(id, data);
+ byte[] newData = ZKMetadata.appendMetaData(id, data);
switch (createMode) {
case EPHEMERAL:
case PERSISTENT:
@@ -686,14 +682,14 @@ public class RecoverableZooKeeper {
for (Op op : ops) {
if (op.getType() == ZooDefs.OpCode.create) {
CreateRequest create = (CreateRequest)op.toRequestRecord();
- preparedOps.add(Op.create(create.getPath(), appendMetaData(id, create.getData()),
+ preparedOps.add(Op.create(create.getPath(), ZKMetadata.appendMetaData(id, create.getData()),
create.getAcl(), create.getFlags()));
} else if (op.getType() == ZooDefs.OpCode.delete) {
// no need to appendMetaData for delete
preparedOps.add(op);
} else if (op.getType() == ZooDefs.OpCode.setData) {
SetDataRequest setData = (SetDataRequest)op.toRequestRecord();
- preparedOps.add(Op.setData(setData.getPath(), appendMetaData(id, setData.getData()),
+ preparedOps.add(Op.setData(setData.getPath(), ZKMetadata.appendMetaData(id, setData.getData()),
setData.getVersion()));
} else {
throw new UnsupportedOperationException("Unexpected ZKOp type: " + op.getClass().getName());
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionNormalizerTracker.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionNormalizerTracker.java
similarity index 96%
rename from hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionNormalizerTracker.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionNormalizerTracker.java
index a9939347c7a..93545ee74fc 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionNormalizerTracker.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionNormalizerTracker.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -32,10 +32,10 @@ import java.io.IOException;
/**
* Tracks region normalizer state up in ZK
*/
-public class RegionNormalizerTracker extends ZooKeeperNodeTracker {
+public class RegionNormalizerTracker extends ZKNodeTracker {
private static final Log LOG = LogFactory.getLog(RegionNormalizerTracker.class);
- public RegionNormalizerTracker(ZooKeeperWatcher watcher,
+ public RegionNormalizerTracker(ZKWatcher watcher,
Abortable abortable) {
super(watcher, watcher.znodePaths.regionNormalizerZNode, abortable);
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZkAclReset.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAclReset.java
similarity index 91%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZkAclReset.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAclReset.java
index 045fd973361..4150f5483fa 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZkAclReset.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAclReset.java
@@ -1,4 +1,4 @@
-/**
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -43,11 +43,11 @@ import org.apache.zookeeper.ZooKeeper;
* Use -set-acls to set the ACLs, no option to erase ACLs
*/
@InterfaceAudience.Private
-public class ZkAclReset extends Configured implements Tool {
- private static final Log LOG = LogFactory.getLog(ZkAclReset.class);
+public class ZKAclReset extends Configured implements Tool {
+ private static final Log LOG = LogFactory.getLog(ZKAclReset.class);
- private static void resetAcls(final ZooKeeperWatcher zkw, final String znode,
- final boolean eraseAcls) throws Exception {
+ private static void resetAcls(final ZKWatcher zkw, final String znode,
+ final boolean eraseAcls) throws Exception {
List children = ZKUtil.listChildrenNoWatch(zkw, znode);
if (children != null) {
for (String child: children) {
@@ -67,7 +67,7 @@ public class ZkAclReset extends Configured implements Tool {
private static void resetAcls(final Configuration conf, boolean eraseAcls)
throws Exception {
- ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf, "ZkAclReset", null);
+ ZKWatcher zkw = new ZKWatcher(conf, "ZKAclReset", null);
try {
LOG.info((eraseAcls ? "Erase" : "Set") + " HBase ACLs for " +
zkw.getQuorum() + " " + zkw.znodePaths.baseZNode);
@@ -111,6 +111,6 @@ public class ZkAclReset extends Configured implements Tool {
}
public static void main(String[] args) throws Exception {
- System.exit(ToolRunner.run(HBaseConfiguration.create(), new ZkAclReset(), args));
+ System.exit(ToolRunner.run(HBaseConfiguration.create(), new ZKAclReset(), args));
}
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKClusterId.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKClusterId.java
similarity index 89%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKClusterId.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKClusterId.java
index 9ef76918066..2f2b0364985 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKClusterId.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKClusterId.java
@@ -35,11 +35,11 @@ import org.apache.zookeeper.KeeperException;
*/
@InterfaceAudience.Private
public class ZKClusterId {
- private ZooKeeperWatcher watcher;
+ private ZKWatcher watcher;
private Abortable abortable;
private String id;
- public ZKClusterId(ZooKeeperWatcher watcher, Abortable abortable) {
+ public ZKClusterId(ZKWatcher watcher, Abortable abortable) {
this.watcher = watcher;
this.abortable = abortable;
}
@@ -60,7 +60,7 @@ public class ZKClusterId {
return id;
}
- public static String readClusterIdZNode(ZooKeeperWatcher watcher)
+ public static String readClusterIdZNode(ZKWatcher watcher)
throws KeeperException {
if (ZKUtil.checkExists(watcher, watcher.znodePaths.clusterIdZNode) != -1) {
byte [] data;
@@ -81,7 +81,7 @@ public class ZKClusterId {
return null;
}
- public static void setClusterId(ZooKeeperWatcher watcher, ClusterId id)
+ public static void setClusterId(ZKWatcher watcher, ClusterId id)
throws KeeperException {
ZKUtil.createSetData(watcher, watcher.znodePaths.clusterIdZNode, id.toByteArray());
}
@@ -92,7 +92,7 @@ public class ZKClusterId {
* @return the UUID read from zookeeper
* @throws KeeperException
*/
- public static UUID getUUIDForCluster(ZooKeeperWatcher zkw) throws KeeperException {
+ public static UUID getUUIDForCluster(ZKWatcher zkw) throws KeeperException {
String uuid = readClusterIdZNode(zkw);
return uuid == null ? null : UUID.fromString(uuid);
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKLeaderManager.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKLeaderManager.java
similarity index 97%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKLeaderManager.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKLeaderManager.java
index b0610b01ea9..edd2ccdff3b 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKLeaderManager.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKLeaderManager.java
@@ -40,7 +40,7 @@ import org.apache.zookeeper.KeeperException;
*/
@Deprecated
@InterfaceAudience.Private
-public class ZKLeaderManager extends ZooKeeperListener {
+public class ZKLeaderManager extends ZKListener {
private static final Log LOG = LogFactory.getLog(ZKLeaderManager.class);
private final AtomicBoolean leaderExists = new AtomicBoolean();
@@ -48,8 +48,8 @@ public class ZKLeaderManager extends ZooKeeperListener {
private byte[] nodeId;
private Stoppable candidate;
- public ZKLeaderManager(ZooKeeperWatcher watcher, String leaderZNode,
- byte[] identifier, Stoppable candidate) {
+ public ZKLeaderManager(ZKWatcher watcher, String leaderZNode,
+ byte[] identifier, Stoppable candidate) {
super(watcher);
this.leaderZNode = leaderZNode;
this.nodeId = identifier;
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperListener.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKListener.java
similarity index 88%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperListener.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKListener.java
index f78f1d8ad45..595e7130426 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperListener.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKListener.java
@@ -1,5 +1,4 @@
-/**
- *
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -23,9 +22,9 @@ import org.apache.yetus.audience.InterfaceAudience;
/**
* Base class for internal listeners of ZooKeeper events.
*
- * The {@link ZooKeeperWatcher} for a process will execute the appropriate
+ * The {@link ZKWatcher} for a process will execute the appropriate
* methods of implementations of this class. In order to receive events from
- * the watcher, every listener must register itself via {@link ZooKeeperWatcher#registerListener}.
+ * the watcher, every listener must register itself via {@link ZKWatcher#registerListener}.
*
* Subclasses need only override those methods in which they are interested.
*
@@ -33,15 +32,15 @@ import org.apache.yetus.audience.InterfaceAudience;
* they must not be long-running.
*/
@InterfaceAudience.Private
-public abstract class ZooKeeperListener {
+public abstract class ZKListener {
// Reference to the zk watcher which also contains configuration and constants
- protected ZooKeeperWatcher watcher;
+ protected ZKWatcher watcher;
/**
* Construct a ZooKeeper event listener.
*/
- public ZooKeeperListener(ZooKeeperWatcher watcher) {
+ public ZKListener(ZKWatcher watcher) {
this.watcher = watcher;
}
@@ -80,7 +79,7 @@ public abstract class ZooKeeperListener {
/**
* @return The watcher associated with this listener
*/
- public ZooKeeperWatcher getWatcher() {
+ public ZKWatcher getWatcher() {
return this.watcher;
}
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMainServer.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKMainServer.java
similarity index 97%
rename from hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMainServer.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKMainServer.java
index 341fbbdfa82..9cb0e7d28da 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMainServer.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKMainServer.java
@@ -1,4 +1,4 @@
-/**
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -35,7 +35,7 @@ import org.apache.zookeeper.ZooKeeperMain;
* from HBase XML configuration.
*/
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.TOOLS)
-public class ZooKeeperMainServer {
+public class ZKMainServer {
private static final String SERVER_ARG = "-server";
public String parse(final Configuration c) {
@@ -104,7 +104,7 @@ public class ZooKeeperMainServer {
if (!hasServer(args)) {
// Add the zk ensemble from configuration if none passed on command-line.
Configuration conf = HBaseConfiguration.create();
- String hostport = new ZooKeeperMainServer().parse(conf);
+ String hostport = new ZKMainServer().parse(conf);
if (hostport != null && hostport.length() > 0) {
newArgs = new String[args.length + 2];
System.arraycopy(args, 0, newArgs, 2, args.length);
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetricsZooKeeper.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKMetrics.java
similarity index 90%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetricsZooKeeper.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKMetrics.java
index 5632031c0d8..20d4a5549c1 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetricsZooKeeper.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKMetrics.java
@@ -1,4 +1,4 @@
-/**
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -23,23 +23,21 @@ import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.shaded.com.google.common.annotations.VisibleForTesting;
-import org.apache.hadoop.hbase.regionserver.wal.MetricsWALSource;
-import org.apache.hadoop.hbase.regionserver.wal.MetricsWALSourceImpl;
/**
* Class used to push numbers about ZooKeeper into the metrics subsystem. This will take a
* single function call and turn it into multiple manipulations of the hadoop metrics system.
*/
@InterfaceAudience.Private
-public class MetricsZooKeeper implements ZooKeeperMetricsListener {
+public class ZKMetrics implements ZKMetricsListener {
private final MetricsZooKeeperSource source;
- public MetricsZooKeeper() {
+ public ZKMetrics() {
this(CompatibilitySingletonFactory.getInstance(MetricsZooKeeperSource.class));
}
@VisibleForTesting
- public MetricsZooKeeper(MetricsZooKeeperSource s) {
+ public ZKMetrics(MetricsZooKeeperSource s) {
this.source = s;
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMetricsListener.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKMetricsListener.java
similarity index 98%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMetricsListener.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKMetricsListener.java
index 12ce2cfca5f..f17925ef281 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMetricsListener.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKMetricsListener.java
@@ -22,7 +22,7 @@ package org.apache.hadoop.hbase.zookeeper;
import org.apache.yetus.audience.InterfaceAudience;
@InterfaceAudience.Private
-public interface ZooKeeperMetricsListener {
+public interface ZKMetricsListener {
/**
* An AUTHFAILED Exception was seen.
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperNodeTracker.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKNodeTracker.java
similarity index 95%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperNodeTracker.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKNodeTracker.java
index a5b084b0019..8ce41e3a508 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperNodeTracker.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKNodeTracker.java
@@ -1,4 +1,4 @@
-/**
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -27,16 +27,16 @@ import org.apache.zookeeper.KeeperException;
/**
* Tracks the availability and value of a single ZooKeeper node.
*
- * Utilizes the {@link ZooKeeperListener} interface to get the necessary
+ *
Utilizes the {@link ZKListener} interface to get the necessary
* ZooKeeper events related to the node.
*
*
This is the base class used by trackers in both the Master and
* RegionServers.
*/
@InterfaceAudience.Private
-public abstract class ZooKeeperNodeTracker extends ZooKeeperListener {
+public abstract class ZKNodeTracker extends ZKListener {
// LOG is being used in subclasses, hence keeping it protected
- protected static final Log LOG = LogFactory.getLog(ZooKeeperNodeTracker.class);
+ protected static final Log LOG = LogFactory.getLog(ZKNodeTracker.class);
/** Path of node being tracked */
protected final String node;
@@ -57,8 +57,8 @@ public abstract class ZooKeeperNodeTracker extends ZooKeeperListener {
* @param node
* @param abortable
*/
- public ZooKeeperNodeTracker(ZooKeeperWatcher watcher, String node,
- Abortable abortable) {
+ public ZKNodeTracker(ZKWatcher watcher, String node,
+ Abortable abortable) {
super(watcher);
this.node = node;
this.abortable = abortable;
@@ -223,7 +223,7 @@ public abstract class ZooKeeperNodeTracker extends ZooKeeperListener {
nodeCreated(path);
}
}
-
+
/**
* Checks if the baseznode set as per the property 'zookeeper.znode.parent'
* exists.
@@ -245,7 +245,7 @@ public abstract class ZooKeeperNodeTracker extends ZooKeeperListener {
@Override
public String toString() {
- return "ZooKeeperNodeTracker{" +
+ return "ZKNodeTracker{" +
"node='" + node + ", stopped=" + stopped + '}';
}
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKServerTool.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKServerTool.java
similarity index 99%
rename from hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKServerTool.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKServerTool.java
index 70e58f8712b..8116c2366f2 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKServerTool.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKServerTool.java
@@ -1,4 +1,4 @@
-/**
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKSplitLog.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKSplitLog.java
similarity index 89%
rename from hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKSplitLog.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKSplitLog.java
index 1376ba9101a..33cc43eab1f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKSplitLog.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKSplitLog.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -30,9 +30,7 @@ import org.apache.hadoop.hbase.HConstants;
import org.apache.yetus.audience.InterfaceAudience;
/**
- * Common methods and attributes used by {@link org.apache.hadoop.hbase.master.SplitLogManager}
- * and {@link org.apache.hadoop.hbase.regionserver.SplitLogWorker}
- * running distributed splitting of WAL logs.
+ * Common methods and attributes used by SplitLogManager and SplitLogWorker running distributed splitting of WAL logs.
*/
@InterfaceAudience.Private
public class ZKSplitLog {
@@ -44,7 +42,7 @@ public class ZKSplitLog {
* @param zkw zk reference
* @param filename log file name (only the basename)
*/
- public static String getEncodedNodeName(ZooKeeperWatcher zkw, String filename) {
+ public static String getEncodedNodeName(ZKWatcher zkw, String filename) {
return ZNodePaths.joinZNode(zkw.znodePaths.splitLogZNode, encode(filename));
}
@@ -69,7 +67,7 @@ public class ZKSplitLog {
}
}
- public static String getRescanNode(ZooKeeperWatcher zkw) {
+ public static String getRescanNode(ZKWatcher zkw) {
return ZNodePaths.joinZNode(zkw.znodePaths.splitLogZNode, "RESCAN");
}
@@ -86,7 +84,7 @@ public class ZKSplitLog {
* @param path the absolute path, starts with '/'
* @return whether the path represents a rescan node
*/
- public static boolean isRescanNode(ZooKeeperWatcher zkw, String path) {
+ public static boolean isRescanNode(ZKWatcher zkw, String path) {
String prefix = getRescanNode(zkw);
if (path.length() <= prefix.length()) {
return false;
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
similarity index 93%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
index 61a5a4290b1..d8472a9441f 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
@@ -1,4 +1,4 @@
-/**
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -333,7 +333,7 @@ public class ZKUtil {
* @return true if znode exists, false if does not exist or error
* @throws KeeperException if unexpected zookeeper exception
*/
- public static boolean watchAndCheckExists(ZooKeeperWatcher zkw, String znode)
+ public static boolean watchAndCheckExists(ZKWatcher zkw, String znode)
throws KeeperException {
try {
Stat s = zkw.getRecoverableZooKeeper().exists(znode, zkw);
@@ -365,7 +365,7 @@ public class ZKUtil {
* @return true if the watch is set, false if node does not exists
* @throws KeeperException if unexpected zookeeper exception
*/
- public static boolean setWatchIfNodeExists(ZooKeeperWatcher zkw, String znode)
+ public static boolean setWatchIfNodeExists(ZKWatcher zkw, String znode)
throws KeeperException {
try {
zkw.getRecoverableZooKeeper().getData(znode, true, null);
@@ -387,7 +387,7 @@ public class ZKUtil {
* @return version of the node if it exists, -1 if does not exist
* @throws KeeperException if unexpected zookeeper exception
*/
- public static int checkExists(ZooKeeperWatcher zkw, String znode)
+ public static int checkExists(ZKWatcher zkw, String znode)
throws KeeperException {
try {
Stat s = zkw.getRecoverableZooKeeper().exists(znode, null);
@@ -424,7 +424,7 @@ public class ZKUtil {
* @throws KeeperException if unexpected zookeeper exception
*/
public static List listChildrenAndWatchForNewChildren(
- ZooKeeperWatcher zkw, String znode)
+ ZKWatcher zkw, String znode)
throws KeeperException {
try {
List children = zkw.getRecoverableZooKeeper().getChildren(znode, zkw);
@@ -453,7 +453,7 @@ public class ZKUtil {
* @return list of znode names, null if the node doesn't exist
* @throws KeeperException
*/
- public static List listChildrenAndWatchThem(ZooKeeperWatcher zkw,
+ public static List listChildrenAndWatchThem(ZKWatcher zkw,
String znode) throws KeeperException {
List children = listChildrenAndWatchForNewChildren(zkw, znode);
if (children == null) {
@@ -479,7 +479,7 @@ public class ZKUtil {
* null if parent does not exist
* @throws KeeperException if unexpected zookeeper exception
*/
- public static List listChildrenNoWatch(ZooKeeperWatcher zkw, String znode)
+ public static List listChildrenNoWatch(ZKWatcher zkw, String znode)
throws KeeperException {
List children = null;
try {
@@ -536,7 +536,7 @@ public class ZKUtil {
* @return true if node has children, false if not or node does not exist
* @throws KeeperException if unexpected zookeeper exception
*/
- public static boolean nodeHasChildren(ZooKeeperWatcher zkw, String znode)
+ public static boolean nodeHasChildren(ZKWatcher zkw, String znode)
throws KeeperException {
try {
return !zkw.getRecoverableZooKeeper().getChildren(znode, null).isEmpty();
@@ -568,7 +568,7 @@ public class ZKUtil {
* exist
* @throws KeeperException if unexpected zookeeper exception
*/
- public static int getNumberOfChildren(ZooKeeperWatcher zkw, String znode)
+ public static int getNumberOfChildren(ZKWatcher zkw, String znode)
throws KeeperException {
try {
Stat stat = zkw.getRecoverableZooKeeper().exists(znode, null);
@@ -591,7 +591,7 @@ public class ZKUtil {
* @return ZNode data, null if the node does not exist or if there is an
* error.
*/
- public static byte [] getData(ZooKeeperWatcher zkw, String znode)
+ public static byte [] getData(ZKWatcher zkw, String znode)
throws KeeperException, InterruptedException {
try {
byte [] data = zkw.getRecoverableZooKeeper().getData(znode, null, null);
@@ -619,7 +619,7 @@ public class ZKUtil {
* @return data of the specified znode, or null
* @throws KeeperException if unexpected zookeeper exception
*/
- public static byte [] getDataAndWatch(ZooKeeperWatcher zkw, String znode)
+ public static byte [] getDataAndWatch(ZKWatcher zkw, String znode)
throws KeeperException {
return getDataInternal(zkw, znode, null, true);
}
@@ -636,13 +636,13 @@ public class ZKUtil {
* @return data of the specified znode, or null
* @throws KeeperException if unexpected zookeeper exception
*/
- public static byte[] getDataAndWatch(ZooKeeperWatcher zkw, String znode,
- Stat stat) throws KeeperException {
+ public static byte[] getDataAndWatch(ZKWatcher zkw, String znode,
+ Stat stat) throws KeeperException {
return getDataInternal(zkw, znode, stat, true);
}
- private static byte[] getDataInternal(ZooKeeperWatcher zkw, String znode, Stat stat,
- boolean watcherSet)
+ private static byte[] getDataInternal(ZKWatcher zkw, String znode, Stat stat,
+ boolean watcherSet)
throws KeeperException {
try {
byte [] data = zkw.getRecoverableZooKeeper().getData(znode, zkw, stat);
@@ -680,8 +680,8 @@ public class ZKUtil {
* @return data of the specified znode, or null if node does not exist
* @throws KeeperException if unexpected zookeeper exception
*/
- public static byte [] getDataNoWatch(ZooKeeperWatcher zkw, String znode,
- Stat stat)
+ public static byte [] getDataNoWatch(ZKWatcher zkw, String znode,
+ Stat stat)
throws KeeperException {
try {
byte [] data = zkw.getRecoverableZooKeeper().getData(znode, null, stat);
@@ -721,7 +721,7 @@ public class ZKUtil {
*/
@Deprecated
public static List getChildDataAndWatchForNewChildren(
- ZooKeeperWatcher zkw, String baseNode) throws KeeperException {
+ ZKWatcher zkw, String baseNode) throws KeeperException {
List nodes =
ZKUtil.listChildrenAndWatchForNewChildren(zkw, baseNode);
if (nodes != null) {
@@ -753,8 +753,8 @@ public class ZKUtil {
* @deprecated Unused
*/
@Deprecated
- public static void updateExistingNodeData(ZooKeeperWatcher zkw, String znode,
- byte [] data, int expectedVersion)
+ public static void updateExistingNodeData(ZKWatcher zkw, String znode,
+ byte [] data, int expectedVersion)
throws KeeperException {
try {
zkw.getRecoverableZooKeeper().setData(znode, data, expectedVersion);
@@ -787,8 +787,8 @@ public class ZKUtil {
* @return true if data set, false if version mismatch
* @throws KeeperException if unexpected zookeeper exception
*/
- public static boolean setData(ZooKeeperWatcher zkw, String znode,
- byte [] data, int expectedVersion)
+ public static boolean setData(ZKWatcher zkw, String znode,
+ byte [] data, int expectedVersion)
throws KeeperException, KeeperException.NoNodeException {
try {
return zkw.getRecoverableZooKeeper().setData(znode, data, expectedVersion) != null;
@@ -807,8 +807,8 @@ public class ZKUtil {
* @param data data to set for node
* @throws KeeperException
*/
- public static void createSetData(final ZooKeeperWatcher zkw, final String znode,
- final byte [] data)
+ public static void createSetData(final ZKWatcher zkw, final String znode,
+ final byte [] data)
throws KeeperException {
if (checkExists(zkw, znode) == -1) {
ZKUtil.createWithParents(zkw, znode, data);
@@ -833,12 +833,12 @@ public class ZKUtil {
* @param data data to set for node
* @throws KeeperException if unexpected zookeeper exception
*/
- public static void setData(ZooKeeperWatcher zkw, String znode, byte [] data)
+ public static void setData(ZKWatcher zkw, String znode, byte [] data)
throws KeeperException, KeeperException.NoNodeException {
setData(zkw, (SetData)ZKUtilOp.setData(znode, data));
}
- private static void setData(ZooKeeperWatcher zkw, SetData setData)
+ private static void setData(ZKWatcher zkw, SetData setData)
throws KeeperException, KeeperException.NoNodeException {
SetDataRequest sd = (SetDataRequest)toZooKeeperOp(zkw, setData).toRequestRecord();
setData(zkw, sd.getPath(), sd.getData(), sd.getVersion());
@@ -874,12 +874,12 @@ public class ZKUtil {
return "kerberos".equalsIgnoreCase(conf.get("hbase.security.authentication"));
}
- private static ArrayList createACL(ZooKeeperWatcher zkw, String node) {
+ private static ArrayList createACL(ZKWatcher zkw, String node) {
return createACL(zkw, node, isSecureZooKeeper(zkw.getConfiguration()));
}
- public static ArrayList createACL(ZooKeeperWatcher zkw, String node,
- boolean isSecureZooKeeper) {
+ public static ArrayList createACL(ZKWatcher zkw, String node,
+ boolean isSecureZooKeeper) {
if (!node.startsWith(zkw.znodePaths.baseZNode)) {
return Ids.OPEN_ACL_UNSAFE;
}
@@ -946,7 +946,7 @@ public class ZKUtil {
* @return true if node created, false if not, watch set in both cases
* @throws KeeperException if unexpected zookeeper exception
*/
- public static boolean createEphemeralNodeAndWatch(ZooKeeperWatcher zkw,
+ public static boolean createEphemeralNodeAndWatch(ZKWatcher zkw,
String znode, byte [] data)
throws KeeperException {
boolean ret = true;
@@ -987,7 +987,7 @@ public class ZKUtil {
* @throws KeeperException if unexpected zookeeper exception
*/
public static boolean createNodeIfNotExistsAndWatch(
- ZooKeeperWatcher zkw, String znode, byte [] data)
+ ZKWatcher zkw, String znode, byte [] data)
throws KeeperException {
boolean ret = true;
try {
@@ -1022,8 +1022,8 @@ public class ZKUtil {
* @return true name of the newly created znode or null
* @throws KeeperException if unexpected zookeeper exception
*/
- public static String createNodeIfNotExistsNoWatch(ZooKeeperWatcher zkw, String znode,
- byte[] data, CreateMode createMode) throws KeeperException {
+ public static String createNodeIfNotExistsNoWatch(ZKWatcher zkw, String znode,
+ byte[] data, CreateMode createMode) throws KeeperException {
String createdZNode = null;
try {
@@ -1054,7 +1054,7 @@ public class ZKUtil {
* @throws KeeperException if unexpected zookeeper exception
* @throws KeeperException.NodeExistsException if node already exists
*/
- public static int createAndWatch(ZooKeeperWatcher zkw,
+ public static int createAndWatch(ZKWatcher zkw,
String znode, byte [] data)
throws KeeperException, KeeperException.NodeExistsException {
try {
@@ -1086,7 +1086,7 @@ public class ZKUtil {
* @param cb
* @param ctx
*/
- public static void asyncCreate(ZooKeeperWatcher zkw,
+ public static void asyncCreate(ZKWatcher zkw,
String znode, byte [] data, final AsyncCallback.StringCallback cb,
final Object ctx) {
zkw.getRecoverableZooKeeper().getZooKeeper().create(znode, data,
@@ -1103,7 +1103,7 @@ public class ZKUtil {
* @param znode path of node
* @throws KeeperException if unexpected zookeeper exception
*/
- public static void createAndFailSilent(ZooKeeperWatcher zkw,
+ public static void createAndFailSilent(ZKWatcher zkw,
String znode) throws KeeperException {
createAndFailSilent(zkw, znode, new byte[0]);
}
@@ -1119,14 +1119,14 @@ public class ZKUtil {
* @param data a byte array data to store in the znode
* @throws KeeperException if unexpected zookeeper exception
*/
- public static void createAndFailSilent(ZooKeeperWatcher zkw,
+ public static void createAndFailSilent(ZKWatcher zkw,
String znode, byte[] data)
throws KeeperException {
createAndFailSilent(zkw,
(CreateAndFailSilent)ZKUtilOp.createAndFailSilent(znode, data));
}
- private static void createAndFailSilent(ZooKeeperWatcher zkw, CreateAndFailSilent cafs)
+ private static void createAndFailSilent(ZKWatcher zkw, CreateAndFailSilent cafs)
throws KeeperException {
CreateRequest create = (CreateRequest)toZooKeeperOp(zkw, cafs).toRequestRecord();
String znode = create.getPath();
@@ -1161,7 +1161,7 @@ public class ZKUtil {
* @param znode path of node
* @throws KeeperException if unexpected zookeeper exception
*/
- public static void createWithParents(ZooKeeperWatcher zkw, String znode)
+ public static void createWithParents(ZKWatcher zkw, String znode)
throws KeeperException {
createWithParents(zkw, znode, new byte[0]);
}
@@ -1179,7 +1179,7 @@ public class ZKUtil {
* @param znode path of node
* @throws KeeperException if unexpected zookeeper exception
*/
- public static void createWithParents(ZooKeeperWatcher zkw, String znode, byte[] data)
+ public static void createWithParents(ZKWatcher zkw, String znode, byte[] data)
throws KeeperException {
try {
if(znode == null) {
@@ -1204,7 +1204,7 @@ public class ZKUtil {
/**
* Delete the specified node. Sets no watches. Throws all exceptions.
*/
- public static void deleteNode(ZooKeeperWatcher zkw, String node)
+ public static void deleteNode(ZKWatcher zkw, String node)
throws KeeperException {
deleteNode(zkw, node, -1);
}
@@ -1213,8 +1213,8 @@ public class ZKUtil {
* Delete the specified node with the specified version. Sets no watches.
* Throws all exceptions.
*/
- public static boolean deleteNode(ZooKeeperWatcher zkw, String node,
- int version)
+ public static boolean deleteNode(ZKWatcher zkw, String node,
+ int version)
throws KeeperException {
try {
zkw.getRecoverableZooKeeper().delete(node, version);
@@ -1233,13 +1233,13 @@ public class ZKUtil {
* @param node
* @throws KeeperException
*/
- public static void deleteNodeFailSilent(ZooKeeperWatcher zkw, String node)
+ public static void deleteNodeFailSilent(ZKWatcher zkw, String node)
throws KeeperException {
deleteNodeFailSilent(zkw,
(DeleteNodeFailSilent)ZKUtilOp.deleteNodeFailSilent(node));
}
- private static void deleteNodeFailSilent(ZooKeeperWatcher zkw,
+ private static void deleteNodeFailSilent(ZKWatcher zkw,
DeleteNodeFailSilent dnfs) throws KeeperException {
DeleteRequest delete = (DeleteRequest)toZooKeeperOp(zkw, dnfs).toRequestRecord();
try {
@@ -1259,7 +1259,7 @@ public class ZKUtil {
* Sets no watches. Throws all exceptions besides dealing with deletion of
* children.
*/
- public static void deleteNodeRecursively(ZooKeeperWatcher zkw, String node)
+ public static void deleteNodeRecursively(ZKWatcher zkw, String node)
throws KeeperException {
deleteNodeRecursivelyMultiOrSequential(zkw, true, node);
}
@@ -1272,7 +1272,7 @@ public class ZKUtil {
*
* @throws KeeperException
*/
- public static void deleteChildrenRecursively(ZooKeeperWatcher zkw, String node)
+ public static void deleteChildrenRecursively(ZKWatcher zkw, String node)
throws KeeperException {
deleteChildrenRecursivelyMultiOrSequential(zkw, true, node);
}
@@ -1308,8 +1308,8 @@ public class ZKUtil {
* if an invalid path is specified
*/
public static void deleteChildrenRecursivelyMultiOrSequential(
- ZooKeeperWatcher zkw, boolean runSequentialOnMultiFailure,
- String... pathRoots) throws KeeperException {
+ ZKWatcher zkw, boolean runSequentialOnMultiFailure,
+ String... pathRoots) throws KeeperException {
if (pathRoots == null || pathRoots.length <= 0) {
LOG.warn("Given path is not valid!");
return;
@@ -1358,7 +1358,7 @@ public class ZKUtil {
* @throws IllegalArgumentException
* if an invalid path is specified
*/
- public static void deleteNodeRecursivelyMultiOrSequential(ZooKeeperWatcher zkw,
+ public static void deleteNodeRecursivelyMultiOrSequential(ZKWatcher zkw,
boolean runSequentialOnMultiFailure, String... pathRoots) throws KeeperException {
if (pathRoots == null || pathRoots.length <= 0) {
LOG.warn("Given path is not valid!");
@@ -1400,7 +1400,7 @@ public class ZKUtil {
* @throws KeeperException
* if unexpected ZooKeeper exception
*/
- private static List listChildrenBFSNoWatch(ZooKeeperWatcher zkw,
+ private static List listChildrenBFSNoWatch(ZKWatcher zkw,
final String znode) throws KeeperException {
Deque queue = new LinkedList<>();
List tree = new ArrayList<>();
@@ -1436,7 +1436,7 @@ public class ZKUtil {
* @throws KeeperException
* if unexpected ZooKeeper exception
*/
- private static List listChildrenBFSAndWatchThem(ZooKeeperWatcher zkw, final String znode)
+ private static List listChildrenBFSAndWatchThem(ZKWatcher zkw, final String znode)
throws KeeperException {
Deque queue = new LinkedList<>();
List tree = new ArrayList<>();
@@ -1589,7 +1589,7 @@ public class ZKUtil {
/**
* Convert from ZKUtilOp to ZKOp
*/
- private static Op toZooKeeperOp(ZooKeeperWatcher zkw, ZKUtilOp op)
+ private static Op toZooKeeperOp(ZKWatcher zkw, ZKUtilOp op)
throws UnsupportedOperationException {
if(op == null) return null;
@@ -1628,8 +1628,8 @@ public class ZKUtil {
*
* @throws KeeperException
*/
- public static void multiOrSequential(ZooKeeperWatcher zkw, List ops,
- boolean runSequentialOnMultiFailure) throws KeeperException {
+ public static void multiOrSequential(ZKWatcher zkw, List ops,
+ boolean runSequentialOnMultiFailure) throws KeeperException {
if (zkw.getConfiguration().get("hbase.zookeeper.useMulti") != null) {
LOG.warn("hbase.zookeeper.useMulti is deprecated. Default to true always.");
}
@@ -1664,7 +1664,7 @@ public class ZKUtil {
}
}
- private static void processSequentially(ZooKeeperWatcher zkw, List ops)
+ private static void processSequentially(ZKWatcher zkw, List ops)
throws KeeperException, NoNodeException {
for (ZKUtilOp op : ops) {
if (op instanceof CreateAndFailSilent) {
@@ -1685,7 +1685,7 @@ public class ZKUtil {
//
/** @return String dump of everything in ZooKeeper. */
- public static String dump(ZooKeeperWatcher zkw) {
+ public static String dump(ZKWatcher zkw) {
StringBuilder sb = new StringBuilder();
try {
sb.append("HBase is rooted at ").append(zkw.znodePaths.baseZNode);
@@ -1749,7 +1749,7 @@ public class ZKUtil {
* @param sb
* @throws KeeperException
*/
- private static void getReplicationZnodesDump(ZooKeeperWatcher zkw, StringBuilder sb)
+ private static void getReplicationZnodesDump(ZKWatcher zkw, StringBuilder sb)
throws KeeperException {
String replicationZnode = zkw.znodePaths.replicationZNode;
if (ZKUtil.checkExists(zkw, replicationZnode) == -1) return;
@@ -1768,8 +1768,8 @@ public class ZKUtil {
}
}
- private static void appendHFileRefsZnodes(ZooKeeperWatcher zkw, String hfileRefsZnode,
- StringBuilder sb) throws KeeperException {
+ private static void appendHFileRefsZnodes(ZKWatcher zkw, String hfileRefsZnode,
+ StringBuilder sb) throws KeeperException {
sb.append("\n").append(hfileRefsZnode).append(": ");
for (String peerIdZnode : ZKUtil.listChildrenNoWatch(zkw, hfileRefsZnode)) {
String znodeToProcess = ZNodePaths.joinZNode(hfileRefsZnode, peerIdZnode);
@@ -1790,13 +1790,13 @@ public class ZKUtil {
* @param zkw
* @return aq string of replication znodes and log positions
*/
- public static String getReplicationZnodesDump(ZooKeeperWatcher zkw) throws KeeperException {
+ public static String getReplicationZnodesDump(ZKWatcher zkw) throws KeeperException {
StringBuilder sb = new StringBuilder();
getReplicationZnodesDump(zkw, sb);
return sb.toString();
}
- private static void appendRSZnodes(ZooKeeperWatcher zkw, String znode, StringBuilder sb)
+ private static void appendRSZnodes(ZKWatcher zkw, String znode, StringBuilder sb)
throws KeeperException {
List stack = new LinkedList<>();
stack.add(znode);
@@ -1827,8 +1827,8 @@ public class ZKUtil {
} while (stack.size() > 0);
}
- private static void appendPeersZnodes(ZooKeeperWatcher zkw, String peersZnode,
- StringBuilder sb) throws KeeperException {
+ private static void appendPeersZnodes(ZKWatcher zkw, String peersZnode,
+ StringBuilder sb) throws KeeperException {
int pblen = ProtobufUtil.lengthOfPBMagic();
sb.append("\n").append(peersZnode).append(": ");
for (String peerIdZnode : ZKUtil.listChildrenNoWatch(zkw, peersZnode)) {
@@ -1855,8 +1855,8 @@ public class ZKUtil {
}
}
- private static void appendPeerState(ZooKeeperWatcher zkw, String znodeToProcess,
- StringBuilder sb) throws KeeperException, InvalidProtocolBufferException {
+ private static void appendPeerState(ZKWatcher zkw, String znodeToProcess,
+ StringBuilder sb) throws KeeperException, InvalidProtocolBufferException {
String peerState = zkw.getConfiguration().get("zookeeper.znode.replication.peers.state",
"peer-state");
int pblen = ProtobufUtil.lengthOfPBMagic();
@@ -1922,7 +1922,7 @@ public class ZKUtil {
}
}
- private static void logRetrievedMsg(final ZooKeeperWatcher zkw,
+ private static void logRetrievedMsg(final ZKWatcher zkw,
final String znode, final byte [] data, final boolean watcherSet) {
if (!LOG.isTraceEnabled()) return;
LOG.trace(zkw.prefix("Retrieved " + ((data == null)? 0: data.length) +
@@ -2002,7 +2002,7 @@ public class ZKUtil {
* Recursively print the current state of ZK (non-transactional)
* @param root name of the root directory in zk to print
*/
- public static void logZKTree(ZooKeeperWatcher zkw, String root) {
+ public static void logZKTree(ZKWatcher zkw, String root) {
if (!LOG.isDebugEnabled()) return;
LOG.debug("Current zk system:");
String prefix = "|-";
@@ -2016,10 +2016,10 @@ public class ZKUtil {
/**
* Helper method to print the current state of the ZK tree.
- * @see #logZKTree(ZooKeeperWatcher, String)
+ * @see #logZKTree(ZKWatcher, String)
* @throws KeeperException if an unexpected exception occurs
*/
- protected static void logZKTree(ZooKeeperWatcher zkw, String root, String prefix)
+ protected static void logZKTree(ZKWatcher zkw, String root, String prefix)
throws KeeperException {
List children = ZKUtil.listChildrenNoWatch(zkw, root);
if (children == null) return;
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java
similarity index 94%
rename from hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
rename to hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java
index 5d10cdf3351..d0b0081d712 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java
@@ -1,4 +1,4 @@
-/**
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -21,9 +21,7 @@ package org.apache.hadoop.hbase.zookeeper;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.regex.Matcher;
@@ -34,8 +32,6 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Abortable;
import org.apache.hadoop.hbase.AuthUtil;
-import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.security.Superusers;
@@ -61,8 +57,8 @@ import org.apache.zookeeper.data.Stat;
* deal with connection related events and exceptions are handled here.
*/
@InterfaceAudience.Private
-public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
- private static final Log LOG = LogFactory.getLog(ZooKeeperWatcher.class);
+public class ZKWatcher implements Watcher, Abortable, Closeable {
+ private static final Log LOG = LogFactory.getLog(ZKWatcher.class);
// Identifier for this watcher (for logging only). It is made of the prefix
// passed on construction and the zookeeper sessionid.
@@ -83,7 +79,7 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
public final ZNodePaths znodePaths;
// listeners to be notified
- private final List listeners = new CopyOnWriteArrayList<>();
+ private final List listeners = new CopyOnWriteArrayList<>();
// Used by ZKUtil:waitForZKConnectionIfAuthenticating to wait for SASL
// negotiation to complete
@@ -103,8 +99,8 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
* @throws IOException
* @throws ZooKeeperConnectionException
*/
- public ZooKeeperWatcher(Configuration conf, String identifier,
- Abortable abortable) throws ZooKeeperConnectionException, IOException {
+ public ZKWatcher(Configuration conf, String identifier,
+ Abortable abortable) throws ZooKeeperConnectionException, IOException {
this(conf, identifier, abortable, false);
}
@@ -119,8 +115,8 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
* @throws IOException
* @throws ZooKeeperConnectionException
*/
- public ZooKeeperWatcher(Configuration conf, String identifier,
- Abortable abortable, boolean canCreateBaseZNode)
+ public ZKWatcher(Configuration conf, String identifier,
+ Abortable abortable, boolean canCreateBaseZNode)
throws IOException, ZooKeeperConnectionException {
this.conf = conf;
this.quorum = ZKConfig.getZKQuorumServersString(conf);
@@ -386,7 +382,7 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
* Register the specified listener to receive ZooKeeper events.
* @param listener
*/
- public void registerListener(ZooKeeperListener listener) {
+ public void registerListener(ZKListener listener) {
listeners.add(listener);
}
@@ -395,11 +391,11 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
* the first in the list of current listeners.
* @param listener
*/
- public void registerListenerFirst(ZooKeeperListener listener) {
+ public void registerListenerFirst(ZKListener listener) {
listeners.add(0, listener);
}
- public void unregisterListener(ZooKeeperListener listener) {
+ public void unregisterListener(ZKListener listener) {
listeners.remove(listener);
}
@@ -413,7 +409,7 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
/**
* Get a copy of current registered listeners
*/
- public List getListeners() {
+ public List getListeners() {
return new ArrayList<>(listeners);
}
@@ -477,28 +473,28 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
// Otherwise pass along to the listeners
case NodeCreated: {
- for(ZooKeeperListener listener : listeners) {
+ for(ZKListener listener : listeners) {
listener.nodeCreated(event.getPath());
}
break;
}
case NodeDeleted: {
- for(ZooKeeperListener listener : listeners) {
+ for(ZKListener listener : listeners) {
listener.nodeDeleted(event.getPath());
}
break;
}
case NodeDataChanged: {
- for(ZooKeeperListener listener : listeners) {
+ for(ZKListener listener : listeners) {
listener.nodeDataChanged(event.getPath());
}
break;
}
case NodeChildrenChanged: {
- for(ZooKeeperListener listener : listeners) {
+ for(ZKListener listener : listeners) {
listener.nodeChildrenChanged(event.getPath());
}
break;
@@ -535,8 +531,8 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
case Expired:
String msg = prefix(this.identifier + " received expired from " +
"ZooKeeper, aborting");
- // TODO: One thought is to add call to ZooKeeperListener so say,
- // ZooKeeperNodeTracker can zero out its data values.
+ // TODO: One thought is to add call to ZKListener so say,
+ // ZKNodeTracker can zero out its data values.
if (this.abortable != null) {
this.abortable.abort(msg, new KeeperException.SessionExpiredException());
}
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestInstancePending.java b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestInstancePending.java
similarity index 100%
rename from hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestInstancePending.java
rename to hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestInstancePending.java
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestMetricsZooKeeper.java b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMetrics.java
similarity index 92%
rename from hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestMetricsZooKeeper.java
rename to hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMetrics.java
index a987bec6296..2811cc5ee08 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestMetricsZooKeeper.java
+++ b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMetrics.java
@@ -1,4 +1,4 @@
-/**
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,18 +18,21 @@
*/
package org.apache.hadoop.hbase.zookeeper;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.mockito.Mockito.*;
@Category(SmallTests.class)
-public class TestMetricsZooKeeper {
+public class TestZKMetrics {
@Test
public void testRegisterExceptions() {
MetricsZooKeeperSource zkSource = mock(MetricsZooKeeperSourceImpl.class);
- MetricsZooKeeper metricsZK = new MetricsZooKeeper(zkSource);
+ ZKMetrics metricsZK = new ZKMetrics(zkSource);
metricsZK.registerAuthFailedException();
metricsZK.registerConnectionLossException();
metricsZK.registerConnectionLossException();
@@ -62,7 +65,7 @@ public class TestMetricsZooKeeper {
@Test
public void testLatencyHistogramUpdates() {
MetricsZooKeeperSource zkSource = mock(MetricsZooKeeperSourceImpl.class);
- MetricsZooKeeper metricsZK = new MetricsZooKeeper(zkSource);
+ ZKMetrics metricsZK = new ZKMetrics(zkSource);
long latency = 100;
metricsZK.registerReadOperationLatency(latency);
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKUtil.java b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKUtil.java
similarity index 92%
rename from hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKUtil.java
rename to hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKUtil.java
index 6b1e1f0b93e..7006040bc1f 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKUtil.java
+++ b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKUtil.java
@@ -48,7 +48,7 @@ public class TestZKUtil {
Configuration conf = HBaseConfiguration.create();
conf.set(Superusers.SUPERUSER_CONF_KEY, "user1");
String node = "/hbase/testUnsecure";
- ZooKeeperWatcher watcher = new ZooKeeperWatcher(conf, node, null, false);
+ ZKWatcher watcher = new ZKWatcher(conf, node, null, false);
List aclList = ZKUtil.createACL(watcher, node, false);
Assert.assertEquals(aclList.size(), 1);
Assert.assertTrue(aclList.contains(Ids.OPEN_ACL_UNSAFE.iterator().next()));
@@ -59,7 +59,7 @@ public class TestZKUtil {
Configuration conf = HBaseConfiguration.create();
conf.set(Superusers.SUPERUSER_CONF_KEY, "user1");
String node = "/hbase/testSecuritySingleSuperuser";
- ZooKeeperWatcher watcher = new ZooKeeperWatcher(conf, node, null, false);
+ ZKWatcher watcher = new ZKWatcher(conf, node, null, false);
List aclList = ZKUtil.createACL(watcher, node, true);
Assert.assertEquals(aclList.size(), 2); // 1+1, since ACL will be set for the creator by default
Assert.assertTrue(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "user1"))));
@@ -71,7 +71,7 @@ public class TestZKUtil {
Configuration conf = HBaseConfiguration.create();
conf.set(Superusers.SUPERUSER_CONF_KEY, "user1,@group1,user2,@group2,user3");
String node = "/hbase/testCreateACL";
- ZooKeeperWatcher watcher = new ZooKeeperWatcher(conf, node, null, false);
+ ZKWatcher watcher = new ZKWatcher(conf, node, null, false);
List aclList = ZKUtil.createACL(watcher, node, true);
Assert.assertEquals(aclList.size(), 4); // 3+1, since ACL will be set for the creator by default
Assert.assertFalse(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "@group1"))));
@@ -87,7 +87,7 @@ public class TestZKUtil {
conf.set(Superusers.SUPERUSER_CONF_KEY, "user4,@group1,user5,user6");
UserGroupInformation.setLoginUser(UserGroupInformation.createRemoteUser("user4"));
String node = "/hbase/testCreateACL";
- ZooKeeperWatcher watcher = new ZooKeeperWatcher(conf, node, null, false);
+ ZKWatcher watcher = new ZKWatcher(conf, node, null, false);
List aclList = ZKUtil.createACL(watcher, node, true);
Assert.assertEquals(aclList.size(), 3); // 3, since service user the same as one of superuser
Assert.assertFalse(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "@group1"))));
@@ -100,7 +100,7 @@ public class TestZKUtil {
public void testInterruptedDuringAction()
throws ZooKeeperConnectionException, IOException, KeeperException, InterruptedException {
final RecoverableZooKeeper recoverableZk = Mockito.mock(RecoverableZooKeeper.class);
- ZooKeeperWatcher zkw = new ZooKeeperWatcher(HBaseConfiguration.create(), "unittest", null) {
+ ZKWatcher zkw = new ZKWatcher(HBaseConfiguration.create(), "unittest", null) {
@Override
public RecoverableZooKeeper getRecoverableZooKeeper() {
return recoverableZk;
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperWatcher.java b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKWatcher.java
similarity index 93%
rename from hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperWatcher.java
rename to hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKWatcher.java
index 3c99175ad81..bd4575d6dd6 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperWatcher.java
+++ b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKWatcher.java
@@ -28,12 +28,12 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
@Category({ SmallTests.class })
-public class TestZooKeeperWatcher {
+public class TestZKWatcher {
@Test
public void testIsClientReadable() throws IOException {
- ZooKeeperWatcher watcher =
- new ZooKeeperWatcher(HBaseConfiguration.create(), "testIsClientReadable", null, false);
+ ZKWatcher watcher =
+ new ZKWatcher(HBaseConfiguration.create(), "testIsClientReadable", null, false);
assertTrue(watcher.isClientReadable(watcher.znodePaths.baseZNode));
assertTrue(watcher.isClientReadable(watcher.znodePaths.getZNodeForReplica(0)));
diff --git a/pom.xml b/pom.xml
index 2d3fa8c38d4..0e6b5583ca8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,6 +90,7 @@
hbase-metrics-api
hbase-metrics
hbase-backup
+ hbase-zookeeper
@@ -1684,6 +1685,11 @@
org.apache.hbase
${project.version}