From 4c95b82b61f54f364907fd0f21eff4dae098520e Mon Sep 17 00:00:00 2001 From: maoling Date: Tue, 29 May 2018 21:06:38 +0800 Subject: [PATCH] HBASE-19761:Fix Checkstyle errors in hbase-zookeeper Signed-off-by: Jan Hentschel --- .../hbase/IntegrationTestMetaReplicas.java | 2 +- .../IntegrationTestZKAndFSPermissions.java | 4 +- .../replication/ReplicationTrackerZKImpl.java | 7 +- .../replication/ZKReplicationStorageBase.java | 2 +- .../TestReplicationStateZKImpl.java | 5 +- .../hbase/rsgroup/RSGroupInfoManagerImpl.java | 6 +- .../rsgroup/VerifyingRSGroupAdminClient.java | 2 +- .../hadoop/hbase/ZKNamespaceManager.java | 2 +- .../org/apache/hadoop/hbase/ZNodeClearer.java | 2 +- .../backup/example/ZKTableArchiveClient.java | 2 +- .../ZKSplitLogManagerCoordination.java | 12 +-- .../ZkSplitLogWorkerCoordination.java | 20 ++--- .../hbase/master/ActiveMasterManager.java | 18 ++--- .../hbase/master/DrainingServerTracker.java | 8 +- .../apache/hadoop/hbase/master/HMaster.java | 10 +-- .../hbase/master/MasterMetaBootstrap.java | 4 +- .../hbase/master/RegionServerTracker.java | 12 +-- .../hadoop/hbase/master/ServerManager.java | 2 +- .../hbase/master/SplitOrMergeTracker.java | 8 +- .../hbase/master/zksyncer/ClientZKSyncer.java | 2 +- .../master/zksyncer/MasterAddressSyncer.java | 2 +- .../master/zksyncer/MetaLocationSyncer.java | 4 +- .../hbase/procedure/ZKProcedureUtil.java | 2 +- .../hbase/regionserver/HRegionServer.java | 2 +- .../replication/HBaseReplicationEndpoint.java | 5 +- .../master/ReplicationPeerConfigUpgrader.java | 2 +- .../security/access/ZKPermissionWatcher.java | 8 +- .../hbase/security/token/ZKSecretWatcher.java | 2 +- .../visibility/ZKVisibilityLabelWatcher.java | 5 +- .../apache/hadoop/hbase/util/HBaseFsck.java | 4 +- .../hadoop/hbase/util/ZKDataMigrator.java | 5 +- .../hbase/client/TestMetaWithReplicas.java | 4 +- .../hbase/master/TestActiveMasterManager.java | 15 ++-- .../hbase/master/TestHMasterRPCException.java | 5 +- .../hbase/master/TestMasterNoCluster.java | 2 +- .../hbase/master/TestMetaShutdownHandler.java | 3 +- .../TestMirroringTableStateManager.java | 3 +- .../hbase/master/TestSplitLogManager.java | 14 ++-- .../TestMasterAddressTracker.java | 8 +- .../TestRegionServerHostname.java | 4 +- .../regionserver/TestSplitLogWorker.java | 27 +++---- .../TestReplicationTrackerZKImpl.java | 17 +++-- hbase-zookeeper/pom.xml | 7 ++ .../hbase/zookeeper/ClusterStatusTracker.java | 14 ++-- .../hbase/zookeeper/LoadBalancerTracker.java | 10 +-- .../hbase/zookeeper/MasterAddressTracker.java | 14 ++-- .../MasterMaintenanceModeTracker.java | 5 +- .../hbase/zookeeper/MetaTableLocator.java | 27 +++---- .../hbase/zookeeper/RecoverableZooKeeper.java | 22 +++--- .../zookeeper/RegionNormalizerTracker.java | 8 +- .../hadoop/hbase/zookeeper/ZKAclReset.java | 4 +- .../hadoop/hbase/zookeeper/ZKClusterId.java | 8 +- .../hadoop/hbase/zookeeper/ZKMainServer.java | 8 +- .../hadoop/hbase/zookeeper/ZKNodeTracker.java | 6 +- .../hadoop/hbase/zookeeper/ZKSplitLog.java | 4 +- .../apache/hadoop/hbase/zookeeper/ZKUtil.java | 75 ++++++++++--------- .../hadoop/hbase/zookeeper/ZKWatcher.java | 12 +-- .../hbase/zookeeper/TestZKLeaderManager.java | 1 - .../hbase/zookeeper/TestZKMainServer.java | 2 +- .../hadoop/hbase/zookeeper/TestZKMulti.java | 40 +++++----- .../hbase/zookeeper/TestZKNodeTracker.java | 6 +- .../hbase/zookeeper/TestZKUtilNoServer.java | 4 +- 62 files changed, 288 insertions(+), 262 deletions(-) diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestMetaReplicas.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestMetaReplicas.java index 37e26865f39..f14b9a56756 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestMetaReplicas.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestMetaReplicas.java @@ -81,7 +81,7 @@ public class IntegrationTestMetaReplicas { } private static void waitUntilZnodeAvailable(int replicaId) throws Exception { - String znode = util.getZooKeeperWatcher().znodePaths.getZNodeForReplica(replicaId); + String znode = util.getZooKeeperWatcher().getZNodePaths().getZNodeForReplica(replicaId); int i = 0; while (i < 1000) { if (ZKUtil.checkExists(util.getZooKeeperWatcher(), znode) == -1) { diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestZKAndFSPermissions.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestZKAndFSPermissions.java index 31db2fdb2db..08edd74bc1a 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestZKAndFSPermissions.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestZKAndFSPermissions.java @@ -144,7 +144,7 @@ public class IntegrationTestZKAndFSPermissions extends AbstractHBaseTool { ZKWatcher watcher = new ZKWatcher(conf, "IntegrationTestZnodeACLs", null); RecoverableZooKeeper zk = ZKUtil.connect(this.conf, watcher); - String baseZNode = watcher.znodePaths.baseZNode; + String baseZNode = watcher.getZNodePaths().baseZNode; LOG.info(""); LOG.info("***********************************************************************************"); @@ -160,7 +160,7 @@ public class IntegrationTestZKAndFSPermissions extends AbstractHBaseTool { private void checkZnodePermsRecursive(ZKWatcher watcher, RecoverableZooKeeper zk, String znode) throws KeeperException, InterruptedException { - boolean expectedWorldReadable = watcher.znodePaths.isClientReadable(znode); + boolean expectedWorldReadable = watcher.getZNodePaths().isClientReadable(znode); assertZnodePerms(zk, znode, expectedWorldReadable); diff --git a/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ReplicationTrackerZKImpl.java b/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ReplicationTrackerZKImpl.java index 16a1668c9fc..54c9c2cdc0a 100644 --- a/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ReplicationTrackerZKImpl.java +++ b/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ReplicationTrackerZKImpl.java @@ -138,7 +138,7 @@ public class ReplicationTrackerZKImpl implements ReplicationTracker { } private boolean refreshListIfRightPath(String path) { - if (!path.startsWith(this.watcher.znodePaths.rsZNode)) { + if (!path.startsWith(this.watcher.getZNodePaths().rsZNode)) { return false; } return refreshOtherRegionServersList(true); @@ -182,9 +182,10 @@ public class ReplicationTrackerZKImpl implements ReplicationTracker { List result = null; try { if (watch) { - result = ZKUtil.listChildrenAndWatchThem(this.zookeeper, this.zookeeper.znodePaths.rsZNode); + result = ZKUtil.listChildrenAndWatchThem(this.zookeeper, + this.zookeeper.getZNodePaths().rsZNode); } else { - result = ZKUtil.listChildrenNoWatch(this.zookeeper, this.zookeeper.znodePaths.rsZNode); + result = ZKUtil.listChildrenNoWatch(this.zookeeper, this.zookeeper.getZNodePaths().rsZNode); } } catch (KeeperException e) { this.abortable.abort("Get list of registered region servers", e); diff --git a/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ZKReplicationStorageBase.java b/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ZKReplicationStorageBase.java index 7190aeb6795..d6e692aef38 100644 --- a/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ZKReplicationStorageBase.java +++ b/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ZKReplicationStorageBase.java @@ -50,7 +50,7 @@ public class ZKReplicationStorageBase { this.zookeeper = zookeeper; this.conf = conf; - this.replicationZNode = ZNodePaths.joinZNode(this.zookeeper.znodePaths.baseZNode, + this.replicationZNode = ZNodePaths.joinZNode(this.zookeeper.getZNodePaths().baseZNode, conf.get(REPLICATION_ZNODE, REPLICATION_ZNODE_DEFAULT)); } diff --git a/hbase-replication/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java b/hbase-replication/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java index 08178f4c3fb..9eb67f9037d 100644 --- a/hbase-replication/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java +++ b/hbase-replication/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java @@ -58,7 +58,7 @@ public class TestReplicationStateZKImpl extends TestReplicationStateBasic { conf.setBoolean(HConstants.REPLICATION_BULKLOAD_ENABLE_KEY, true); zkw = utility.getZooKeeperWatcher(); String replicationZNodeName = conf.get("zookeeper.znode.replication", "replication"); - replicationZNode = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, replicationZNodeName); + replicationZNode = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, replicationZNodeName); KEY_ONE = initPeerClusterState("/hbase1"); KEY_TWO = initPeerClusterState("/hbase2"); } @@ -69,7 +69,8 @@ public class TestReplicationStateZKImpl extends TestReplicationStateBasic { Configuration testConf = new Configuration(conf); testConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, baseZKNode); ZKWatcher zkw1 = new ZKWatcher(testConf, "test1", null); - String fakeRs = ZNodePaths.joinZNode(zkw1.znodePaths.rsZNode, "hostname1.example.org:1234"); + String fakeRs = ZNodePaths.joinZNode(zkw1.getZNodePaths().rsZNode, + "hostname1.example.org:1234"); ZKUtil.createWithParents(zkw1, fakeRs); ZKClusterId.setClusterId(zkw1, new ClusterId()); return ZKConfig.getZooKeeperClusterKey(testConf); diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java index 9478401b9d9..b34ba8957e8 100644 --- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java +++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java @@ -346,7 +346,7 @@ final class RSGroupInfoManagerImpl implements RSGroupInfoManager { } List retrieveGroupListFromZookeeper() throws IOException { - String groupBasePath = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, rsGroupZNode); + String groupBasePath = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, rsGroupZNode); List RSGroupInfoList = Lists.newArrayList(); //Overwrite any info stored by table, this takes precedence try { @@ -487,7 +487,7 @@ final class RSGroupInfoManagerImpl implements RSGroupInfoManager { resetRSGroupAndTableMaps(newGroupMap, newTableMap); try { - String groupBasePath = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, rsGroupZNode); + String groupBasePath = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, rsGroupZNode); ZKUtil.createAndFailSilent(watcher, groupBasePath, ProtobufMagic.PB_MAGIC); List zkOps = new ArrayList<>(newGroupMap.size()); @@ -548,7 +548,7 @@ final class RSGroupInfoManagerImpl implements RSGroupInfoManager { LOG.debug("Reading online RS from zookeeper"); List servers = new LinkedList<>(); try { - for (String el: ZKUtil.listChildrenNoWatch(watcher, watcher.znodePaths.rsZNode)) { + for (String el: ZKUtil.listChildrenNoWatch(watcher, watcher.getZNodePaths().rsZNode)) { servers.add(ServerName.parseServerName(el)); } } catch (KeeperException e) { diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/VerifyingRSGroupAdminClient.java b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/VerifyingRSGroupAdminClient.java index a6e44be3a81..2af2721c2e1 100644 --- a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/VerifyingRSGroupAdminClient.java +++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/VerifyingRSGroupAdminClient.java @@ -134,7 +134,7 @@ public class VerifyingRSGroupAdminClient implements RSGroupAdmin { Assert.assertEquals(Sets.newHashSet(groupMap.values()), Sets.newHashSet(wrapped.listRSGroups())); try { - String groupBasePath = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "rsgroup"); + String groupBasePath = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "rsgroup"); for(String znode: ZKUtil.listChildrenNoWatch(zkw, groupBasePath)) { byte[] data = ZKUtil.getData(zkw, ZNodePaths.joinZNode(groupBasePath, znode)); if(data.length > 0) { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ZKNamespaceManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ZKNamespaceManager.java index 53b24398245..101c40ebd86 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ZKNamespaceManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ZKNamespaceManager.java @@ -55,7 +55,7 @@ public class ZKNamespaceManager extends ZKListener { public ZKNamespaceManager(ZKWatcher zkw) throws IOException { super(zkw); - nsZNode = zkw.znodePaths.namespaceZNode; + nsZNode = zkw.getZNodePaths().namespaceZNode; cache = new ConcurrentSkipListMap<>(); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ZNodeClearer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ZNodeClearer.java index f0b3a41b841..697706507bf 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ZNodeClearer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ZNodeClearer.java @@ -186,7 +186,7 @@ public final class ZNodeClearer { if (ZNodeClearer.tablesOnMaster(conf)) { // In case of master crash also remove rsZnode since master is also regionserver ZKUtil.deleteNodeFailSilent(zkw, - ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, znodeFileContent)); + ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, znodeFileContent)); return MasterAddressTracker.deleteIfEquals(zkw, ZNodeClearer.parseMasterServerName(znodeFileContent)); } else { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/example/ZKTableArchiveClient.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/example/ZKTableArchiveClient.java index 39d95439c06..142788e7618 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/example/ZKTableArchiveClient.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/example/ZKTableArchiveClient.java @@ -149,7 +149,7 @@ public class ZKTableArchiveClient extends Configured { * @return get the znode for long-term archival of a table for */ public static String getArchiveZNode(Configuration conf, ZKWatcher zooKeeper) { - return ZNodePaths.joinZNode(zooKeeper.znodePaths.baseZNode, conf.get( + return ZNodePaths.joinZNode(zooKeeper.getZNodePaths().baseZNode, conf.get( ZOOKEEPER_ZNODE_HFILE_ARCHIVE_KEY, TableHFileArchiveTracker.HFILE_ARCHIVE_ZNODE_PARENT)); } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZKSplitLogManagerCoordination.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZKSplitLogManagerCoordination.java index d2777a0d764..c8eae6b8c63 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZKSplitLogManagerCoordination.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZKSplitLogManagerCoordination.java @@ -122,7 +122,8 @@ public class ZKSplitLogManagerCoordination extends ZKListener implements public int remainingTasksInCoordination() { int count = 0; try { - List tasks = ZKUtil.listChildrenNoWatch(watcher, watcher.znodePaths.splitLogZNode); + List tasks = ZKUtil.listChildrenNoWatch(watcher, + watcher.getZNodePaths().splitLogZNode); if (tasks != null) { int listSize = tasks.size(); for (int i = 0; i < listSize; i++) { @@ -466,13 +467,14 @@ public class ZKSplitLogManagerCoordination extends ZKListener implements private void lookForOrphans() { List orphans; try { - orphans = ZKUtil.listChildrenNoWatch(this.watcher, this.watcher.znodePaths.splitLogZNode); + orphans = ZKUtil.listChildrenNoWatch(this.watcher, + this.watcher.getZNodePaths().splitLogZNode); if (orphans == null) { - LOG.warn("Could not get children of " + this.watcher.znodePaths.splitLogZNode); + LOG.warn("Could not get children of " + this.watcher.getZNodePaths().splitLogZNode); return; } } catch (KeeperException e) { - LOG.warn("Could not get children of " + this.watcher.znodePaths.splitLogZNode + " " + LOG.warn("Could not get children of " + this.watcher.getZNodePaths().splitLogZNode + " " + StringUtils.stringifyException(e)); return; } @@ -480,7 +482,7 @@ public class ZKSplitLogManagerCoordination extends ZKListener implements int listSize = orphans.size(); for (int i = 0; i < listSize; i++) { String path = orphans.get(i); - String nodepath = ZNodePaths.joinZNode(watcher.znodePaths.splitLogZNode, path); + String nodepath = ZNodePaths.joinZNode(watcher.getZNodePaths().splitLogZNode, path); if (ZKSplitLog.isRescanNode(watcher, nodepath)) { rescan_nodes++; LOG.debug("Found orphan rescan node " + path); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZkSplitLogWorkerCoordination.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZkSplitLogWorkerCoordination.java index 2143f80a69f..ff555f22add 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZkSplitLogWorkerCoordination.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZkSplitLogWorkerCoordination.java @@ -97,7 +97,7 @@ public class ZkSplitLogWorkerCoordination extends ZKListener implements */ @Override public void nodeChildrenChanged(String path) { - if (path.equals(watcher.znodePaths.splitLogZNode)) { + if (path.equals(watcher.getZNodePaths().splitLogZNode)) { if (LOG.isTraceEnabled()) { LOG.trace("tasks arrived or departed on " + path); } @@ -331,7 +331,7 @@ public class ZkSplitLogWorkerCoordination extends ZKListener implements int availableRSs = 1; try { List regionServers = - ZKUtil.listChildrenNoWatch(watcher, watcher.znodePaths.rsZNode); + ZKUtil.listChildrenNoWatch(watcher, watcher.getZNodePaths().rsZNode); availableRSs = Math.max(availableRSs, (regionServers == null) ? 0 : regionServers.size()); } catch (KeeperException e) { // do nothing @@ -412,7 +412,7 @@ public class ZkSplitLogWorkerCoordination extends ZKListener implements List paths; paths = getTaskList(); if (paths == null) { - LOG.warn("Could not get tasks, did someone remove " + watcher.znodePaths.splitLogZNode + LOG.warn("Could not get tasks, did someone remove " + watcher.getZNodePaths().splitLogZNode + " ... worker thread exiting."); return; } @@ -439,7 +439,7 @@ public class ZkSplitLogWorkerCoordination extends ZKListener implements // don't call ZKSplitLog.getNodeName() because that will lead to // double encoding of the path name taskGrabbed |= grabTask(ZNodePaths.joinZNode( - watcher.znodePaths.splitLogZNode, paths.get(idx))); + watcher.getZNodePaths().splitLogZNode, paths.get(idx))); break; } else { LOG.debug("Current region server " + server.getServerName() + " has " @@ -472,14 +472,14 @@ public class ZkSplitLogWorkerCoordination extends ZKListener implements while (!shouldStop) { try { childrenPaths = ZKUtil.listChildrenAndWatchForNewChildren(watcher, - watcher.znodePaths.splitLogZNode); + watcher.getZNodePaths().splitLogZNode); if (childrenPaths != null) { return childrenPaths; } } catch (KeeperException e) { - LOG.warn("Could not get children of znode " + watcher.znodePaths.splitLogZNode, e); + LOG.warn("Could not get children of znode " + watcher.getZNodePaths().splitLogZNode, e); } - LOG.debug("Retry listChildren of znode " + watcher.znodePaths.splitLogZNode + LOG.debug("Retry listChildren of znode " + watcher.getZNodePaths().splitLogZNode + " after sleep for " + sleepTime + "ms!"); Thread.sleep(sleepTime); } @@ -495,14 +495,14 @@ public class ZkSplitLogWorkerCoordination extends ZKListener implements public boolean isReady() throws InterruptedException { int result = -1; try { - result = ZKUtil.checkExists(watcher, watcher.znodePaths.splitLogZNode); + result = ZKUtil.checkExists(watcher, watcher.getZNodePaths().splitLogZNode); } catch (KeeperException e) { // ignore - LOG.warn("Exception when checking for " + watcher.znodePaths.splitLogZNode + LOG.warn("Exception when checking for " + watcher.getZNodePaths().splitLogZNode + " ... retrying", e); } if (result == -1) { - LOG.info(watcher.znodePaths.splitLogZNode + LOG.info(watcher.getZNodePaths().splitLogZNode + " znode does not exist, waiting for master to create"); Thread.sleep(1000); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java index 78cb024bdf4..50798ed60a0 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java @@ -93,7 +93,7 @@ public class ActiveMasterManager extends ZKListener { // shut down, so that state is now irrelevant. This means that the shutdown // state must be set while we wait on the active master in order // to shutdown this master. See HBASE-8519. - if(path.equals(watcher.znodePaths.clusterStateZNode) && !master.isStopped()) { + if(path.equals(watcher.getZNodePaths().clusterStateZNode) && !master.isStopped()) { clusterShutDown.set(true); } @@ -101,7 +101,7 @@ public class ActiveMasterManager extends ZKListener { } void handle(final String path) { - if (path.equals(watcher.znodePaths.masterAddressZNode) && !master.isStopped()) { + if (path.equals(watcher.getZNodePaths().masterAddressZNode) && !master.isStopped()) { handleMasterNodeChange(); } } @@ -123,7 +123,7 @@ public class ActiveMasterManager extends ZKListener { // Watch the node and check if it exists. try { synchronized(clusterHasActiveMaster) { - if (ZKUtil.watchAndCheckExists(watcher, watcher.znodePaths.masterAddressZNode)) { + if (ZKUtil.watchAndCheckExists(watcher, watcher.getZNodePaths().masterAddressZNode)) { // A master node exists, there is an active master LOG.trace("A master is now available"); clusterHasActiveMaster.set(true); @@ -157,14 +157,14 @@ public class ActiveMasterManager extends ZKListener { boolean blockUntilBecomingActiveMaster( int checkInterval, MonitoredTask startupStatus) { String backupZNode = ZNodePaths.joinZNode( - this.watcher.znodePaths.backupMasterAddressesZNode, this.sn.toString()); + this.watcher.getZNodePaths().backupMasterAddressesZNode, this.sn.toString()); while (!(master.isAborted() || master.isStopped())) { startupStatus.setStatus("Trying to register in ZK as active master"); // Try to become the active master, watch if there is another master. // Write out our ServerName as versioned bytes. try { if (MasterAddressTracker.setMasterAddress(this.watcher, - this.watcher.znodePaths.masterAddressZNode, this.sn, infoPort)) { + this.watcher.getZNodePaths().masterAddressZNode, this.sn, infoPort)) { // If we were a backup master before, delete our ZNode from the backup // master directory since we are the active now) @@ -188,7 +188,7 @@ public class ActiveMasterManager extends ZKListener { String msg; byte[] bytes = - ZKUtil.getDataAndWatch(this.watcher, this.watcher.znodePaths.masterAddressZNode); + ZKUtil.getDataAndWatch(this.watcher, this.watcher.getZNodePaths().masterAddressZNode); if (bytes == null) { msg = ("A master was detected, but went down before its address " + "could be read. Attempting to become the next active master"); @@ -205,7 +205,7 @@ public class ActiveMasterManager extends ZKListener { msg = ("Current master has this master's address, " + currentMaster + "; master was restarted? Deleting node."); // Hurry along the expiration of the znode. - ZKUtil.deleteNode(this.watcher, this.watcher.znodePaths.masterAddressZNode); + ZKUtil.deleteNode(this.watcher, this.watcher.getZNodePaths().masterAddressZNode); // We may have failed to delete the znode at the previous step, but // we delete the file anyway: a second attempt to delete the znode is likely to fail again. @@ -245,7 +245,7 @@ public class ActiveMasterManager extends ZKListener { */ boolean hasActiveMaster() { try { - if (ZKUtil.checkExists(watcher, watcher.znodePaths.masterAddressZNode) >= 0) { + if (ZKUtil.checkExists(watcher, watcher.getZNodePaths().masterAddressZNode) >= 0) { return true; } } @@ -271,7 +271,7 @@ public class ActiveMasterManager extends ZKListener { LOG.warn("Failed get of master address: " + e.toString()); } if (activeMaster != null && activeMaster.equals(this.sn)) { - ZKUtil.deleteNode(watcher, watcher.znodePaths.masterAddressZNode); + ZKUtil.deleteNode(watcher, watcher.getZNodePaths().masterAddressZNode); // We may have failed to delete the znode at the previous step, but // we delete the file anyway: a second attempt to delete the znode is likely to fail again. ZNodeClearer.deleteMyEphemeralNodeOnDisk(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/DrainingServerTracker.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/DrainingServerTracker.java index a9e579629c1..14c4a3ec85f 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/DrainingServerTracker.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/DrainingServerTracker.java @@ -83,7 +83,7 @@ public class DrainingServerTracker extends ZKListener { } }); List servers = - ZKUtil.listChildrenAndWatchThem(watcher, watcher.znodePaths.drainingZNode); + ZKUtil.listChildrenAndWatchThem(watcher, watcher.getZNodePaths().drainingZNode); add(servers); } @@ -110,7 +110,7 @@ public class DrainingServerTracker extends ZKListener { @Override public void nodeDeleted(final String path) { - if(path.startsWith(watcher.znodePaths.drainingZNode)) { + if(path.startsWith(watcher.getZNodePaths().drainingZNode)) { final ServerName sn = ServerName.valueOf(ZKUtil.getNodeName(path)); LOG.info("Draining RS node deleted, removing from list [" + sn + "]"); @@ -120,10 +120,10 @@ public class DrainingServerTracker extends ZKListener { @Override public void nodeChildrenChanged(final String path) { - if(path.equals(watcher.znodePaths.drainingZNode)) { + if(path.equals(watcher.getZNodePaths().drainingZNode)) { try { final List newNodes = - ZKUtil.listChildrenAndWatchThem(watcher, watcher.znodePaths.drainingZNode); + ZKUtil.listChildrenAndWatchThem(watcher, watcher.getZNodePaths().drainingZNode); add(newNodes); } catch (KeeperException e) { abortable.abort("Unexpected zk exception getting RS nodes", e); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index d100ea41b96..33d2e610575 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -2025,7 +2025,7 @@ public class HMaster extends HRegionServer implements MasterServices { private void startActiveMasterManager(int infoPort) throws KeeperException { String backupZNode = ZNodePaths.joinZNode( - zooKeeper.znodePaths.backupMasterAddressesZNode, serverName.toString()); + zooKeeper.getZNodePaths().backupMasterAddressesZNode, serverName.toString()); /* * Add a ZNode for ourselves in the backup master directory since we * may not become the active master. If so, we want the actual active @@ -2538,7 +2538,7 @@ public class HMaster extends HRegionServer implements MasterServices { List backupMasterStrings; try { backupMasterStrings = ZKUtil.listChildrenNoWatch(this.zooKeeper, - this.zooKeeper.znodePaths.backupMasterAddressesZNode); + this.zooKeeper.getZNodePaths().backupMasterAddressesZNode); } catch (KeeperException e) { LOG.warn(this.zooKeeper.prefix("Unable to list backup servers"), e); backupMasterStrings = null; @@ -2552,7 +2552,7 @@ public class HMaster extends HRegionServer implements MasterServices { byte [] bytes; try { bytes = ZKUtil.getData(this.zooKeeper, ZNodePaths.joinZNode( - this.zooKeeper.znodePaths.backupMasterAddressesZNode, s)); + this.zooKeeper.getZNodePaths().backupMasterAddressesZNode, s)); } catch (InterruptedException e) { throw new InterruptedIOException(); } @@ -3500,7 +3500,7 @@ public class HMaster extends HRegionServer implements MasterServices { throws HBaseIOException { List serversAdded = new ArrayList<>(servers.size()); // Place the decommission marker first. - String parentZnode = getZooKeeper().znodePaths.drainingZNode; + String parentZnode = getZooKeeper().getZNodePaths().drainingZNode; for (ServerName server : servers) { try { String node = ZNodePaths.joinZNode(parentZnode, server.getServerName()); @@ -3549,7 +3549,7 @@ public class HMaster extends HRegionServer implements MasterServices { public void recommissionRegionServer(final ServerName server, final List encodedRegionNames) throws HBaseIOException { // Remove the server from decommissioned (draining) server list. - String parentZnode = getZooKeeper().znodePaths.drainingZNode; + String parentZnode = getZooKeeper().getZNodePaths().drainingZNode; String node = ZNodePaths.joinZNode(parentZnode, server.getServerName()); try { ZKUtil.deleteNodeFailSilent(getZooKeeper(), node); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterMetaBootstrap.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterMetaBootstrap.java index eab937d0681..59f123395be 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterMetaBootstrap.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterMetaBootstrap.java @@ -125,14 +125,14 @@ public class MasterMetaBootstrap { try { List metaReplicaZnodes = zooKeeper.getMetaReplicaNodes(); for (String metaReplicaZnode : metaReplicaZnodes) { - int replicaId = zooKeeper.znodePaths.getMetaReplicaIdFromZnode(metaReplicaZnode); + int replicaId = zooKeeper.getZNodePaths().getMetaReplicaIdFromZnode(metaReplicaZnode); if (replicaId >= numMetaReplicasConfigured) { RegionState r = MetaTableLocator.getMetaRegionState(zooKeeper, replicaId); LOG.info("Closing excess replica of meta region " + r.getRegion()); // send a close and wait for a max of 30 seconds ServerManager.closeRegionSilentlyAndWait(master.getClusterConnection(), r.getServerName(), r.getRegion(), 30000); - ZKUtil.deleteNode(zooKeeper, zooKeeper.znodePaths.getZNodeForReplica(replicaId)); + ZKUtil.deleteNode(zooKeeper, zooKeeper.getZNodePaths().getZNodeForReplica(replicaId)); } } } catch (Exception ex) { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionServerTracker.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionServerTracker.java index 81fc589f437..100476bfeb2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionServerTracker.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionServerTracker.java @@ -72,7 +72,7 @@ public class RegionServerTracker extends ZKListener { public void start() throws KeeperException, IOException { watcher.registerListener(this); List servers = - ZKUtil.listChildrenAndWatchThem(watcher, watcher.znodePaths.rsZNode); + ZKUtil.listChildrenAndWatchThem(watcher, watcher.getZNodePaths().rsZNode); refresh(servers); } @@ -84,7 +84,7 @@ public class RegionServerTracker extends ZKListener { if (regionServers.get(sn) == null) { RegionServerInfo.Builder rsInfoBuilder = RegionServerInfo.newBuilder(); try { - String nodePath = ZNodePaths.joinZNode(watcher.znodePaths.rsZNode, n); + String nodePath = ZNodePaths.joinZNode(watcher.getZNodePaths().rsZNode, n); byte[] data = ZKUtil.getData(watcher, nodePath); if (data != null && data.length > 0 && ProtobufUtil.isPBMagicPrefix(data)) { int magicLen = ProtobufUtil.lengthOfPBMagic(); @@ -114,7 +114,7 @@ public class RegionServerTracker extends ZKListener { @Override public void nodeCreated(String path) { - if (path.startsWith(watcher.znodePaths.rsZNode)) { + if (path.startsWith(watcher.getZNodePaths().rsZNode)) { String serverName = ZKUtil.getNodeName(path); LOG.info("RegionServer ephemeral node created, adding [" + serverName + "]"); if (server.isInitialized()) { @@ -127,7 +127,7 @@ public class RegionServerTracker extends ZKListener { @Override public void nodeDeleted(String path) { - if (path.startsWith(watcher.znodePaths.rsZNode)) { + if (path.startsWith(watcher.getZNodePaths().rsZNode)) { String serverName = ZKUtil.getNodeName(path); LOG.info("RegionServer ephemeral node deleted, processing expiration [" + serverName + "]"); @@ -144,11 +144,11 @@ public class RegionServerTracker extends ZKListener { @Override public void nodeChildrenChanged(String path) { - if (path.equals(watcher.znodePaths.rsZNode) + if (path.equals(watcher.getZNodePaths().rsZNode) && !server.isAborted() && !server.isStopped()) { try { List servers = - ZKUtil.listChildrenAndWatchThem(watcher, watcher.znodePaths.rsZNode); + ZKUtil.listChildrenAndWatchThem(watcher, watcher.getZNodePaths().rsZNode); refresh(servers); } catch (IOException e) { server.abort("Unexpected zk exception getting RS nodes", e); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java index a65d95f5eeb..4b072447b22 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java @@ -551,7 +551,7 @@ public class ServerManager { private List getRegionServersInZK(final ZKWatcher zkw) throws KeeperException { - return ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.rsZNode); + return ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().rsZNode); } /* diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitOrMergeTracker.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitOrMergeTracker.java index 52040fab77d..a18738f9d3a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitOrMergeTracker.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitOrMergeTracker.java @@ -49,15 +49,15 @@ public class SplitOrMergeTracker { public SplitOrMergeTracker(ZKWatcher watcher, Configuration conf, Abortable abortable) { try { - if (ZKUtil.checkExists(watcher, watcher.znodePaths.switchZNode) < 0) { - ZKUtil.createAndFailSilent(watcher, watcher.znodePaths.switchZNode); + if (ZKUtil.checkExists(watcher, watcher.getZNodePaths().switchZNode) < 0) { + ZKUtil.createAndFailSilent(watcher, watcher.getZNodePaths().switchZNode); } } catch (KeeperException e) { throw new RuntimeException(e); } - splitZnode = ZNodePaths.joinZNode(watcher.znodePaths.switchZNode, + splitZnode = ZNodePaths.joinZNode(watcher.getZNodePaths().switchZNode, conf.get("zookeeper.znode.switch.split", "split")); - mergeZnode = ZNodePaths.joinZNode(watcher.znodePaths.switchZNode, + mergeZnode = ZNodePaths.joinZNode(watcher.getZNodePaths().switchZNode, conf.get("zookeeper.znode.switch.merge", "merge")); splitStateTracker = new SwitchStateTracker(watcher, splitZnode, abortable); mergeStateTracker = new SwitchStateTracker(watcher, mergeZnode, abortable); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/ClientZKSyncer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/ClientZKSyncer.java index 550aea7e06b..b1c70c56935 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/ClientZKSyncer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/ClientZKSyncer.java @@ -68,7 +68,7 @@ public abstract class ClientZKSyncer extends ZKListener { LOG.debug("Starting " + getClass().getSimpleName()); this.watcher.registerListener(this); // create base znode on remote ZK - ZKUtil.createWithParents(clientZkWatcher, watcher.znodePaths.baseZNode); + ZKUtil.createWithParents(clientZkWatcher, watcher.getZNodePaths().baseZNode); // set meta znodes for client ZK Collection nodes = getNodesToWatch(); LOG.debug("Znodes to watch: " + nodes); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/MasterAddressSyncer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/MasterAddressSyncer.java index 3da8558cc68..a9aa13cb93d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/MasterAddressSyncer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/MasterAddressSyncer.java @@ -35,7 +35,7 @@ public class MasterAddressSyncer extends ClientZKSyncer { public MasterAddressSyncer(ZKWatcher watcher, ZKWatcher clientZkWatcher, Server server) { super(watcher, clientZkWatcher, server); - masterAddressZNode = watcher.znodePaths.masterAddressZNode; + masterAddressZNode = watcher.getZNodePaths().masterAddressZNode; } @Override diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/MetaLocationSyncer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/MetaLocationSyncer.java index 68f7fc40977..eb80a2a232b 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/MetaLocationSyncer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/MetaLocationSyncer.java @@ -36,11 +36,11 @@ public class MetaLocationSyncer extends ClientZKSyncer { @Override boolean validate(String path) { - return watcher.znodePaths.isAnyMetaReplicaZNode(path); + return watcher.getZNodePaths().isAnyMetaReplicaZNode(path); } @Override Collection getNodesToWatch() { - return watcher.znodePaths.metaReplicaZNodes.values(); + return watcher.getZNodePaths().metaReplicaZNodes.values(); } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureUtil.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureUtil.java index 210bc02aaa9..0e9799977ba 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureUtil.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureUtil.java @@ -79,7 +79,7 @@ public abstract class ZKProcedureUtil // make sure we are listening for events watcher.registerListener(this); // setup paths for the zknodes used in procedures - this.baseZNode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, procDescription); + this.baseZNode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, procDescription); acquiredZnode = ZNodePaths.joinZNode(baseZNode, ACQUIRED_BARRIER_ZNODE_DEFAULT); reachedZnode = ZNodePaths.joinZNode(baseZNode, REACHED_BARRIER_ZNODE_DEFAULT); abortZnode = ZNodePaths.joinZNode(baseZNode, ABORT_ZNODE_DEFAULT); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 2c68278b29f..f3db9ab7239 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -3483,7 +3483,7 @@ public class HRegionServer extends HasThread implements } private String getMyEphemeralNodePath() { - return ZNodePaths.joinZNode(this.zooKeeper.znodePaths.rsZNode, getServerName().toString()); + return ZNodePaths.joinZNode(this.zooKeeper.getZNodePaths().rsZNode, getServerName().toString()); } private boolean isHealthCheckerConfigured() { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/HBaseReplicationEndpoint.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/HBaseReplicationEndpoint.java index 9cb3312ca5b..1ca70ad85dd 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/HBaseReplicationEndpoint.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/HBaseReplicationEndpoint.java @@ -155,7 +155,8 @@ public abstract class HBaseReplicationEndpoint extends BaseReplicationEndpoint */ protected static List fetchSlavesAddresses(ZKWatcher zkw) throws KeeperException { - List children = ZKUtil.listChildrenAndWatchForNewChildren(zkw, zkw.znodePaths.rsZNode); + List children = ZKUtil.listChildrenAndWatchForNewChildren(zkw, + zkw.getZNodePaths().rsZNode); if (children == null) { return Collections.emptyList(); } @@ -216,7 +217,7 @@ public abstract class HBaseReplicationEndpoint extends BaseReplicationEndpoint public PeerRegionServerListener(HBaseReplicationEndpoint replicationPeer) { super(replicationPeer.getZkw()); this.replicationEndpoint = replicationPeer; - this.regionServerListNode = replicationEndpoint.getZkw().znodePaths.rsZNode; + this.regionServerListNode = replicationEndpoint.getZkw().getZNodePaths().rsZNode; } @Override diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/master/ReplicationPeerConfigUpgrader.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/master/ReplicationPeerConfigUpgrader.java index ac1acbe7a63..4d481239cf0 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/master/ReplicationPeerConfigUpgrader.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/master/ReplicationPeerConfigUpgrader.java @@ -97,7 +97,7 @@ public class ReplicationPeerConfigUpgrader{ @VisibleForTesting protected String getTableCFsNode(String peerId) { - String replicationZNode = ZNodePaths.joinZNode(zookeeper.znodePaths.baseZNode, + String replicationZNode = ZNodePaths.joinZNode(zookeeper.getZNodePaths().baseZNode, conf.get(REPLICATION_ZNODE, REPLICATION_ZNODE_DEFAULT)); String peersZNode = ZNodePaths.joinZNode(replicationZNode, conf.get(PEERS_ZNODE, PEERS_ZNODE_DEFAULT)); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ZKPermissionWatcher.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ZKPermissionWatcher.java index 92560cd82c3..2266e866f4d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ZKPermissionWatcher.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ZKPermissionWatcher.java @@ -67,7 +67,7 @@ public class ZKPermissionWatcher extends ZKListener implements Closeable { super(watcher); this.authManager = authManager; String aclZnodeParent = conf.get("zookeeper.znode.acl.parent", ACL_NODE); - this.aclZNode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, aclZnodeParent); + this.aclZNode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, aclZnodeParent); executor = Executors.newSingleThreadExecutor( new DaemonThreadFactory("zk-permission-watcher")); } @@ -260,7 +260,7 @@ public class ZKPermissionWatcher extends ZKListener implements Closeable { */ public void writeToZookeeper(byte[] entry, byte[] permsData) { String entryName = Bytes.toString(entry); - String zkNode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, ACL_NODE); + String zkNode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, ACL_NODE); zkNode = ZNodePaths.joinZNode(zkNode, entryName); try { @@ -278,7 +278,7 @@ public class ZKPermissionWatcher extends ZKListener implements Closeable { * @param tableName */ public void deleteTableACLNode(final TableName tableName) { - String zkNode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, ACL_NODE); + String zkNode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, ACL_NODE); zkNode = ZNodePaths.joinZNode(zkNode, tableName.getNameAsString()); try { @@ -295,7 +295,7 @@ public class ZKPermissionWatcher extends ZKListener implements Closeable { * Delete the acl notify node of namespace */ public void deleteNamespaceACLNode(final String namespace) { - String zkNode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, ACL_NODE); + String zkNode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, ACL_NODE); zkNode = ZNodePaths.joinZNode(zkNode, AccessControlLists.NAMESPACE_PREFIX + namespace); try { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/token/ZKSecretWatcher.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/token/ZKSecretWatcher.java index d86a2f95446..f7be45bbfd8 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/token/ZKSecretWatcher.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/token/ZKSecretWatcher.java @@ -54,7 +54,7 @@ public class ZKSecretWatcher extends ZKListener { super(watcher); this.secretManager = secretManager; String keyZNodeParent = conf.get("zookeeper.znode.tokenauth.parent", DEFAULT_ROOT_NODE); - this.baseKeyZNode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, keyZNodeParent); + this.baseKeyZNode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, keyZNodeParent); this.keysParentZNode = ZNodePaths.joinZNode(baseKeyZNode, DEFAULT_KEYS_PARENT); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/ZKVisibilityLabelWatcher.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/ZKVisibilityLabelWatcher.java index d428ff4291e..0bbc8d3a35c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/ZKVisibilityLabelWatcher.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/ZKVisibilityLabelWatcher.java @@ -54,8 +54,9 @@ public class ZKVisibilityLabelWatcher extends ZKListener { String labelZnodeParent = conf.get(VISIBILITY_LABEL_ZK_PATH, DEFAULT_VISIBILITY_LABEL_NODE); String userAuthsZnodeParent = conf.get(VISIBILITY_USER_AUTHS_ZK_PATH, DEFAULT_VISIBILITY_USER_AUTHS_NODE); - this.labelZnode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, labelZnodeParent); - this.userAuthsZnode = ZNodePaths.joinZNode(watcher.znodePaths.baseZNode, userAuthsZnodeParent); + this.labelZnode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, labelZnodeParent); + this.userAuthsZnode = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, + userAuthsZnodeParent); } public void start() throws KeeperException { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java index 27fa6b747ec..c479759fa72 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java @@ -722,7 +722,7 @@ public class HBaseFsck extends Configured implements Closeable { private boolean setMasterInMaintenanceMode() throws IOException { RetryCounter retryCounter = createZNodeRetryCounterFactory.create(); hbckEphemeralNodePath = ZNodePaths.joinZNode( - zkw.znodePaths.masterMaintZNode, + zkw.getZNodePaths().masterMaintZNode, "hbck-" + Long.toString(EnvironmentEdgeManager.currentTime())); do { try { @@ -3673,7 +3673,7 @@ public class HBaseFsck extends Configured implements Closeable { private void unassignMetaReplica(HbckInfo hi) throws IOException, InterruptedException, KeeperException { undeployRegions(hi); - ZKUtil.deleteNode(zkw, zkw.znodePaths.getZNodeForReplica(hi.metaEntry.getReplicaId())); + ZKUtil.deleteNode(zkw, zkw.getZNodePaths().getZNodeForReplica(hi.metaEntry.getReplicaId())); } private void assignMetaReplica(int replicaId) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ZKDataMigrator.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ZKDataMigrator.java index 129341c8b85..6b284ad5057 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ZKDataMigrator.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ZKDataMigrator.java @@ -60,7 +60,7 @@ public class ZKDataMigrator { public static Map queryForTableStates(ZKWatcher zkw) throws KeeperException, InterruptedException { Map rv = new HashMap<>(); - List children = ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.tableZNode); + List children = ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().tableZNode); if (children == null) return rv; for (String child: children) { @@ -101,7 +101,8 @@ public class ZKDataMigrator { private static ZooKeeperProtos.DeprecatedTableState.State getTableState( final ZKWatcher zkw, final TableName tableName) throws KeeperException, InterruptedException { - String znode = ZNodePaths.joinZNode(zkw.znodePaths.tableZNode, tableName.getNameAsString()); + String znode = ZNodePaths.joinZNode(zkw.getZNodePaths().tableZNode, + tableName.getNameAsString()); byte [] data = ZKUtil.getData(zkw, znode); if (data == null || data.length <= 0) return null; try { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java index 2834d178fbd..23187b31ff0 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java @@ -179,7 +179,7 @@ public class TestMetaWithReplicas { for (int i = 1; i < 3; i++) { String secZnode = ZNodePaths.joinZNode(baseZNode, conf.get("zookeeper.znode.metaserver", "meta-region-server") + "-" + i); - String str = zkw.znodePaths.getZNodeForReplica(i); + String str = zkw.getZNodePaths().getZNodeForReplica(i); assertTrue(str.equals(secZnode)); // check that the data in the znode is parseable (this would also mean the znode exists) data = ZKUtil.getData(zkw, secZnode); @@ -413,7 +413,7 @@ public class TestMetaWithReplicas { HBaseFsckRepair.closeRegionSilentlyAndWait(c, rl.getRegionLocation(2).getServerName(), rl.getRegionLocation(2).getRegionInfo()); ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher(); - ZKUtil.deleteNode(zkw, zkw.znodePaths.getZNodeForReplica(2)); + ZKUtil.deleteNode(zkw, zkw.getZNodePaths().getZNodeForReplica(2)); // check that problem exists HBaseFsck hbck = doFsck(TEST_UTIL.getConfiguration(), false); assertErrors(hbck, new ERROR_CODE[]{ERROR_CODE.UNKNOWN,ERROR_CODE.NO_META_REGION}); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java index 9f68ea59c8f..5851dea3c4e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java @@ -79,8 +79,8 @@ public class TestActiveMasterManager { ZKWatcher zk = new ZKWatcher(TEST_UTIL.getConfiguration(), "testActiveMasterManagerFromZK", null, true); try { - ZKUtil.deleteNode(zk, zk.znodePaths.masterAddressZNode); - ZKUtil.deleteNode(zk, zk.znodePaths.clusterStateZNode); + ZKUtil.deleteNode(zk, zk.getZNodePaths().masterAddressZNode); + ZKUtil.deleteNode(zk, zk.getZNodePaths().clusterStateZNode); } catch(KeeperException.NoNodeException nne) {} // Create the master node with a dummy address @@ -121,8 +121,8 @@ public class TestActiveMasterManager { ZKWatcher zk = new ZKWatcher(TEST_UTIL.getConfiguration(), "testActiveMasterManagerFromZK", null, true); try { - ZKUtil.deleteNode(zk, zk.znodePaths.masterAddressZNode); - ZKUtil.deleteNode(zk, zk.znodePaths.clusterStateZNode); + ZKUtil.deleteNode(zk, zk.getZNodePaths().masterAddressZNode); + ZKUtil.deleteNode(zk, zk.getZNodePaths().clusterStateZNode); } catch(KeeperException.NoNodeException nne) {} // Create the master node with a dummy address @@ -167,11 +167,12 @@ public class TestActiveMasterManager { ms1.stop("stopping first server"); // Use a listener to capture when the node is actually deleted - NodeDeletionListener listener = new NodeDeletionListener(zk, zk.znodePaths.masterAddressZNode); + NodeDeletionListener listener = new NodeDeletionListener(zk, + zk.getZNodePaths().masterAddressZNode); zk.registerListener(listener); LOG.info("Deleting master node"); - ZKUtil.deleteNode(zk, zk.znodePaths.masterAddressZNode); + ZKUtil.deleteNode(zk, zk.getZNodePaths().masterAddressZNode); // Wait for the node to be deleted LOG.info("Waiting for active master manager to be notified"); @@ -191,7 +192,7 @@ public class TestActiveMasterManager { assertTrue(t.isActiveMaster); LOG.info("Deleting master node"); - ZKUtil.deleteNode(zk, zk.znodePaths.masterAddressZNode); + ZKUtil.deleteNode(zk, zk.getZNodePaths().masterAddressZNode); } /** diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterRPCException.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterRPCException.java index 8630dbb06dc..19707374642 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterRPCException.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterRPCException.java @@ -72,7 +72,8 @@ public class TestHMasterRPCException { testUtil.startMiniZKCluster(); ZKWatcher watcher = testUtil.getZooKeeperWatcher(); - ZKUtil.createWithParents(watcher, watcher.znodePaths.masterAddressZNode, Bytes.toBytes("fake:123")); + ZKUtil.createWithParents(watcher, watcher.getZNodePaths().masterAddressZNode, + Bytes.toBytes("fake:123")); master = new HMaster(conf); rpcClient = RpcClientFactory.createClient(conf, HConstants.CLUSTER_ID_DEFAULT); } @@ -109,7 +110,7 @@ public class TestHMasterRPCException { LOG.info("Expected exception: ", ie); if (!fakeZNodeDelete) { testUtil.getZooKeeperWatcher().getRecoverableZooKeeper() - .delete(testUtil.getZooKeeperWatcher().znodePaths.masterAddressZNode, -1); + .delete(testUtil.getZooKeeperWatcher().getZNodePaths().masterAddressZNode, -1); fakeZNodeDelete = true; } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java index 9ee10a7e7fd..43ddd83b11a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java @@ -120,7 +120,7 @@ public class TestMasterNoCluster { return false; } }); - ZKUtil.deleteNodeRecursively(zkw, zkw.znodePaths.baseZNode); + ZKUtil.deleteNodeRecursively(zkw, zkw.getZNodePaths().baseZNode); zkw.close(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMetaShutdownHandler.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMetaShutdownHandler.java index 7faed1c2b17..9497210233b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMetaShutdownHandler.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMetaShutdownHandler.java @@ -102,7 +102,8 @@ public class TestMetaShutdownHandler { // Delete the ephemeral node of the meta-carrying region server. // This is trigger the expire of this region server on the master. String rsEphemeralNodePath = - ZNodePaths.joinZNode(master.getZooKeeper().znodePaths.rsZNode, metaServerName.toString()); + ZNodePaths.joinZNode(master.getZooKeeper().getZNodePaths().rsZNode, + metaServerName.toString()); ZKUtil.deleteNode(master.getZooKeeper(), rsEphemeralNodePath); LOG.info("Deleted the znode for the RegionServer hosting hbase:meta; waiting on SSH"); // Wait for SSH to finish diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMirroringTableStateManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMirroringTableStateManager.java index d10c2b4a970..f1ebc17b6a6 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMirroringTableStateManager.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMirroringTableStateManager.java @@ -82,7 +82,8 @@ public class TestMirroringTableStateManager { private TableState.State getTableStateInZK(ZKWatcher watcher, final TableName tableName) throws KeeperException, IOException, InterruptedException { - String znode = ZNodePaths.joinZNode(watcher.znodePaths.tableZNode, tableName.getNameAsString()); + String znode = ZNodePaths.joinZNode(watcher.getZNodePaths().tableZNode, + tableName.getNameAsString()); byte [] data = ZKUtil.getData(watcher, znode); if (data == null || data.length <= 0) { return null; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java index c3021f3d1f7..917a7713363 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java @@ -127,13 +127,13 @@ public class TestSplitLogManager { new ZKWatcher(conf, "split-log-manager-tests" + UUID.randomUUID().toString(), null); master = new DummyMasterServices(zkw, conf); - ZKUtil.deleteChildrenRecursively(zkw, zkw.znodePaths.baseZNode); - ZKUtil.createAndFailSilent(zkw, zkw.znodePaths.baseZNode); - assertTrue(ZKUtil.checkExists(zkw, zkw.znodePaths.baseZNode) != -1); - LOG.debug(zkw.znodePaths.baseZNode + " created"); - ZKUtil.createAndFailSilent(zkw, zkw.znodePaths.splitLogZNode); - assertTrue(ZKUtil.checkExists(zkw, zkw.znodePaths.splitLogZNode) != -1); - LOG.debug(zkw.znodePaths.splitLogZNode + " created"); + ZKUtil.deleteChildrenRecursively(zkw, zkw.getZNodePaths().baseZNode); + ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().baseZNode); + assertTrue(ZKUtil.checkExists(zkw, zkw.getZNodePaths().baseZNode) != -1); + LOG.debug(zkw.getZNodePaths().baseZNode + " created"); + ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().splitLogZNode); + assertTrue(ZKUtil.checkExists(zkw, zkw.getZNodePaths().splitLogZNode) != -1); + LOG.debug(zkw.getZNodePaths().splitLogZNode + " created"); resetCounters(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMasterAddressTracker.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMasterAddressTracker.java index 2a89b99ed56..58b4e729cda 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMasterAddressTracker.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMasterAddressTracker.java @@ -87,7 +87,7 @@ public class TestMasterAddressTracker { throws Exception { ZKWatcher zk = new ZKWatcher(TEST_UTIL.getConfiguration(), name.getMethodName(), null); - ZKUtil.createAndFailSilent(zk, zk.znodePaths.baseZNode); + ZKUtil.createAndFailSilent(zk, zk.getZNodePaths().baseZNode); // Should not have a master yet MasterAddressTracker addressTracker = new MasterAddressTracker(zk, null); @@ -96,12 +96,14 @@ public class TestMasterAddressTracker { zk.registerListener(addressTracker); // Use a listener to capture when the node is actually created - NodeCreationListener listener = new NodeCreationListener(zk, zk.znodePaths.masterAddressZNode); + NodeCreationListener listener = new NodeCreationListener(zk, + zk.getZNodePaths().masterAddressZNode); zk.registerListener(listener); if (sn != null) { LOG.info("Creating master node"); - MasterAddressTracker.setMasterAddress(zk, zk.znodePaths.masterAddressZNode, sn, infoPort); + MasterAddressTracker.setMasterAddress(zk, zk.getZNodePaths().masterAddressZNode, + sn, infoPort); // Wait for the node to be created LOG.info("Waiting for master address manager to be notified"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerHostname.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerHostname.java index 1b51ae4e372..131158b29a5 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerHostname.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerHostname.java @@ -106,7 +106,7 @@ public class TestRegionServerHostname { TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS); try { ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher(); - List servers = ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.rsZNode); + List servers = ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().rsZNode); // there would be NUM_RS+1 children - one for the master assertTrue(servers.size() == NUM_RS + (LoadBalancer.isTablesOnMaster(TEST_UTIL.getConfiguration())? 1: 0)); @@ -167,7 +167,7 @@ public class TestRegionServerHostname { boolean tablesOnMaster = LoadBalancer.isTablesOnMaster(TEST_UTIL.getConfiguration()); int expectedRS = NUM_RS + (tablesOnMaster? 1: 0); try (ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher()) { - List servers = ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.rsZNode); + List servers = ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().rsZNode); assertEquals(expectedRS, servers.size()); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitLogWorker.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitLogWorker.java index b3e9e8ceb8c..0c38ee317cc 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitLogWorker.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitLogWorker.java @@ -204,16 +204,16 @@ public class TestSplitLogWorker { zkw = new ZKWatcher(TEST_UTIL.getConfiguration(), "split-log-worker-tests", null); ds = new DummyServer(zkw, conf); - ZKUtil.deleteChildrenRecursively(zkw, zkw.znodePaths.baseZNode); - ZKUtil.createAndFailSilent(zkw, zkw.znodePaths.baseZNode); - assertThat(ZKUtil.checkExists(zkw, zkw.znodePaths.baseZNode), not (is(-1))); - LOG.debug(zkw.znodePaths.baseZNode + " created"); - ZKUtil.createAndFailSilent(zkw, zkw.znodePaths.splitLogZNode); - assertThat(ZKUtil.checkExists(zkw, zkw.znodePaths.splitLogZNode), not (is(-1))); + ZKUtil.deleteChildrenRecursively(zkw, zkw.getZNodePaths().baseZNode); + ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().baseZNode); + assertThat(ZKUtil.checkExists(zkw, zkw.getZNodePaths().baseZNode), not(is(-1))); + LOG.debug(zkw.getZNodePaths().baseZNode + " created"); + ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().splitLogZNode); + assertThat(ZKUtil.checkExists(zkw, zkw.getZNodePaths().splitLogZNode), not(is(-1))); - LOG.debug(zkw.znodePaths.splitLogZNode + " created"); - ZKUtil.createAndFailSilent(zkw, zkw.znodePaths.rsZNode); - assertThat(ZKUtil.checkExists(zkw, zkw.znodePaths.rsZNode), not (is(-1))); + LOG.debug(zkw.getZNodePaths().splitLogZNode + " created"); + ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().rsZNode); + assertThat(ZKUtil.checkExists(zkw, zkw.getZNodePaths().rsZNode), not(is(-1))); SplitLogCounters.resetCounters(); executorService = new ExecutorService("TestSplitLogWorker"); @@ -430,7 +430,7 @@ public class TestSplitLogWorker { waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 1, 2, WAIT_TIME); waitForCounter(SplitLogCounters.tot_wkr_task_acquired_rescan, 0, 1, WAIT_TIME); - List nodes = ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.splitLogZNode); + List nodes = ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().splitLogZNode); LOG.debug(Objects.toString(nodes)); int num = 0; for (String node : nodes) { @@ -438,7 +438,8 @@ public class TestSplitLogWorker { if (node.startsWith("RESCAN")) { String name = ZKSplitLog.getEncodedNodeName(zkw, node); String fn = ZKSplitLog.getFileName(name); - byte [] data = ZKUtil.getData(zkw, ZNodePaths.joinZNode(zkw.znodePaths.splitLogZNode, fn)); + byte [] data = ZKUtil.getData(zkw, + ZNodePaths.joinZNode(zkw.getZNodePaths().splitLogZNode, fn)); slt = SplitLogTask.parseFrom(data); assertTrue(slt.toString(), slt.isDone(SRV)); } @@ -494,9 +495,9 @@ public class TestSplitLogWorker { RegionServerServices mockedRS = getRegionServer(RS); // create two RS nodes - String rsPath = ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, RS.getServerName()); + String rsPath = ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, RS.getServerName()); zkw.getRecoverableZooKeeper().create(rsPath, null, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL); - rsPath = ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, RS2.getServerName()); + rsPath = ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, RS2.getServerName()); zkw.getRecoverableZooKeeper().create(rsPath, null, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL); for (int i = 0; i < maxTasks; i++) { 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 77b4c1b0de8..65eac4a9f04 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 @@ -83,13 +83,14 @@ public class TestReplicationTrackerZKImpl { utility.startMiniZKCluster(); conf = utility.getConfiguration(); ZKWatcher zk = HBaseTestingUtility.getZooKeeperWatcher(utility); - ZKUtil.createWithParents(zk, zk.znodePaths.rsZNode); + ZKUtil.createWithParents(zk, zk.getZNodePaths().rsZNode); } @Before public void setUp() throws Exception { zkw = HBaseTestingUtility.getZooKeeperWatcher(utility); - String fakeRs1 = ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, "hostname1.example.org:1234"); + String fakeRs1 = ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, + "hostname1.example.org:1234"); try { ZKClusterId.setClusterId(zkw, new ClusterId()); rp = ReplicationFactory.getReplicationPeers(zkw, conf); @@ -115,34 +116,34 @@ public class TestReplicationTrackerZKImpl { // 1 region server ZKUtil.createWithParents(zkw, - ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, "hostname1.example.org:1234")); + ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, "hostname1.example.org:1234")); assertEquals(1, rt.getListOfRegionServers().size()); // 2 region servers ZKUtil.createWithParents(zkw, - ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, "hostname2.example.org:1234")); + ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, "hostname2.example.org:1234")); assertEquals(2, rt.getListOfRegionServers().size()); // 1 region server ZKUtil.deleteNode(zkw, - ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, "hostname2.example.org:1234")); + ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, "hostname2.example.org:1234")); assertEquals(1, rt.getListOfRegionServers().size()); // 0 region server ZKUtil.deleteNode(zkw, - ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, "hostname1.example.org:1234")); + ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, "hostname1.example.org:1234")); assertEquals(0, rt.getListOfRegionServers().size()); } @Test public void testRegionServerRemovedEvent() throws Exception { ZKUtil.createAndWatch(zkw, - ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, "hostname2.example.org:1234"), + ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, "hostname2.example.org:1234"), HConstants.EMPTY_BYTE_ARRAY); rt.registerListener(new DummyReplicationListener()); // delete one ZKUtil.deleteNode(zkw, - ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, "hostname2.example.org:1234")); + ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, "hostname2.example.org:1234")); // wait for event while (rsRemovedCount.get() < 1) { Thread.sleep(5); diff --git a/hbase-zookeeper/pom.xml b/hbase-zookeeper/pom.xml index 588afb55f55..38daf3bad44 100644 --- a/hbase-zookeeper/pom.xml +++ b/hbase-zookeeper/pom.xml @@ -91,6 +91,13 @@ org.codehaus.mojo findbugs-maven-plugin + + org.apache.maven.plugins + maven-checkstyle-plugin + + true + + net.revelc.code warbucks-maven-plugin diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ClusterStatusTracker.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ClusterStatusTracker.java index 730c099c65f..c78d69aec44 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ClusterStatusTracker.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ClusterStatusTracker.java @@ -48,7 +48,7 @@ public class ClusterStatusTracker extends ZKNodeTracker { * @param abortable used to abort if a fatal error occurs */ public ClusterStatusTracker(ZKWatcher watcher, Abortable abortable) { - super(watcher, watcher.znodePaths.clusterStateZNode, abortable); + super(watcher, watcher.getZNodePaths().clusterStateZNode, abortable); } /** @@ -65,12 +65,12 @@ public class ClusterStatusTracker extends ZKNodeTracker { * @throws KeeperException unexpected zk exception */ public void setClusterUp() - throws KeeperException { + throws KeeperException { byte [] upData = toByteArray(); try { - ZKUtil.createAndWatch(watcher, watcher.znodePaths.clusterStateZNode, upData); + ZKUtil.createAndWatch(watcher, watcher.getZNodePaths().clusterStateZNode, upData); } catch(KeeperException.NodeExistsException nee) { - ZKUtil.setData(watcher, watcher.znodePaths.clusterStateZNode, upData); + ZKUtil.setData(watcher, watcher.getZNodePaths().clusterStateZNode, upData); } } @@ -79,12 +79,12 @@ public class ClusterStatusTracker extends ZKNodeTracker { * @throws KeeperException unexpected zk exception */ public void setClusterDown() - throws KeeperException { + throws KeeperException { try { - ZKUtil.deleteNode(watcher, watcher.znodePaths.clusterStateZNode); + ZKUtil.deleteNode(watcher, watcher.getZNodePaths().clusterStateZNode); } catch(KeeperException.NoNodeException nne) { LOG.warn("Attempted to set cluster as down but already down, cluster " + - "state node (" + watcher.znodePaths.clusterStateZNode + ") not found"); + "state node (" + watcher.getZNodePaths().clusterStateZNode + ") not found"); } } diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/LoadBalancerTracker.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/LoadBalancerTracker.java index d3085b778f6..0e74483a228 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/LoadBalancerTracker.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/LoadBalancerTracker.java @@ -39,7 +39,7 @@ public class LoadBalancerTracker extends ZKNodeTracker { public LoadBalancerTracker(ZKWatcher watcher, Abortable abortable) { - super(watcher, watcher.znodePaths.balancerZNode, abortable); + super(watcher, watcher.getZNodePaths().balancerZNode, abortable); } /** @@ -67,11 +67,11 @@ public class LoadBalancerTracker extends ZKNodeTracker { byte [] upData = toByteArray(balancerOn); try { - ZKUtil.setData(watcher, watcher.znodePaths.balancerZNode, upData); + ZKUtil.setData(watcher, watcher.getZNodePaths().balancerZNode, upData); } catch(KeeperException.NoNodeException nne) { - ZKUtil.createAndWatch(watcher, watcher.znodePaths.balancerZNode, upData); + ZKUtil.createAndWatch(watcher, watcher.getZNodePaths().balancerZNode, upData); } - super.nodeDataChanged(watcher.znodePaths.balancerZNode); + super.nodeDataChanged(watcher.getZNodePaths().balancerZNode); } private byte [] toByteArray(boolean isBalancerOn) { @@ -82,7 +82,7 @@ public class LoadBalancerTracker extends ZKNodeTracker { } private LoadBalancerProtos.LoadBalancerState parseFrom(byte [] pbBytes) - throws DeserializationException { + throws DeserializationException { ProtobufUtil.expectPBMagicPrefix(pbBytes); LoadBalancerProtos.LoadBalancerState.Builder builder = LoadBalancerProtos.LoadBalancerState.newBuilder(); diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTracker.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTracker.java index 18b81f4de69..915244e9646 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTracker.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTracker.java @@ -65,7 +65,7 @@ public class MasterAddressTracker extends ZKNodeTracker { * @param abortable abortable in case of fatal error */ public MasterAddressTracker(ZKWatcher watcher, Abortable abortable) { - super(watcher, watcher.znodePaths.masterAddressZNode, abortable); + super(watcher, watcher.getZNodePaths().masterAddressZNode, abortable); } /** @@ -101,7 +101,7 @@ public class MasterAddressTracker extends ZKNodeTracker { * @return info port or 0 if timed out or exceptions */ public int getBackupMasterInfoPort(final ServerName sn) { - String backupZNode = ZNodePaths.joinZNode(watcher.znodePaths.backupMasterAddressesZNode, + String backupZNode = ZNodePaths.joinZNode(watcher.getZNodePaths().backupMasterAddressesZNode, sn.toString()); try { byte[] data = ZKUtil.getData(watcher, backupZNode); @@ -147,7 +147,7 @@ public class MasterAddressTracker extends ZKNodeTracker { throws KeeperException, IOException { byte [] data; try { - data = ZKUtil.getData(zkw, zkw.znodePaths.masterAddressZNode); + data = ZKUtil.getData(zkw, zkw.getZNodePaths().masterAddressZNode); } catch (InterruptedException e) { throw new InterruptedIOException(); } @@ -178,7 +178,7 @@ public class MasterAddressTracker extends ZKNodeTracker { public static int getMasterInfoPort(final ZKWatcher zkw) throws KeeperException, IOException { byte[] data; try { - data = ZKUtil.getData(zkw, zkw.znodePaths.masterAddressZNode); + data = ZKUtil.getData(zkw, zkw.getZNodePaths().masterAddressZNode); } catch (InterruptedException e) { throw new InterruptedIOException(); } @@ -208,7 +208,7 @@ public class MasterAddressTracker extends ZKNodeTracker { */ public static boolean setMasterAddress(final ZKWatcher zkw, final String znode, final ServerName master, int infoPort) - throws KeeperException { + throws KeeperException { return ZKUtil.createEphemeralNodeAndWatch(zkw, znode, toByteArray(master, infoPort)); } @@ -265,10 +265,10 @@ public class MasterAddressTracker extends ZKNodeTracker { try { Stat stat = new Stat(); - byte[] data = ZKUtil.getDataNoWatch(zkw, zkw.znodePaths.masterAddressZNode, stat); + byte[] data = ZKUtil.getDataNoWatch(zkw, zkw.getZNodePaths().masterAddressZNode, stat); ServerName sn = ProtobufUtil.parseServerNameFrom(data); if (sn != null && content.equals(sn.toString())) { - return (ZKUtil.deleteNode(zkw, zkw.znodePaths.masterAddressZNode, stat.getVersion())); + return (ZKUtil.deleteNode(zkw, zkw.getZNodePaths().masterAddressZNode, stat.getVersion())); } } catch (KeeperException e) { LOG.warn("Can't get or delete the master znode", e); diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterMaintenanceModeTracker.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterMaintenanceModeTracker.java index 952da6f2e64..9dafe5fede3 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterMaintenanceModeTracker.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterMaintenanceModeTracker.java @@ -40,7 +40,7 @@ public class MasterMaintenanceModeTracker extends ZKListener { } private void update(String path) { - if (path.startsWith(watcher.znodePaths.masterMaintZNode)) { + if (path.startsWith(watcher.getZNodePaths().masterMaintZNode)) { update(); } } @@ -48,7 +48,8 @@ public class MasterMaintenanceModeTracker extends ZKListener { private void update() { try { List children = - ZKUtil.listChildrenAndWatchForNewChildren(watcher, watcher.znodePaths.masterMaintZNode); + ZKUtil.listChildrenAndWatchForNewChildren(watcher, + watcher.getZNodePaths().masterMaintZNode); hasChildren = (children != null && children.size() > 0); } catch (KeeperException e) { // Ignore the ZK keeper exception diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java index 76c12d0c84e..7f0fb113094 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java @@ -191,7 +191,7 @@ public class MetaTableLocator { * @throws NotAllMetaRegionsOnlineException if a meta or root region is not online */ public ServerName waitMetaRegionLocation(ZKWatcher zkw, long timeout) - throws InterruptedException, NotAllMetaRegionsOnlineException { + throws InterruptedException, NotAllMetaRegionsOnlineException { return waitMetaRegionLocation(zkw, RegionInfo.DEFAULT_REPLICA_ID, timeout); } @@ -209,9 +209,9 @@ public class MetaTableLocator { * @throws NotAllMetaRegionsOnlineException if a meta or root region is not online */ public ServerName waitMetaRegionLocation(ZKWatcher zkw, int replicaId, long timeout) - throws InterruptedException, NotAllMetaRegionsOnlineException { + throws InterruptedException, NotAllMetaRegionsOnlineException { try { - if (ZKUtil.checkExists(zkw, zkw.znodePaths.baseZNode) == -1) { + if (ZKUtil.checkExists(zkw, zkw.getZNodePaths().baseZNode) == -1) { String errorMsg = "Check the value configured in 'zookeeper.znode.parent'. " + "There could be a mismatch with the one configured in the master."; LOG.error(errorMsg); @@ -388,7 +388,7 @@ public class MetaTableLocator { service = connection.getAdmin(sn); } catch (RetriesExhaustedException e) { if (e.getCause() != null && e.getCause() instanceof ConnectException) { - // Catch this; presume it means the cached connection has gone bad. + LOG.debug("Catch this; presume it means the cached connection has gone bad."); } else { throw e; } @@ -407,12 +407,12 @@ public class MetaTableLocator { } catch (IOException ioe) { Throwable cause = ioe.getCause(); if (ioe instanceof ConnectException) { - // Catch. Connect refused. + LOG.debug("Catch. Connect refused."); } else if (cause != null && cause instanceof EOFException) { - // Catch. Other end disconnected us. + LOG.debug("Catch. Other end disconnected us."); } else if (cause != null && cause.getMessage() != null && cause.getMessage().toLowerCase(Locale.ROOT).contains("connection reset")) { - // Catch. Connection reset. + LOG.debug("Catch. Connection reset."); } else { throw ioe; } @@ -460,7 +460,7 @@ public class MetaTableLocator { byte[] data = ProtobufUtil.prependPBMagic(pbrsr.toByteArray()); try { ZKUtil.setData(zookeeper, - zookeeper.znodePaths.getZNodeForReplica(replicaId), data); + zookeeper.getZNodePaths().getZNodeForReplica(replicaId), data); } catch(KeeperException.NoNodeException nne) { if (replicaId == RegionInfo.DEFAULT_REPLICA_ID) { LOG.debug("META region location doesn't exist, create it"); @@ -468,7 +468,8 @@ public class MetaTableLocator { LOG.debug("META region location doesn't exist for replicaId=" + replicaId + ", create it"); } - ZKUtil.createAndWatch(zookeeper, zookeeper.znodePaths.getZNodeForReplica(replicaId), data); + ZKUtil.createAndWatch(zookeeper, zookeeper.getZNodePaths().getZNodeForReplica(replicaId), + data); } } @@ -492,7 +493,7 @@ public class MetaTableLocator { RegionState.State state = RegionState.State.OPEN; ServerName serverName = null; try { - byte[] data = ZKUtil.getData(zkw, zkw.znodePaths.getZNodeForReplica(replicaId)); + byte[] data = ZKUtil.getData(zkw, zkw.getZNodePaths().getZNodeForReplica(replicaId)); if (data != null && data.length > 0 && ProtobufUtil.isPBMagicPrefix(data)) { try { int prefixLen = ProtobufUtil.lengthOfPBMagic(); @@ -532,12 +533,12 @@ public class MetaTableLocator { * @throws KeeperException unexpected zookeeper exception */ public void deleteMetaLocation(ZKWatcher zookeeper) - throws KeeperException { + throws KeeperException { deleteMetaLocation(zookeeper, RegionInfo.DEFAULT_REPLICA_ID); } public void deleteMetaLocation(ZKWatcher zookeeper, int replicaId) - throws KeeperException { + throws KeeperException { if (replicaId == RegionInfo.DEFAULT_REPLICA_ID) { LOG.info("Deleting hbase:meta region location in ZooKeeper"); } else { @@ -545,7 +546,7 @@ public class MetaTableLocator { } try { // Just delete the node. Don't need any watches. - ZKUtil.deleteNode(zookeeper, zookeeper.znodePaths.getZNodeForReplica(replicaId)); + ZKUtil.deleteNode(zookeeper, zookeeper.getZNodePaths().getZNodeForReplica(replicaId)); } catch(KeeperException.NoNodeException nne) { // Has already been deleted } diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java index 9343ec29312..c23e3d22546 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java @@ -85,7 +85,7 @@ public class RecoverableZooKeeper { public RecoverableZooKeeper(String quorumServers, int sessionTimeout, Watcher watcher, int maxRetries, int retryIntervalMillis, int maxSleepTime) - throws IOException { + throws IOException { this(quorumServers, sessionTimeout, watcher, maxRetries, retryIntervalMillis, maxSleepTime, null); } @@ -94,7 +94,7 @@ public class RecoverableZooKeeper { justification="None. Its always been this way.") public RecoverableZooKeeper(String quorumServers, int sessionTimeout, Watcher watcher, int maxRetries, int retryIntervalMillis, int maxSleepTime, String identifier) - throws IOException { + throws IOException { // TODO: Add support for zk 'chroot'; we don't add it to the quorumServers String as we should. this.retryCounterFactory = new RetryCounterFactory(maxRetries+1, retryIntervalMillis, maxSleepTime); @@ -300,7 +300,7 @@ public class RecoverableZooKeeper { * @return List of children znodes */ public List getChildren(String path, boolean watch) - throws KeeperException, InterruptedException { + throws KeeperException, InterruptedException { try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.getChildren")) { RetryCounter retryCounter = retryCounterFactory.create(); while (true) { @@ -331,7 +331,7 @@ public class RecoverableZooKeeper { * @return Data */ public byte[] getData(String path, Watcher watcher, Stat stat) - throws KeeperException, InterruptedException { + throws KeeperException, InterruptedException { try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.getData")) { RetryCounter retryCounter = retryCounterFactory.create(); while (true) { @@ -362,7 +362,7 @@ public class RecoverableZooKeeper { * @return Data */ public byte[] getData(String path, boolean watch, Stat stat) - throws KeeperException, InterruptedException { + throws KeeperException, InterruptedException { try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.getData")) { RetryCounter retryCounter = retryCounterFactory.create(); while (true) { @@ -395,7 +395,7 @@ public class RecoverableZooKeeper { * @return Stat instance */ public Stat setData(String path, byte[] data, int version) - throws KeeperException, InterruptedException { + throws KeeperException, InterruptedException { try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.setData")) { RetryCounter retryCounter = retryCounterFactory.create(); byte[] newData = ZKMetadata.appendMetaData(id, data); @@ -445,7 +445,7 @@ public class RecoverableZooKeeper { * @return list of ACLs */ public List getAcl(String path, Stat stat) - throws KeeperException, InterruptedException { + throws KeeperException, InterruptedException { try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.getAcl")) { RetryCounter retryCounter = retryCounterFactory.create(); while (true) { @@ -476,7 +476,7 @@ public class RecoverableZooKeeper { * @return list of ACLs */ public Stat setAcl(String path, List acls, int version) - throws KeeperException, InterruptedException { + throws KeeperException, InterruptedException { try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.setAcl")) { RetryCounter retryCounter = retryCounterFactory.create(); while (true) { @@ -519,7 +519,7 @@ public class RecoverableZooKeeper { */ public String create(String path, byte[] data, List acl, CreateMode createMode) - throws KeeperException, InterruptedException { + throws KeeperException, InterruptedException { try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.create")) { byte[] newData = ZKMetadata.appendMetaData(id, data); switch (createMode) { @@ -587,7 +587,7 @@ public class RecoverableZooKeeper { private String createSequential(String path, byte[] data, List acl, CreateMode createMode) - throws KeeperException, InterruptedException { + throws KeeperException, InterruptedException { RetryCounter retryCounter = retryCounterFactory.create(); boolean first = true; String newPath = path+this.identifier; @@ -653,7 +653,7 @@ public class RecoverableZooKeeper { * Run multiple operations in a transactional manner. Retry before throwing exception */ public List multi(Iterable ops) - throws KeeperException, InterruptedException { + throws KeeperException, InterruptedException { try (TraceScope scope = TraceUtil.createTrace("RecoverableZookeeper.multi")) { RetryCounter retryCounter = retryCounterFactory.create(); Iterable multiOps = prepareZKMulti(ops); diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionNormalizerTracker.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionNormalizerTracker.java index 7413879b0b8..d69e75094b6 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionNormalizerTracker.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionNormalizerTracker.java @@ -38,7 +38,7 @@ public class RegionNormalizerTracker extends ZKNodeTracker { private static final Logger LOG = LoggerFactory.getLogger(RegionNormalizerTracker.class); public RegionNormalizerTracker(ZKWatcher watcher, Abortable abortable) { - super(watcher, watcher.znodePaths.regionNormalizerZNode, abortable); + super(watcher, watcher.getZNodePaths().regionNormalizerZNode, abortable); } /** @@ -65,11 +65,11 @@ public class RegionNormalizerTracker extends ZKNodeTracker { public void setNormalizerOn(boolean normalizerOn) throws KeeperException { byte [] upData = toByteArray(normalizerOn); try { - ZKUtil.setData(watcher, watcher.znodePaths.regionNormalizerZNode, upData); + ZKUtil.setData(watcher, watcher.getZNodePaths().regionNormalizerZNode, upData); } catch(KeeperException.NoNodeException nne) { - ZKUtil.createAndWatch(watcher, watcher.znodePaths.regionNormalizerZNode, upData); + ZKUtil.createAndWatch(watcher, watcher.getZNodePaths().regionNormalizerZNode, upData); } - super.nodeDataChanged(watcher.znodePaths.regionNormalizerZNode); + super.nodeDataChanged(watcher.getZNodePaths().regionNormalizerZNode); } private byte [] toByteArray(boolean isNormalizerOn) { diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAclReset.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAclReset.java index 50a6f5e78fe..03a28469c04 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAclReset.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAclReset.java @@ -70,8 +70,8 @@ public class ZKAclReset extends Configured implements Tool { ZKWatcher zkw = new ZKWatcher(conf, "ZKAclReset", null); try { LOG.info((eraseAcls ? "Erase" : "Set") + " HBase ACLs for " + - zkw.getQuorum() + " " + zkw.znodePaths.baseZNode); - resetAcls(zkw, zkw.znodePaths.baseZNode, eraseAcls); + zkw.getQuorum() + " " + zkw.getZNodePaths().baseZNode); + resetAcls(zkw, zkw.getZNodePaths().baseZNode, eraseAcls); } finally { zkw.close(); } diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKClusterId.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKClusterId.java index be2529b054f..a093f615b51 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKClusterId.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKClusterId.java @@ -61,11 +61,11 @@ public class ZKClusterId { } public static String readClusterIdZNode(ZKWatcher watcher) - throws KeeperException { - if (ZKUtil.checkExists(watcher, watcher.znodePaths.clusterIdZNode) != -1) { + throws KeeperException { + if (ZKUtil.checkExists(watcher, watcher.getZNodePaths().clusterIdZNode) != -1) { byte [] data; try { - data = ZKUtil.getData(watcher, watcher.znodePaths.clusterIdZNode); + data = ZKUtil.getData(watcher, watcher.getZNodePaths().clusterIdZNode); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return null; @@ -83,7 +83,7 @@ public class ZKClusterId { public static void setClusterId(ZKWatcher watcher, ClusterId id) throws KeeperException { - ZKUtil.createSetData(watcher, watcher.znodePaths.clusterIdZNode, id.toByteArray()); + ZKUtil.createSetData(watcher, watcher.getZNodePaths().clusterIdZNode, id.toByteArray()); } /** diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKMainServer.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKMainServer.java index 2488682bcbc..b2478cee67a 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKMainServer.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKMainServer.java @@ -46,7 +46,7 @@ public class ZKMainServer { */ private static class HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain extends ZooKeeperMain { public HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain(String[] args) - throws IOException, InterruptedException { + throws IOException, InterruptedException { super(args); // Make sure we are connected before we proceed. Can take a while on some systems. If we // run the command without being connected, we get ConnectionLoss KeeperErrorConnection... @@ -57,9 +57,9 @@ public class ZKMainServer { /** * Run the command-line args passed. Calls System.exit when done. - * @throws KeeperException - * @throws IOException - * @throws InterruptedException + * @throws KeeperException if an unexpected ZooKeeper exception happens + * @throws IOException in case of a network failure + * @throws InterruptedException if the ZooKeeper client closes */ void runCmdLine() throws KeeperException, IOException, InterruptedException { processCmd(this.cl); diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKNodeTracker.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKNodeTracker.java index f76947b2c89..5806e5b4429 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKNodeTracker.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKNodeTracker.java @@ -102,7 +102,7 @@ public abstract class ZKNodeTracker extends ZKListener { * @throws InterruptedException if the waiting thread is interrupted */ public synchronized byte [] blockUntilAvailable() - throws InterruptedException { + throws InterruptedException { return blockUntilAvailable(0, false); } @@ -238,11 +238,11 @@ public abstract class ZKNodeTracker extends ZKListener { */ public boolean checkIfBaseNodeAvailable() { try { - if (ZKUtil.checkExists(watcher, watcher.znodePaths.baseZNode) == -1) { + if (ZKUtil.checkExists(watcher, watcher.getZNodePaths().baseZNode) == -1) { return false; } } catch (KeeperException e) { - abortable.abort("Exception while checking if basenode (" + watcher.znodePaths.baseZNode + abortable.abort("Exception while checking if basenode (" + watcher.getZNodePaths().baseZNode + ") exists in ZooKeeper.", e); } diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKSplitLog.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKSplitLog.java index b58c98cde6d..f93307010a7 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKSplitLog.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKSplitLog.java @@ -47,7 +47,7 @@ public final class ZKSplitLog { * @param filename log file name (only the basename) */ public static String getEncodedNodeName(ZKWatcher zkw, String filename) { - return ZNodePaths.joinZNode(zkw.znodePaths.splitLogZNode, encode(filename)); + return ZNodePaths.joinZNode(zkw.getZNodePaths().splitLogZNode, encode(filename)); } public static String getFileName(String node) { @@ -72,7 +72,7 @@ public final class ZKSplitLog { } public static String getRescanNode(ZKWatcher zkw) { - return ZNodePaths.joinZNode(zkw.znodePaths.splitLogZNode, "RESCAN"); + return ZNodePaths.joinZNode(zkw.getZNodePaths().splitLogZNode, "RESCAN"); } /** diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java index f1cacbf3584..9153191975c 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java @@ -108,20 +108,20 @@ public final class ZKUtil { * @throws IOException if unable to connect to zk or config problem */ public static RecoverableZooKeeper connect(Configuration conf, Watcher watcher) - throws IOException { + throws IOException { String ensemble = ZKConfig.getZKQuorumServersString(conf); return connect(conf, ensemble, watcher); } public static RecoverableZooKeeper connect(Configuration conf, String ensemble, Watcher watcher) - throws IOException { + throws IOException { return connect(conf, ensemble, watcher, null); } public static RecoverableZooKeeper connect(Configuration conf, String ensemble, Watcher watcher, final String identifier) - throws IOException { + throws IOException { if(ensemble == null) { throw new IOException("Unable to determine ZooKeeper ensemble"); } @@ -347,7 +347,7 @@ public final class ZKUtil { * @throws KeeperException if unexpected zookeeper exception */ public static boolean watchAndCheckExists(ZKWatcher zkw, String znode) - throws KeeperException { + throws KeeperException { try { Stat s = zkw.getRecoverableZooKeeper().exists(znode, zkw); boolean exists = s != null ? true : false; @@ -401,7 +401,7 @@ public final class ZKUtil { * @throws KeeperException if unexpected zookeeper exception */ public static int checkExists(ZKWatcher zkw, String znode) - throws KeeperException { + throws KeeperException { try { Stat s = zkw.getRecoverableZooKeeper().exists(znode, null); return s != null ? s.getVersion() : -1; @@ -438,7 +438,7 @@ public final class ZKUtil { */ public static List listChildrenAndWatchForNewChildren( ZKWatcher zkw, String znode) - throws KeeperException { + throws KeeperException { try { List children = zkw.getRecoverableZooKeeper().getChildren(znode, zkw); return children; @@ -493,7 +493,7 @@ public final class ZKUtil { * @throws KeeperException if unexpected zookeeper exception */ public static List listChildrenNoWatch(ZKWatcher zkw, String znode) - throws KeeperException { + throws KeeperException { List children = null; try { // List the children without watching @@ -550,7 +550,7 @@ public final class ZKUtil { * @throws KeeperException if unexpected zookeeper exception */ public static boolean nodeHasChildren(ZKWatcher zkw, String znode) - throws KeeperException { + throws KeeperException { try { return !zkw.getRecoverableZooKeeper().getChildren(znode, null).isEmpty(); } catch(KeeperException.NoNodeException ke) { @@ -582,7 +582,7 @@ public final class ZKUtil { * @throws KeeperException if unexpected zookeeper exception */ public static int getNumberOfChildren(ZKWatcher zkw, String znode) - throws KeeperException { + throws KeeperException { try { Stat stat = zkw.getRecoverableZooKeeper().exists(znode, null); return stat == null ? 0 : stat.getNumChildren(); @@ -633,7 +633,7 @@ public final class ZKUtil { * @throws KeeperException if unexpected zookeeper exception */ public static byte [] getDataAndWatch(ZKWatcher zkw, String znode) - throws KeeperException { + throws KeeperException { return getDataInternal(zkw, znode, null, true); } @@ -695,7 +695,7 @@ public final class ZKUtil { */ public static byte [] getDataNoWatch(ZKWatcher zkw, String znode, Stat stat) - throws KeeperException { + throws KeeperException { try { byte [] data = zkw.getRecoverableZooKeeper().getData(znode, null, stat); logRetrievedMsg(zkw, znode, data, false); @@ -801,7 +801,7 @@ public final class ZKUtil { */ public static boolean setData(ZKWatcher zkw, String znode, byte [] data, int expectedVersion) - throws KeeperException, KeeperException.NoNodeException { + throws KeeperException, KeeperException.NoNodeException { try { return zkw.getRecoverableZooKeeper().setData(znode, data, expectedVersion) != null; } catch (InterruptedException e) { @@ -845,12 +845,12 @@ public final class ZKUtil { * @throws KeeperException if unexpected zookeeper exception */ public static void setData(ZKWatcher zkw, String znode, byte [] data) - throws KeeperException, KeeperException.NoNodeException { + throws KeeperException, KeeperException.NoNodeException { setData(zkw, (SetData)ZKUtilOp.setData(znode, data)); } private static void setData(ZKWatcher zkw, SetData setData) - throws KeeperException, KeeperException.NoNodeException { + throws KeeperException, KeeperException.NoNodeException { SetDataRequest sd = (SetDataRequest)toZooKeeperOp(zkw, setData).toRequestRecord(); setData(zkw, sd.getPath(), sd.getData(), sd.getVersion()); } @@ -891,7 +891,7 @@ public final class ZKUtil { public static ArrayList createACL(ZKWatcher zkw, String node, boolean isSecureZooKeeper) { - if (!node.startsWith(zkw.znodePaths.baseZNode)) { + if (!node.startsWith(zkw.getZNodePaths().baseZNode)) { return Ids.OPEN_ACL_UNSAFE; } if (isSecureZooKeeper) { @@ -923,7 +923,7 @@ public final class ZKUtil { } // Certain znodes are accessed directly by the client, // so they must be readable by non-authenticated clients - if (zkw.znodePaths.isClientReadable(node)) { + if (zkw.getZNodePaths().isClientReadable(node)) { acls.addAll(Ids.CREATOR_ALL_ACL); acls.addAll(Ids.READ_ACL_UNSAFE); } else { @@ -959,7 +959,7 @@ public final class ZKUtil { */ public static boolean createEphemeralNodeAndWatch(ZKWatcher zkw, String znode, byte [] data) - throws KeeperException { + throws KeeperException { boolean ret = true; try { zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode), @@ -999,7 +999,7 @@ public final class ZKUtil { */ public static boolean createNodeIfNotExistsAndWatch( ZKWatcher zkw, String znode, byte [] data) - throws KeeperException { + throws KeeperException { boolean ret = true; try { zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode), @@ -1066,7 +1066,7 @@ public final class ZKUtil { */ public static int createAndWatch(ZKWatcher zkw, String znode, byte [] data) - throws KeeperException, KeeperException.NodeExistsException { + throws KeeperException, KeeperException.NodeExistsException { try { zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode), CreateMode.PERSISTENT); @@ -1132,13 +1132,13 @@ public final class ZKUtil { */ public static void createAndFailSilent(ZKWatcher zkw, String znode, byte[] data) - throws KeeperException { + throws KeeperException { createAndFailSilent(zkw, (CreateAndFailSilent)ZKUtilOp.createAndFailSilent(znode, data)); } private static void createAndFailSilent(ZKWatcher zkw, CreateAndFailSilent cafs) - throws KeeperException { + throws KeeperException { CreateRequest create = (CreateRequest)toZooKeeperOp(zkw, cafs).toRequestRecord(); String znode = create.getPath(); try { @@ -1173,7 +1173,7 @@ public final class ZKUtil { * @throws KeeperException if unexpected zookeeper exception */ public static void createWithParents(ZKWatcher zkw, String znode) - throws KeeperException { + throws KeeperException { createWithParents(zkw, znode, new byte[0]); } @@ -1191,7 +1191,7 @@ public final class ZKUtil { * @throws KeeperException if unexpected zookeeper exception */ public static void createWithParents(ZKWatcher zkw, String znode, byte[] data) - throws KeeperException { + throws KeeperException { try { if(znode == null) { return; @@ -1216,7 +1216,7 @@ public final class ZKUtil { * Delete the specified node. Sets no watches. Throws all exceptions. */ public static void deleteNode(ZKWatcher zkw, String node) - throws KeeperException { + throws KeeperException { deleteNode(zkw, node, -1); } @@ -1226,7 +1226,7 @@ public final class ZKUtil { */ public static boolean deleteNode(ZKWatcher zkw, String node, int version) - throws KeeperException { + throws KeeperException { try { zkw.getRecoverableZooKeeper().delete(node, version); return true; @@ -1246,7 +1246,7 @@ public final class ZKUtil { * @throws KeeperException if a ZooKeeper operation fails */ public static void deleteNodeFailSilent(ZKWatcher zkw, String node) - throws KeeperException { + throws KeeperException { deleteNodeFailSilent(zkw, (DeleteNodeFailSilent)ZKUtilOp.deleteNodeFailSilent(node)); } @@ -1272,7 +1272,7 @@ public final class ZKUtil { * children. */ public static void deleteNodeRecursively(ZKWatcher zkw, String node) - throws KeeperException { + throws KeeperException { deleteNodeRecursivelyMultiOrSequential(zkw, true, node); } @@ -1735,7 +1735,7 @@ public final class ZKUtil { public static String dump(ZKWatcher zkw) { StringBuilder sb = new StringBuilder(); try { - sb.append("HBase is rooted at ").append(zkw.znodePaths.baseZNode); + sb.append("HBase is rooted at ").append(zkw.getZNodePaths().baseZNode); sb.append("\nActive master address: "); try { sb.append(MasterAddressTracker.getMasterAddress(zkw)); @@ -1743,7 +1743,8 @@ public final class ZKUtil { sb.append("<>"); } sb.append("\nBackup master addresses:"); - for (String child : listChildrenNoWatch(zkw, zkw.znodePaths.backupMasterAddressesZNode)) { + for (String child : listChildrenNoWatch(zkw, + zkw.getZNodePaths().backupMasterAddressesZNode)) { sb.append("\n ").append(child); } sb.append("\nRegion server holding hbase:meta: " @@ -1756,7 +1757,7 @@ public final class ZKUtil { + new MetaTableLocator().getMetaRegionLocation(zkw, i)); } sb.append("\nRegion servers:"); - for (String child : listChildrenNoWatch(zkw, zkw.znodePaths.rsZNode)) { + for (String child : listChildrenNoWatch(zkw, zkw.getZNodePaths().rsZNode)) { sb.append("\n ").append(child); } try { @@ -1799,7 +1800,7 @@ public final class ZKUtil { */ private static void getReplicationZnodesDump(ZKWatcher zkw, StringBuilder sb) throws KeeperException { - String replicationZnode = zkw.znodePaths.replicationZNode; + String replicationZnode = zkw.getZNodePaths().replicationZNode; if (ZKUtil.checkExists(zkw, replicationZnode) == -1) { return; @@ -1810,11 +1811,11 @@ public final class ZKUtil { List children = ZKUtil.listChildrenNoWatch(zkw, replicationZnode); for (String child : children) { String znode = ZNodePaths.joinZNode(replicationZnode, child); - if (znode.equals(zkw.znodePaths.peersZNode)) { + if (znode.equals(zkw.getZNodePaths().peersZNode)) { appendPeersZnodes(zkw, znode, sb); - } else if (znode.equals(zkw.znodePaths.queuesZNode)) { + } else if (znode.equals(zkw.getZNodePaths().queuesZNode)) { appendRSZnodes(zkw, znode, sb); - } else if (znode.equals(zkw.znodePaths.hfileRefsZNode)) { + } else if (znode.equals(zkw.getZNodePaths().hfileRefsZNode)) { appendHFileRefsZnodes(zkw, znode, sb); } } @@ -1944,7 +1945,7 @@ public final class ZKUtil { * @throws IOException When the socket communication fails. */ public static String[] getServerStats(String server, int timeout) - throws IOException { + throws IOException { String[] sp = server.split(":"); if (sp == null || sp.length == 0) { return null; @@ -1989,9 +1990,9 @@ public final class ZKUtil { " byte(s) of data from znode " + znode + (watcherSet? " and set watcher; ": "; data=") + (data == null? "null": data.length == 0? "empty": ( - znode.startsWith(zkw.znodePaths.metaZNodePrefix)? + znode.startsWith(zkw.getZNodePaths().metaZNodePrefix)? getServerNameOrEmptyString(data): - znode.startsWith(zkw.znodePaths.backupMasterAddressesZNode)? + znode.startsWith(zkw.getZNodePaths().backupMasterAddressesZNode)? getServerNameOrEmptyString(data): StringUtils.abbreviate(Bytes.toStringBinary(data), 32))))); } diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java index c3cac5f3d20..cceedfd326c 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java @@ -76,14 +76,14 @@ public class ZKWatcher implements Watcher, Abortable, Closeable { // Used if abortable is null private boolean aborted = false; - public final ZNodePaths znodePaths; + private final ZNodePaths znodePaths; // listeners to be notified private final List listeners = new CopyOnWriteArrayList<>(); // Used by ZKUtil:waitForZKConnectionIfAuthenticating to wait for SASL // negotiation to complete - public CountDownLatch saslLatch = new CountDownLatch(1); + private CountDownLatch saslLatch = new CountDownLatch(1); private final Configuration conf; @@ -95,7 +95,7 @@ public class ZKWatcher implements Watcher, Abortable, Closeable { * @param identifier string that is passed to RecoverableZookeeper to be used as * identifier for this instance. Use null for default. * @throws IOException if the connection to ZooKeeper fails - * @throws ZooKeeperConnectionException + * @throws ZooKeeperConnectionException if the client can't connect to ZooKeeper */ public ZKWatcher(Configuration conf, String identifier, Abortable abortable) throws ZooKeeperConnectionException, IOException { @@ -111,11 +111,11 @@ public class ZKWatcher implements Watcher, Abortable, Closeable { * context. * @param canCreateBaseZNode true if a base ZNode can be created * @throws IOException if the connection to ZooKeeper fails - * @throws ZooKeeperConnectionException + * @throws ZooKeeperConnectionException if the client can't connect to ZooKeeper */ public ZKWatcher(Configuration conf, String identifier, Abortable abortable, boolean canCreateBaseZNode) - throws IOException, ZooKeeperConnectionException { + throws IOException, ZooKeeperConnectionException { this(conf, identifier, abortable, canCreateBaseZNode, false); } @@ -517,6 +517,8 @@ public class ZKWatcher implements Watcher, Abortable, Closeable { } break; } + default: + throw new IllegalStateException("Received event is not valid: " + event.getState()); } } diff --git a/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKLeaderManager.java b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKLeaderManager.java index 8371f91c318..432779e9ebd 100644 --- a/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKLeaderManager.java +++ b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKLeaderManager.java @@ -18,7 +18,6 @@ package org.apache.hadoop.hbase.zookeeper; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; diff --git a/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMainServer.java b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMainServer.java index f8052603c1d..d1c18d3548e 100644 --- a/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMainServer.java +++ b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMainServer.java @@ -43,7 +43,7 @@ public class TestZKMainServer { // http://stackoverflow.com/questions/309396/java-how-to-test-methods-that-call-system-exit protected static class ExitException extends SecurityException { private static final long serialVersionUID = 1L; - public final int status; + private final int status; public ExitException(int status) { super("There is no escape!"); this.status = status; diff --git a/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMulti.java b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMulti.java index 55e7aa8e5d1..0f2472ba9ed 100644 --- a/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMulti.java +++ b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMulti.java @@ -90,7 +90,7 @@ public class TestZKMulti { ZKUtil.multiOrSequential(zkw, new LinkedList<>(), false); // single create - String path = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testSimpleMulti"); + String path = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testSimpleMulti"); LinkedList singleCreate = new LinkedList<>(); singleCreate.add(ZKUtilOp.createAndFailSilent(path, new byte[0])); ZKUtil.multiOrSequential(zkw, singleCreate, false); @@ -112,12 +112,12 @@ public class TestZKMulti { @Test public void testComplexMulti() throws Exception { - String path1 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti1"); - String path2 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti2"); - String path3 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti3"); - String path4 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti4"); - String path5 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti5"); - String path6 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testComplexMulti6"); + String path1 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testComplexMulti1"); + String path2 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testComplexMulti2"); + String path3 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testComplexMulti3"); + String path4 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testComplexMulti4"); + String path5 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testComplexMulti5"); + String path6 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testComplexMulti6"); // create 4 nodes that we'll setData on or delete later LinkedList create4Nodes = new LinkedList<>(); create4Nodes.add(ZKUtilOp.createAndFailSilent(path1, Bytes.toBytes(path1))); @@ -156,7 +156,7 @@ public class TestZKMulti { public void testSingleFailure() throws Exception { // try to delete a node that doesn't exist boolean caughtNoNode = false; - String path = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testSingleFailureZ"); + String path = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testSingleFailureZ"); LinkedList ops = new LinkedList<>(); ops.add(ZKUtilOp.deleteNodeFailSilent(path)); try { @@ -193,9 +193,9 @@ public class TestZKMulti { @Test public void testSingleFailureInMulti() throws Exception { // try a multi where all but one operation succeeds - String pathA = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testSingleFailureInMultiA"); - String pathB = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testSingleFailureInMultiB"); - String pathC = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testSingleFailureInMultiC"); + String pathA = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testSingleFailureInMultiA"); + String pathB = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testSingleFailureInMultiB"); + String pathC = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testSingleFailureInMultiC"); LinkedList ops = new LinkedList<>(); ops.add(ZKUtilOp.createAndFailSilent(pathA, Bytes.toBytes(pathA))); ops.add(ZKUtilOp.createAndFailSilent(pathB, Bytes.toBytes(pathB))); @@ -215,17 +215,17 @@ public class TestZKMulti { @Test public void testMultiFailure() throws Exception { - String pathX = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureX"); - String pathY = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureY"); - String pathZ = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureZ"); + String pathX = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testMultiFailureX"); + String pathY = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testMultiFailureY"); + String pathZ = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testMultiFailureZ"); // create X that we will use to fail create later LinkedList ops = new LinkedList<>(); ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathX))); ZKUtil.multiOrSequential(zkw, ops, false); // fail one of each create ,setData, delete - String pathV = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureV"); - String pathW = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureW"); + String pathV = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testMultiFailureV"); + String pathW = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testMultiFailureW"); ops = new LinkedList<>(); ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathX))); // fail -- already exists ops.add(ZKUtilOp.setData(pathY, Bytes.toBytes(pathY))); // fail -- doesn't exist @@ -269,10 +269,10 @@ public class TestZKMulti { @Test public void testRunSequentialOnMultiFailure() throws Exception { - String path1 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "runSequential1"); - String path2 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "runSequential2"); - String path3 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "runSequential3"); - String path4 = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "runSequential4"); + String path1 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "runSequential1"); + String path2 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "runSequential2"); + String path3 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "runSequential3"); + String path4 = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "runSequential4"); // create some nodes that we will use later LinkedList ops = new LinkedList<>(); diff --git a/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKNodeTracker.java b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKNodeTracker.java index 9e90177ea34..8b059bc1013 100644 --- a/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKNodeTracker.java +++ b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKNodeTracker.java @@ -99,9 +99,9 @@ public class TestZKNodeTracker { Abortable abortable = new StubAbortable(); ZKWatcher zk = new ZKWatcher(TEST_UTIL.getConfiguration(), "testNodeTracker", abortable); - ZKUtil.createAndFailSilent(zk, zk.znodePaths.baseZNode); + ZKUtil.createAndFailSilent(zk, zk.getZNodePaths().baseZNode); - final String node = ZNodePaths.joinZNode(zk.znodePaths.baseZNode, + final String node = ZNodePaths.joinZNode(zk.getZNodePaths().baseZNode, Long.toString(ThreadLocalRandom.current().nextLong())); final byte [] dataOne = Bytes.toBytes("dataOne"); @@ -322,7 +322,7 @@ public class TestZKNodeTracker { TEST_UTIL.getConfiguration().get(HConstants.ZOOKEEPER_ZNODE_PARENT, HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT)); - final String nodeName = zkw.znodePaths.masterAddressZNode; + final String nodeName = zkw.getZNodePaths().masterAddressZNode; // Check that we manage the case when there is no data ZKUtil.createAndFailSilent(zkw, nodeName); diff --git a/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKUtilNoServer.java b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKUtilNoServer.java index 99ec35ebab7..c8cc0eb2eee 100644 --- a/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKUtilNoServer.java +++ b/hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKUtilNoServer.java @@ -112,7 +112,7 @@ public class TestZKUtilNoServer { } }; Mockito.doThrow(new InterruptedException()).when(recoverableZk) - .getChildren(zkw.znodePaths.baseZNode, null); - ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.baseZNode); + .getChildren(zkw.getZNodePaths().baseZNode, null); + ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().baseZNode); } }