accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwa...@apache.org
Subject [accumulo] branch master updated: Retrieve more from ClientContext (#586)
Date Thu, 09 Aug 2018 14:40:50 GMT
This is an automated email from the ASF dual-hosted git repository.

mwalch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new 0479553  Retrieve more from ClientContext (#586)
0479553 is described below

commit 04795533f9311d99466c84c0001aa70d52130fcf
Author: Mike Walch <mwalch@apache.org>
AuthorDate: Thu Aug 9 10:40:47 2018 -0400

    Retrieve more from ClientContext (#586)
    
    * Refactor code to pull ZooKeeperRoot and ZooCache from context
---
 .../accumulo/core/client/impl/ClientContext.java   |  4 ++
 .../core/client/impl/ConditionalWriterImpl.java    |  9 +---
 .../core/client/impl/InstanceOperationsImpl.java   |  7 +--
 .../accumulo/core/client/impl/Namespaces.java      | 16 ++-----
 .../core/client/impl/RootTabletLocator.java        | 19 ++------
 .../accumulo/core/client/impl/ServerClient.java    |  9 ++--
 .../apache/accumulo/core/client/impl/Tables.java   |  5 +--
 .../core/client/impl/ZookeeperLockChecker.java     | 10 +----
 .../core/client/impl/RootTabletLocatorTest.java    | 17 +++-----
 .../core/client/impl/ZookeeperLockCheckerTest.java | 17 +++-----
 .../accumulo/server/log/WalStateManager.java       |  3 +-
 .../accumulo/server/master/LiveTServerSet.java     | 10 ++---
 .../accumulo/server/problems/ProblemReports.java   |  4 +-
 .../org/apache/accumulo/server/util/Admin.java     |  4 +-
 .../accumulo/server/util/TabletServerLocks.java    |  2 +-
 .../apache/accumulo/gc/SimpleGarbageCollector.java |  3 +-
 .../java/org/apache/accumulo/master/Master.java    | 50 +++++++++++-----------
 .../org/apache/accumulo/master/MasterTime.java     |  3 +-
 .../accumulo/master/recovery/RecoveryManager.java  | 14 +++---
 .../replication/MasterReplicationCoordinator.java  |  6 +--
 .../accumulo/master/tableOps/RenameNamespace.java  |  5 +--
 .../accumulo/master/tableOps/RenameTable.java      |  3 +-
 .../master/tserverOps/ShutdownTServer.java         |  7 +--
 .../java/org/apache/accumulo/monitor/Monitor.java  |  9 ++--
 .../rest/tservers/TabletServerResource.java        |  3 +-
 .../monitor/util/AccumuloMonitorAppender.java      |  4 +-
 .../org/apache/accumulo/tserver/TabletServer.java  | 22 +++++-----
 .../org/apache/accumulo/tserver/log/LogSorter.java |  3 +-
 .../tserver/replication/ReplicationWorker.java     |  6 +--
 .../apache/accumulo/test/TransportCachingIT.java   |  6 +--
 .../test/functional/GarbageCollectorIT.java        |  2 +-
 .../accumulo/test/functional/ZombieTServer.java    |  4 +-
 32 files changed, 104 insertions(+), 182 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ClientContext.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ClientContext.java
index 58b6067..68c0aa5 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ClientContext.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ClientContext.java
@@ -363,4 +363,8 @@ public class ClientContext {
   public int getZooKeepersSessionTimeOut() {
     return info.getZooKeepersSessionTimeOut();
   }
+
+  public ZooCache getZooCache() {
+    return zooCache;
+  }
 }
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ConditionalWriterImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ConditionalWriterImpl.java
index 6378ec7..0a1f658 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ConditionalWriterImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ConditionalWriterImpl.java
@@ -78,9 +78,7 @@ import org.apache.accumulo.core.util.BadArgumentException;
 import org.apache.accumulo.core.util.ByteBufferUtil;
 import org.apache.accumulo.core.util.HostAndPort;
 import org.apache.accumulo.core.util.NamingThreadFactory;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.util.LoggingRunnable;
-import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
 import org.apache.accumulo.fate.zookeeper.ZooLock;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.LockID;
 import org.apache.commons.collections.map.LRUMap;
@@ -690,13 +688,10 @@ class ConditionalWriterImpl implements ConditionalWriter {
 
     long startTime = System.currentTimeMillis();
 
-    LockID lid = new LockID(ZooUtil.getRoot(context.getInstanceID()) + Constants.ZTSERVERS,
-        sessionId.lockId);
+    LockID lid = new LockID(context.getZooKeeperRoot() + Constants.ZTSERVERS, sessionId.lockId);
 
-    ZooCacheFactory zcf = new ZooCacheFactory();
     while (true) {
-      if (!ZooLock.isLockHeld(
-          zcf.getZooCache(context.getZooKeepers(), context.getZooKeepersSessionTimeOut()), lid)) {
+      if (!ZooLock.isLockHeld(context.getZooCache(), lid)) {
         // ACCUMULO-1152 added a tserver lock check to the tablet location cache, so this
         // invalidation prevents future attempts to contact the
         // tserver even its gone zombie and is still running w/o a lock
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java
index 41dc026..46d08ec 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java
@@ -40,9 +40,7 @@ import org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client;
 import org.apache.accumulo.core.trace.Tracer;
 import org.apache.accumulo.core.util.AddressUtil;
 import org.apache.accumulo.core.util.HostAndPort;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
-import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
 import org.apache.thrift.TException;
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
@@ -91,9 +89,8 @@ public class InstanceOperationsImpl implements InstanceOperations {
 
   @Override
   public List<String> getTabletServers() {
-    ZooCache cache = new ZooCacheFactory().getZooCache(context.getZooKeepers(),
-        context.getZooKeepersSessionTimeOut());
-    String path = ZooUtil.getRoot(context.getInstanceID()) + Constants.ZTSERVERS;
+    ZooCache cache = context.getZooCache();
+    String path = context.getZooKeeperRoot() + Constants.ZTSERVERS;
     List<String> results = new ArrayList<>();
     for (String candidate : cache.getChildren(path)) {
       List<String> children = cache.getChildren(path + "/" + candidate);
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/Namespaces.java b/core/src/main/java/org/apache/accumulo/core/client/impl/Namespaces.java
index 3e50ed9..bc6d81f 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/Namespaces.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/Namespaces.java
@@ -29,9 +29,7 @@ import java.util.function.BiConsumer;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.NamespaceNotFoundException;
 import org.apache.accumulo.core.util.Validator;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
-import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -78,15 +76,9 @@ public class Namespaces {
     }
   };
 
-  private static ZooCache getZooCache(ClientContext context) {
-    return new ZooCacheFactory().getZooCache(context.getZooKeepers(),
-        context.getZooKeepersSessionTimeOut());
-  }
-
   public static boolean exists(ClientContext context, Namespace.ID namespaceId) {
-    ZooCache zc = getZooCache(context);
-    List<String> namespaceIds = zc
-        .getChildren(ZooUtil.getRoot(context.getInstanceID()) + Constants.ZNAMESPACES);
+    ZooCache zc = context.getZooCache();
+    List<String> namespaceIds = zc.getChildren(context.getZooKeeperRoot() + Constants.ZNAMESPACES);
     return namespaceIds.contains(namespaceId.canonicalID());
   }
 
@@ -116,7 +108,7 @@ public class Namespaces {
    */
   private static void getAllNamespaces(ClientContext context,
       BiConsumer<String,String> biConsumer) {
-    final ZooCache zc = getZooCache(context);
+    final ZooCache zc = context.getZooCache();
     List<String> namespaceIds = zc.getChildren(context.getZooKeeperRoot() + Constants.ZNAMESPACES);
     for (String id : namespaceIds) {
       byte[] path = zc.get(context.getZooKeeperRoot() + Constants.ZNAMESPACES + "/" + id
@@ -188,7 +180,7 @@ public class Namespaces {
   public static String getNamespaceName(ClientContext context, Namespace.ID namespaceId)
       throws NamespaceNotFoundException {
     String name;
-    ZooCache zc = getZooCache(context);
+    ZooCache zc = context.getZooCache();
     byte[] path = zc.get(context.getZooKeeperRoot() + Constants.ZNAMESPACES + "/"
         + namespaceId.canonicalID() + Constants.ZNAMESPACE_NAME);
     if (path != null)
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/RootTabletLocator.java b/core/src/main/java/org/apache/accumulo/core/client/impl/RootTabletLocator.java
index 78ec6d8..3132769 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/RootTabletLocator.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/RootTabletLocator.java
@@ -34,9 +34,7 @@ import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.impl.KeyExtent;
 import org.apache.accumulo.core.metadata.RootTable;
 import org.apache.accumulo.core.util.OpTimer;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
-import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
 import org.apache.hadoop.io.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -44,15 +42,9 @@ import org.slf4j.LoggerFactory;
 public class RootTabletLocator extends TabletLocator {
 
   private final TabletServerLockChecker lockChecker;
-  private final ZooCacheFactory zcf;
 
   RootTabletLocator(TabletServerLockChecker lockChecker) {
-    this(lockChecker, new ZooCacheFactory());
-  }
-
-  RootTabletLocator(TabletServerLockChecker lockChecker, ZooCacheFactory zcf) {
     this.lockChecker = lockChecker;
-    this.zcf = zcf;
   }
 
   @Override
@@ -95,9 +87,8 @@ public class RootTabletLocator extends TabletLocator {
 
   @Override
   public void invalidateCache(ClientContext context, String server) {
-    ZooCache zooCache = zcf.getZooCache(context.getZooKeepers(),
-        context.getZooKeepersSessionTimeOut());
-    String root = ZooUtil.getRoot(context.getInstanceID()) + Constants.ZTSERVERS;
+    ZooCache zooCache = context.getZooCache();
+    String root = context.getZooKeeperRoot() + Constants.ZTSERVERS;
     zooCache.clear(root + "/" + server);
   }
 
@@ -105,10 +96,8 @@ public class RootTabletLocator extends TabletLocator {
   public void invalidateCache() {}
 
   protected TabletLocation getRootTabletLocation(ClientContext context) {
-    String zRootLocPath = ZooUtil.getRoot(context.getInstanceID())
-        + RootTable.ZROOT_TABLET_LOCATION;
-    ZooCache zooCache = zcf.getZooCache(context.getZooKeepers(),
-        context.getZooKeepersSessionTimeOut());
+    String zRootLocPath = context.getZooKeeperRoot() + RootTable.ZROOT_TABLET_LOCATION;
+    ZooCache zooCache = context.getZooCache();
 
     Logger log = LoggerFactory.getLogger(this.getClass());
 
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java
index a94c71b..5e13c3f 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java
@@ -35,7 +35,6 @@ import org.apache.accumulo.core.util.ServerServices;
 import org.apache.accumulo.core.util.ServerServices.Service;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
-import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
 import org.apache.thrift.TApplicationException;
 import org.apache.thrift.TServiceClient;
 import org.apache.thrift.TServiceClientFactory;
@@ -160,11 +159,9 @@ public class ServerClient {
     ArrayList<ThriftTransportKey> servers = new ArrayList<>();
 
     // add tservers
-    ZooCache zc = new ZooCacheFactory().getZooCache(context.getZooKeepers(),
-        context.getZooKeepersSessionTimeOut());
-    for (String tserver : zc
-        .getChildren(ZooUtil.getRoot(context.getInstanceID()) + Constants.ZTSERVERS)) {
-      String path = ZooUtil.getRoot(context.getInstanceID()) + Constants.ZTSERVERS + "/" + tserver;
+    ZooCache zc = context.getZooCache();
+    for (String tserver : zc.getChildren(context.getZooKeeperRoot() + Constants.ZTSERVERS)) {
+      String path = context.getZooKeeperRoot() + Constants.ZTSERVERS + "/" + tserver;
       byte[] data = ZooUtil.getLockData(zc, path);
       if (data != null) {
         String strData = new String(data, UTF_8);
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java b/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
index ddf77d8..8297df0 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
@@ -31,7 +31,6 @@ import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.master.state.tables.TableState;
 import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.util.Pair;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
 import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
 
@@ -161,8 +160,8 @@ public class Tables {
   }
 
   public static void clearCache(ClientContext context) {
-    getZooCache(context).clear(ZooUtil.getRoot(context.getInstanceID()) + Constants.ZTABLES);
-    getZooCache(context).clear(ZooUtil.getRoot(context.getInstanceID()) + Constants.ZNAMESPACES);
+    getZooCache(context).clear(context.getZooKeeperRoot() + Constants.ZTABLES);
+    getZooCache(context).clear(context.getZooKeeperRoot() + Constants.ZNAMESPACES);
     instanceToMapCache.invalidate(context.getInstanceID());
   }
 
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ZookeeperLockChecker.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ZookeeperLockChecker.java
index c6d3e7f..302471b 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ZookeeperLockChecker.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ZookeeperLockChecker.java
@@ -18,9 +18,7 @@ package org.apache.accumulo.core.client.impl;
 
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.impl.TabletLocatorImpl.TabletServerLockChecker;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
-import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
 import org.apache.accumulo.fate.zookeeper.ZooLock;
 import org.apache.zookeeper.KeeperException;
 
@@ -30,12 +28,8 @@ public class ZookeeperLockChecker implements TabletServerLockChecker {
   private final String root;
 
   ZookeeperLockChecker(ClientContext context) {
-    this(context, new ZooCacheFactory());
-  }
-
-  ZookeeperLockChecker(ClientContext context, ZooCacheFactory zcf) {
-    zc = zcf.getZooCache(context.getZooKeepers(), context.getZooKeepersSessionTimeOut());
-    this.root = ZooUtil.getRoot(context.getInstanceID()) + Constants.ZTSERVERS;
+    zc = context.getZooCache();
+    this.root = context.getZooKeeperRoot() + Constants.ZTSERVERS;
   }
 
   @Override
diff --git a/core/src/test/java/org/apache/accumulo/core/client/impl/RootTabletLocatorTest.java b/core/src/test/java/org/apache/accumulo/core/client/impl/RootTabletLocatorTest.java
index dec510f..5ef3b63 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/impl/RootTabletLocatorTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/impl/RootTabletLocatorTest.java
@@ -23,37 +23,30 @@ import static org.easymock.EasyMock.verify;
 
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.impl.TabletLocatorImpl.TabletServerLockChecker;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
-import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
 import org.junit.Before;
 import org.junit.Test;
 
 public class RootTabletLocatorTest {
   private ClientContext context;
   private TabletServerLockChecker lockChecker;
-  private ZooCacheFactory zcf;
   private ZooCache zc;
   private RootTabletLocator rtl;
 
   @Before
   public void setUp() {
     context = createMock(ClientContext.class);
-    expect(context.getInstanceID()).andReturn("iid").anyTimes();
-    expect(context.getZooKeepers()).andReturn("zk1").anyTimes();
-    expect(context.getZooKeepersSessionTimeOut()).andReturn(30000).anyTimes();
+    expect(context.getZooKeeperRoot()).andReturn("/accumulo/iid").anyTimes();
+    zc = createMock(ZooCache.class);
+    expect(context.getZooCache()).andReturn(zc).anyTimes();
     replay(context);
     lockChecker = createMock(TabletServerLockChecker.class);
-    zcf = createMock(ZooCacheFactory.class);
-    zc = createMock(ZooCache.class);
-    rtl = new RootTabletLocator(lockChecker, zcf);
+    rtl = new RootTabletLocator(lockChecker);
   }
 
   @Test
   public void testInvalidateCache_Server() {
-    expect(zcf.getZooCache("zk1", 30000)).andReturn(zc);
-    replay(zcf);
-    zc.clear(ZooUtil.getRoot(context.getInstanceID()) + Constants.ZTSERVERS + "/server");
+    zc.clear(context.getZooKeeperRoot() + Constants.ZTSERVERS + "/server");
     replay(zc);
     rtl.invalidateCache(context, "server");
     verify(zc);
diff --git a/core/src/test/java/org/apache/accumulo/core/client/impl/ZookeeperLockCheckerTest.java b/core/src/test/java/org/apache/accumulo/core/client/impl/ZookeeperLockCheckerTest.java
index e2544ed..b4274a1 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/impl/ZookeeperLockCheckerTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/impl/ZookeeperLockCheckerTest.java
@@ -22,35 +22,28 @@ import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
 
 import org.apache.accumulo.core.Constants;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
-import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
 import org.junit.Before;
 import org.junit.Test;
 
 public class ZookeeperLockCheckerTest {
   private ClientContext context;
-  private ZooCacheFactory zcf;
   private ZooCache zc;
   private ZookeeperLockChecker zklc;
 
   @Before
   public void setUp() {
     context = createMock(ClientContext.class);
-    expect(context.getInstanceID()).andReturn("iid").anyTimes();
-    expect(context.getZooKeepers()).andReturn("zk1").anyTimes();
-    expect(context.getZooKeepersSessionTimeOut()).andReturn(30000).anyTimes();
-    replay(context);
-    zcf = createMock(ZooCacheFactory.class);
+    expect(context.getZooKeeperRoot()).andReturn("/accumulo/iid").anyTimes();
     zc = createMock(ZooCache.class);
-    expect(zcf.getZooCache("zk1", 30000)).andReturn(zc);
-    replay(zcf);
-    zklc = new ZookeeperLockChecker(context, zcf);
+    expect(context.getZooCache()).andReturn(zc).anyTimes();
+    replay(context);
+    zklc = new ZookeeperLockChecker(context);
   }
 
   @Test
   public void testInvalidateCache() {
-    zc.clear(ZooUtil.getRoot("iid") + Constants.ZTSERVERS + "/server");
+    zc.clear(context.getZooKeeperRoot() + Constants.ZTSERVERS + "/server");
     replay(zc);
     zklc.invalidateCache("server");
     verify(zc);
diff --git a/server/base/src/main/java/org/apache/accumulo/server/log/WalStateManager.java b/server/base/src/main/java/org/apache/accumulo/server/log/WalStateManager.java
index 22703eb..864f48f 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/log/WalStateManager.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/log/WalStateManager.java
@@ -27,7 +27,6 @@ import java.util.UUID;
 
 import org.apache.accumulo.core.client.impl.ClientContext;
 import org.apache.accumulo.core.util.Pair;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
 import org.apache.accumulo.server.master.state.TServerInstance;
@@ -99,7 +98,7 @@ public class WalStateManager {
   }
 
   private String root() throws WalMarkerException {
-    String root = ZooUtil.getRoot(context.getInstanceID()) + ZWALS;
+    String root = context.getZooKeeperRoot() + ZWALS;
 
     try {
       if (!checkedExistance && !zoo.exists(root)) {
diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java b/server/base/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
index 4690529..eb41d70 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
@@ -40,7 +40,6 @@ import org.apache.accumulo.core.trace.Tracer;
 import org.apache.accumulo.core.util.AddressUtil;
 import org.apache.accumulo.core.util.HostAndPort;
 import org.apache.accumulo.core.util.ServerServices;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache.ZcStat;
 import org.apache.accumulo.server.master.state.TServerInstance;
 import org.apache.accumulo.server.util.Halt;
@@ -79,8 +78,7 @@ public class LiveTServerSet implements Watcher {
     }
 
     private String lockString(ZooLock mlock) {
-      return mlock.getLockID()
-          .serialize(ZooUtil.getRoot(context.getInstanceID()) + Constants.ZMASTER_LOCK);
+      return mlock.getLockID().serialize(context.getZooKeeperRoot() + Constants.ZMASTER_LOCK);
     }
 
     private void loadTablet(TabletClientService.Client client, ZooLock lock, KeyExtent extent)
@@ -269,7 +267,7 @@ public class LiveTServerSet implements Watcher {
       final Set<TServerInstance> updates = new HashSet<>();
       final Set<TServerInstance> doomed = new HashSet<>();
 
-      final String path = ZooUtil.getRoot(context.getInstanceID()) + Constants.ZTSERVERS;
+      final String path = context.getZooKeeperRoot() + Constants.ZTSERVERS;
 
       HashSet<String> all = new HashSet<>(current.keySet());
       all.addAll(getZooCache().getChildren(path));
@@ -364,7 +362,7 @@ public class LiveTServerSet implements Watcher {
           final Set<TServerInstance> updates = new HashSet<>();
           final Set<TServerInstance> doomed = new HashSet<>();
 
-          final String path = ZooUtil.getRoot(context.getInstanceID()) + Constants.ZTSERVERS;
+          final String path = context.getZooKeeperRoot() + Constants.ZTSERVERS;
 
           try {
             checkServer(updates, doomed, path, server);
@@ -437,7 +435,7 @@ public class LiveTServerSet implements Watcher {
     currentInstances.remove(server);
 
     log.info("Removing zookeeper lock for {}", server);
-    String fullpath = ZooUtil.getRoot(context.getInstanceID()) + Constants.ZTSERVERS + "/" + zPath;
+    String fullpath = context.getZooKeeperRoot() + Constants.ZTSERVERS + "/" + zPath;
     try {
       ZooReaderWriter.getInstance().recursiveDelete(fullpath, SKIP);
     } catch (Exception e) {
diff --git a/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReports.java b/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReports.java
index c0af4d4..6055075 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReports.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReports.java
@@ -44,7 +44,6 @@ import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.metadata.RootTable;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.util.NamingThreadFactory;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.util.LoggingRunnable;
 import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
 import org.apache.accumulo.server.ServerContext;
@@ -205,8 +204,7 @@ public class ProblemReports implements Iterable<ProblemReport> {
             try {
               List<String> children;
               if (table == null || isMeta(table)) {
-                children = zoo
-                    .getChildren(ZooUtil.getRoot(context.getInstanceID()) + Constants.ZPROBLEMS);
+                children = zoo.getChildren(context.getZooKeeperRoot() + Constants.ZPROBLEMS);
               } else {
                 children = Collections.emptyList();
               }
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
index 61c05f1..2bc853f 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
@@ -55,7 +55,6 @@ import org.apache.accumulo.core.trace.Tracer;
 import org.apache.accumulo.core.util.AddressUtil;
 import org.apache.accumulo.core.util.HostAndPort;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
-import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
 import org.apache.accumulo.fate.zookeeper.ZooLock;
 import org.apache.accumulo.server.cli.ClientOpts;
 import org.apache.accumulo.server.security.SecurityUtil;
@@ -367,8 +366,7 @@ public class Admin implements KeywordExecutable {
       return;
     }
     final String zTServerRoot = getTServersZkPath(context);
-    final ZooCache zc = new ZooCacheFactory().getZooCache(context.getZooKeepers(),
-        context.getZooKeepersSessionTimeOut());
+    final ZooCache zc = context.getZooCache();
     for (String server : servers) {
       for (int port : context.getConfiguration().getPort(Property.TSERV_CLIENTPORT)) {
         HostAndPort address = AddressUtil.parseAddress(server, port);
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/TabletServerLocks.java b/server/base/src/main/java/org/apache/accumulo/server/util/TabletServerLocks.java
index 772ab78..dedaff1 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/TabletServerLocks.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/TabletServerLocks.java
@@ -46,7 +46,7 @@ public class TabletServerLocks {
     Opts opts = new Opts();
     opts.parseArgs(TabletServerLocks.class.getName(), args);
 
-    ZooCache cache = new ZooCache(context.getZooKeepers(), context.getZooKeepersSessionTimeOut());
+    ZooCache cache = context.getZooCache();
 
     if (opts.list) {
       IZooReaderWriter zoo = ZooReaderWriter.getInstance();
diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java b/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java
index aa059e8..6527283 100644
--- a/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java
+++ b/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java
@@ -76,7 +76,6 @@ import org.apache.accumulo.core.util.NamingThreadFactory;
 import org.apache.accumulo.core.util.Pair;
 import org.apache.accumulo.core.util.ServerServices;
 import org.apache.accumulo.core.util.ServerServices.Service;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooLock.LockLossReason;
 import org.apache.accumulo.fate.zookeeper.ZooLock.LockWatcher;
 import org.apache.accumulo.gc.replication.CloseWriteAheadLogReferences;
@@ -628,7 +627,7 @@ public class SimpleGarbageCollector implements Iface {
   }
 
   private void getZooLock(HostAndPort addr) throws KeeperException, InterruptedException {
-    String path = ZooUtil.getRoot(context.getInstanceID()) + Constants.ZGC_LOCK;
+    String path = context.getZooKeeperRoot() + Constants.ZGC_LOCK;
 
     LockWatcher lockWatcher = new LockWatcher() {
       @Override
diff --git a/server/master/src/main/java/org/apache/accumulo/master/Master.java b/server/master/src/main/java/org/apache/accumulo/master/Master.java
index 308212b..b22320a 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/Master.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/Master.java
@@ -277,7 +277,7 @@ public class Master
   }
 
   private void moveRootTabletToRootTable(IZooReaderWriter zoo) throws Exception {
-    String dirZPath = ZooUtil.getRoot(getInstanceID()) + RootTable.ZROOT_TABLET_PATH;
+    String dirZPath = getZooKeeperRoot() + RootTable.ZROOT_TABLET_PATH;
 
     if (!zoo.exists(dirZPath)) {
       Path oldPath = fs.getFullPath(FileType.TABLE, "/" + MetadataTable.ID + "/root_tablet");
@@ -338,7 +338,7 @@ public class Master
         log.info("Upgrading zookeeper");
 
         IZooReaderWriter zoo = ZooReaderWriter.getInstance();
-        final String zooRoot = ZooUtil.getRoot(getInstanceID());
+        final String zooRoot = getZooKeeperRoot();
 
         log.debug("Handling updates for version {}", accumuloPersistentVersion);
 
@@ -395,7 +395,7 @@ public class Master
         }
 
         // create initial namespaces
-        String namespaces = ZooUtil.getRoot(getInstanceID()) + Constants.ZNAMESPACES;
+        String namespaces = getZooKeeperRoot() + Constants.ZNAMESPACES;
         zoo.putPersistentData(namespaces, new byte[0], NodeExistsPolicy.SKIP);
         for (Pair<String,Namespace.ID> namespace : Iterables.concat(
             Collections.singleton(new Pair<>(Namespace.ACCUMULO, Namespace.ID.ACCUMULO)),
@@ -423,7 +423,7 @@ public class Master
             TablePermission.ALTER_TABLE, Namespace.ID.ACCUMULO);
 
         // put existing tables in the correct namespaces
-        String tables = ZooUtil.getRoot(getInstanceID()) + Constants.ZTABLES;
+        String tables = getZooKeeperRoot() + Constants.ZTABLES;
         for (String tableId : zoo.getChildren(tables)) {
           Namespace.ID targetNamespace = (MetadataTable.ID.canonicalID().equals(tableId)
               || RootTable.ID.canonicalID().equals(tableId)) ? Namespace.ID.ACCUMULO
@@ -447,7 +447,7 @@ public class Master
         // add system namespace permissions to existing users
         ZKPermHandler perm = new ZKPermHandler();
         perm.initialize(getInstanceID(), true);
-        String users = ZooUtil.getRoot(getInstanceID()) + "/users";
+        String users = getZooKeeperRoot() + "/users";
         for (String user : zoo.getChildren(users)) {
           zoo.putPersistentData(users + "/" + user + "/Namespaces", new byte[0],
               NodeExistsPolicy.SKIP);
@@ -457,12 +457,11 @@ public class Master
             NamespacePermission.ALTER_TABLE);
 
         // add the currlog location for root tablet current logs
-        zoo.putPersistentData(
-            ZooUtil.getRoot(getInstanceID()) + RootTable.ZROOT_TABLET_CURRENT_LOGS, new byte[0],
+        zoo.putPersistentData(getZooKeeperRoot() + RootTable.ZROOT_TABLET_CURRENT_LOGS, new byte[0],
             NodeExistsPolicy.SKIP);
 
         // create tablet server wal logs node in ZK
-        zoo.putPersistentData(ZooUtil.getRoot(getInstanceID()) + WalStateManager.ZWALS, new byte[0],
+        zoo.putPersistentData(getZooKeeperRoot() + WalStateManager.ZWALS, new byte[0],
             NodeExistsPolicy.SKIP);
 
         haveUpgradedZooKeeper = true;
@@ -681,7 +680,7 @@ public class Master
       final long tokenUpdateInterval = aconf
           .getTimeInMillis(Property.GENERAL_DELEGATION_TOKEN_UPDATE_INTERVAL);
       keyDistributor = new ZooAuthenticationKeyDistributor(ZooReaderWriter.getInstance(),
-          ZooUtil.getRoot(getInstanceID()) + Constants.ZDELEGATION_TOKEN_KEYS);
+          getZooKeeperRoot() + Constants.ZDELEGATION_TOKEN_KEYS);
       authenticationTokenKeyManager = new AuthenticationTokenKeyManager(context.getSecretManager(),
           keyDistributor, tokenUpdateInterval, tokenLifetime);
       delegationTokensAvailable = true;
@@ -696,6 +695,10 @@ public class Master
     return context.getInstanceID();
   }
 
+  public String getZooKeeperRoot() {
+    return context.getZooKeeperRoot();
+  }
+
   public AccumuloConfiguration getConfiguration() {
     return context.getConfiguration();
   }
@@ -707,8 +710,7 @@ public class Master
   public MergeInfo getMergeInfo(Table.ID tableId) {
     synchronized (mergeLock) {
       try {
-        String path = ZooUtil.getRoot(getInstanceID()) + Constants.ZTABLES + "/" + tableId
-            + "/merge";
+        String path = getZooKeeperRoot() + Constants.ZTABLES + "/" + tableId + "/merge";
         if (!ZooReaderWriter.getInstance().exists(path))
           return new MergeInfo();
         byte[] data = ZooReaderWriter.getInstance().getData(path, new Stat());
@@ -730,8 +732,8 @@ public class Master
   public void setMergeState(MergeInfo info, MergeState state)
       throws IOException, KeeperException, InterruptedException {
     synchronized (mergeLock) {
-      String path = ZooUtil.getRoot(getInstanceID()) + Constants.ZTABLES + "/"
-          + info.getExtent().getTableId() + "/merge";
+      String path = getZooKeeperRoot() + Constants.ZTABLES + "/" + info.getExtent().getTableId()
+          + "/merge";
       info.setState(state);
       if (state.equals(MergeState.NONE)) {
         ZooReaderWriter.getInstance().recursiveDelete(path, NodeMissingPolicy.SKIP);
@@ -754,7 +756,7 @@ public class Master
   public void clearMergeState(Table.ID tableId)
       throws IOException, KeeperException, InterruptedException {
     synchronized (mergeLock) {
-      String path = ZooUtil.getRoot(getInstanceID()) + Constants.ZTABLES + "/" + tableId + "/merge";
+      String path = getZooKeeperRoot() + Constants.ZTABLES + "/" + tableId + "/merge";
       ZooReaderWriter.getInstance().recursiveDelete(path, NodeMissingPolicy.SKIP);
       mergeLock.notifyAll();
     }
@@ -764,7 +766,7 @@ public class Master
   void setMasterGoalState(MasterGoalState state) {
     try {
       ZooReaderWriter.getInstance().putPersistentData(
-          ZooUtil.getRoot(getInstanceID()) + Constants.ZMASTER_GOAL_STATE, state.name().getBytes(),
+          getZooKeeperRoot() + Constants.ZMASTER_GOAL_STATE, state.name().getBytes(),
           NodeExistsPolicy.OVERWRITE);
     } catch (Exception ex) {
       log.error("Unable to set master goal state in zookeeper");
@@ -775,7 +777,7 @@ public class Master
     while (true)
       try {
         byte[] data = ZooReaderWriter.getInstance()
-            .getData(ZooUtil.getRoot(getInstanceID()) + Constants.ZMASTER_GOAL_STATE, null);
+            .getData(getZooKeeperRoot() + Constants.ZMASTER_GOAL_STATE, null);
         return MasterGoalState.valueOf(new String(data));
       } catch (Exception e) {
         log.error("Problem getting real goal state from zookeeper: ", e);
@@ -1230,7 +1232,7 @@ public class Master
   }
 
   public void run() throws IOException, InterruptedException, KeeperException {
-    final String zroot = ZooUtil.getRoot(getInstanceID());
+    final String zroot = getZooKeeperRoot();
 
     // ACCUMULO-4424 Put up the Thrift servers before getting the lock as a sign of process health
     // when a hot-standby
@@ -1336,10 +1338,8 @@ public class Master
     waitForMetadataUpgrade.await();
 
     try {
-      final AgeOffStore<Master> store = new AgeOffStore<>(
-          new org.apache.accumulo.fate.ZooStore<>(
-              ZooUtil.getRoot(getInstanceID()) + Constants.ZFATE, ZooReaderWriter.getInstance()),
-          1000 * 60 * 60 * 8);
+      final AgeOffStore<Master> store = new AgeOffStore<>(new org.apache.accumulo.fate.ZooStore<>(
+          getZooKeeperRoot() + Constants.ZFATE, ZooReaderWriter.getInstance()), 1000 * 60 * 60 * 8);
 
       int threads = getConfiguration().getCount(Property.MASTER_FATE_THREADPOOL_SIZE);
 
@@ -1401,7 +1401,7 @@ public class Master
 
     // Advertise that port we used so peers don't have to be told what it is
     ZooReaderWriter.getInstance().putPersistentData(
-        ZooUtil.getRoot(getInstanceID()) + Constants.ZMASTER_REPLICATION_COORDINATOR_ADDR,
+        getZooKeeperRoot() + Constants.ZMASTER_REPLICATION_COORDINATOR_ADDR,
         replAddress.address.toString().getBytes(UTF_8), NodeExistsPolicy.OVERWRITE);
 
     // Register replication metrics
@@ -1561,8 +1561,7 @@ public class Master
   @Override
   public void update(LiveTServerSet current, Set<TServerInstance> deleted,
       Set<TServerInstance> added) {
-    DeadServerList obit = new DeadServerList(
-        ZooUtil.getRoot(getInstanceID()) + Constants.ZDEADTSERVERS);
+    DeadServerList obit = new DeadServerList(getZooKeeperRoot() + Constants.ZDEADTSERVERS);
     if (added.size() > 0) {
       log.info("New servers: {}", added);
       for (TServerInstance up : added)
@@ -1749,8 +1748,7 @@ public class Master
       for (TServerInstance server : serversToShutdown)
         result.serversShuttingDown.add(server.hostPort());
     }
-    DeadServerList obit = new DeadServerList(
-        ZooUtil.getRoot(getInstanceID()) + Constants.ZDEADTSERVERS);
+    DeadServerList obit = new DeadServerList(getZooKeeperRoot() + Constants.ZDEADTSERVERS);
     result.deadTabletServers = obit.getList();
     result.bulkImports = bulkImportStatus.getBulkLoadStatus();
     return result;
diff --git a/server/master/src/main/java/org/apache/accumulo/master/MasterTime.java b/server/master/src/main/java/org/apache/accumulo/master/MasterTime.java
index 359751e..cbfa2b3 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/MasterTime.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/MasterTime.java
@@ -26,7 +26,6 @@ import java.util.Timer;
 import java.util.TimerTask;
 
 import org.apache.accumulo.core.Constants;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
 import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
 import org.slf4j.Logger;
@@ -50,7 +49,7 @@ public class MasterTime extends TimerTask {
   private long skewAmount;
 
   public MasterTime(Master master) throws IOException {
-    this.zPath = ZooUtil.getRoot(master.getInstanceID()) + Constants.ZMASTER_TICK;
+    this.zPath = master.getZooKeeperRoot() + Constants.ZMASTER_TICK;
     this.zk = ZooReaderWriter.getInstance();
     this.master = master;
 
diff --git a/server/master/src/main/java/org/apache/accumulo/master/recovery/RecoveryManager.java b/server/master/src/main/java/org/apache/accumulo/master/recovery/RecoveryManager.java
index fd35982..59cf756 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/recovery/RecoveryManager.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/recovery/RecoveryManager.java
@@ -35,7 +35,6 @@ import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.data.impl.KeyExtent;
 import org.apache.accumulo.core.util.NamingThreadFactory;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.master.Master;
 import org.apache.accumulo.server.ServerConstants;
 import org.apache.accumulo.server.fs.VolumeManager.FileType;
@@ -69,7 +68,7 @@ public class RecoveryManager {
     try {
       AccumuloConfiguration aconf = master.getConfiguration();
       List<String> workIDs = new DistributedWorkQueue(
-          ZooUtil.getRoot(master.getInstanceID()) + Constants.ZRECOVERY, aconf).getWorkQueued();
+          master.getZooKeeperRoot() + Constants.ZRECOVERY, aconf).getWorkQueued();
       sortsQueued.addAll(workIDs);
     } catch (Exception e) {
       log.warn("{}", e.getMessage(), e);
@@ -120,15 +119,14 @@ public class RecoveryManager {
   private void initiateSort(String sortId, String source, final String destination,
       AccumuloConfiguration aconf) throws KeeperException, InterruptedException, IOException {
     String work = source + "|" + destination;
-    new DistributedWorkQueue(ZooUtil.getRoot(master.getInstanceID()) + Constants.ZRECOVERY, aconf)
-        .addWork(sortId, work.getBytes(UTF_8));
+    new DistributedWorkQueue(master.getZooKeeperRoot() + Constants.ZRECOVERY, aconf).addWork(sortId,
+        work.getBytes(UTF_8));
 
     synchronized (this) {
       sortsQueued.add(sortId);
     }
 
-    final String path = ZooUtil.getRoot(master.getInstanceID()) + Constants.ZRECOVERY + "/"
-        + sortId;
+    final String path = master.getZooKeeperRoot() + Constants.ZRECOVERY + "/" + sortId;
     log.info("Created zookeeper entry {} with data {}", path, work);
   }
 
@@ -161,8 +159,8 @@ public class RecoveryManager {
           sortQueued = sortsQueued.contains(sortId);
         }
 
-        if (sortQueued && zooCache.get(
-            ZooUtil.getRoot(master.getInstanceID()) + Constants.ZRECOVERY + "/" + sortId) == null) {
+        if (sortQueued && zooCache
+            .get(master.getZooKeeperRoot() + Constants.ZRECOVERY + "/" + sortId) == null) {
           synchronized (this) {
             sortsQueued.remove(sortId);
           }
diff --git a/server/master/src/main/java/org/apache/accumulo/master/replication/MasterReplicationCoordinator.java b/server/master/src/main/java/org/apache/accumulo/master/replication/MasterReplicationCoordinator.java
index afe7399..b9d0712 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/replication/MasterReplicationCoordinator.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/replication/MasterReplicationCoordinator.java
@@ -29,7 +29,6 @@ import org.apache.accumulo.core.replication.thrift.ReplicationCoordinator;
 import org.apache.accumulo.core.replication.thrift.ReplicationCoordinatorErrorCode;
 import org.apache.accumulo.core.replication.thrift.ReplicationCoordinatorException;
 import org.apache.accumulo.core.security.thrift.TCredentials;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooReader;
 import org.apache.accumulo.master.Master;
 import org.apache.accumulo.server.master.state.TServerInstance;
@@ -84,8 +83,9 @@ public class MasterReplicationCoordinator implements ReplicationCoordinator.Ifac
     TServerInstance tserver = getRandomTServer(tservers, rand.nextInt(tservers.size()));
     String replServiceAddr;
     try {
-      replServiceAddr = new String(reader.getData(ZooUtil.getRoot(master.getInstanceID())
-          + ReplicationConstants.ZOO_TSERVERS + "/" + tserver.hostPort(), null), UTF_8);
+      replServiceAddr = new String(reader.getData(
+          master.getZooKeeperRoot() + ReplicationConstants.ZOO_TSERVERS + "/" + tserver.hostPort(),
+          null), UTF_8);
     } catch (KeeperException | InterruptedException e) {
       log.error("Could not fetch repliation service port for tserver", e);
       throw new ReplicationCoordinatorException(
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameNamespace.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameNamespace.java
index 0fe6452..d8e2ff1 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameNamespace.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameNamespace.java
@@ -22,7 +22,6 @@ import org.apache.accumulo.core.client.impl.Namespace;
 import org.apache.accumulo.core.client.impl.Tables;
 import org.apache.accumulo.core.client.impl.thrift.TableOperation;
 import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.Repo;
 import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
 import org.apache.accumulo.fate.zookeeper.IZooReaderWriter.Mutator;
@@ -58,8 +57,8 @@ public class RenameNamespace extends MasterRepo {
       Utils.checkNamespaceDoesNotExist(master.getContext(), newName, namespaceId,
           TableOperation.RENAME);
 
-      final String tap = ZooUtil.getRoot(master.getInstanceID()) + Constants.ZNAMESPACES + "/"
-          + namespaceId + Constants.ZNAMESPACE_NAME;
+      final String tap = master.getZooKeeperRoot() + Constants.ZNAMESPACES + "/" + namespaceId
+          + Constants.ZNAMESPACE_NAME;
 
       zoo.mutate(tap, null, null, new Mutator() {
         @Override
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java
index ead80ca..74d075c 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java
@@ -28,7 +28,6 @@ import org.apache.accumulo.core.client.impl.Tables;
 import org.apache.accumulo.core.client.impl.thrift.TableOperation;
 import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
 import org.apache.accumulo.core.util.Pair;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.Repo;
 import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
 import org.apache.accumulo.fate.zookeeper.IZooReaderWriter.Mutator;
@@ -80,7 +79,7 @@ public class RenameTable extends MasterRepo {
       final String newName = qualifiedNewTableName.getSecond();
       final String oldName = qualifiedOldTableName.getSecond();
 
-      final String tap = ZooUtil.getRoot(master.getInstanceID()) + Constants.ZTABLES + "/" + tableId
+      final String tap = master.getZooKeeperRoot() + Constants.ZTABLES + "/" + tableId
           + Constants.ZTABLE_NAME;
 
       zoo.mutate(tap, null, null, new Mutator() {
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tserverOps/ShutdownTServer.java b/server/master/src/main/java/org/apache/accumulo/master/tserverOps/ShutdownTServer.java
index a133080..8ac83ef 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tserverOps/ShutdownTServer.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tserverOps/ShutdownTServer.java
@@ -20,7 +20,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
 
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.master.thrift.TabletServerStatus;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.Repo;
 import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
@@ -92,11 +91,9 @@ public class ShutdownTServer extends MasterRepo {
   public Repo<Master> call(long tid, Master master) throws Exception {
     // suppress assignment of tablets to the server
     if (force) {
-      String path = ZooUtil.getRoot(master.getInstanceID()) + Constants.ZTSERVERS + "/"
-          + server.getLocation();
+      String path = master.getZooKeeperRoot() + Constants.ZTSERVERS + "/" + server.getLocation();
       ZooLock.deleteLock(path);
-      path = ZooUtil.getRoot(master.getInstanceID()) + Constants.ZDEADTSERVERS + "/"
-          + server.getLocation();
+      path = master.getZooKeeperRoot() + Constants.ZDEADTSERVERS + "/" + server.getLocation();
       IZooReaderWriter zoo = ZooReaderWriter.getInstance();
       zoo.putPersistentData(path, "forced down".getBytes(UTF_8), NodeExistsPolicy.OVERWRITE);
     }
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
index 3310edf..5287810 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
@@ -58,7 +58,6 @@ import org.apache.accumulo.core.util.HostAndPort;
 import org.apache.accumulo.core.util.Pair;
 import org.apache.accumulo.core.util.ServerServices;
 import org.apache.accumulo.core.util.ServerServices.Service;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.util.LoggingRunnable;
 import org.apache.accumulo.fate.zookeeper.ZooLock.LockLossReason;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
@@ -410,7 +409,7 @@ public class Monitor implements HighlyAvailableService {
     try {
       // Read the gc location from its lock
       ZooReaderWriter zk = ZooReaderWriter.getInstance();
-      String path = ZooUtil.getRoot(context.getInstanceID()) + Constants.ZGC_LOCK;
+      String path = context.getZooKeeperRoot() + Constants.ZGC_LOCK;
       List<String> locks = zk.getChildren(path, null);
       if (locks != null && locks.size() > 0) {
         Collections.sort(locks);
@@ -493,8 +492,8 @@ public class Monitor implements HighlyAvailableService {
     try {
       String monitorAddress = HostAndPort.fromParts(advertiseHost, server.getPort()).toString();
       ZooReaderWriter.getInstance().putPersistentData(
-          ZooUtil.getRoot(context.getInstanceID()) + Constants.ZMONITOR_HTTP_ADDR,
-          monitorAddress.getBytes(UTF_8), NodeExistsPolicy.OVERWRITE);
+          context.getZooKeeperRoot() + Constants.ZMONITOR_HTTP_ADDR, monitorAddress.getBytes(UTF_8),
+          NodeExistsPolicy.OVERWRITE);
       log.info("Set monitor address in zookeeper to {}", monitorAddress);
     } catch (Exception ex) {
       log.error("Unable to set monitor HTTP address in zookeeper", ex);
@@ -630,7 +629,7 @@ public class Monitor implements HighlyAvailableService {
    * Get the monitor lock in ZooKeeper
    */
   private void getMonitorLock() throws KeeperException, InterruptedException {
-    final String zRoot = ZooUtil.getRoot(context.getInstanceID());
+    final String zRoot = context.getZooKeeperRoot();
     final String monitorPath = zRoot + Constants.ZMONITOR;
     final String monitorLockPath = zRoot + Constants.ZMONITOR_LOCK;
 
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerResource.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerResource.java
index 07b4ecc..679bf33 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerResource.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerResource.java
@@ -52,7 +52,6 @@ import org.apache.accumulo.core.tabletserver.thrift.TabletStats;
 import org.apache.accumulo.core.trace.Tracer;
 import org.apache.accumulo.core.util.AddressUtil;
 import org.apache.accumulo.core.util.HostAndPort;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.monitor.Monitor;
 import org.apache.accumulo.monitor.rest.master.MasterResource;
 import org.apache.accumulo.server.master.state.DeadServerList;
@@ -104,7 +103,7 @@ public class TabletServerResource {
   public void clearDeadServer(
       @QueryParam("server") @NotNull @Pattern(regexp = SERVER_REGEX) String server) {
     DeadServerList obit = new DeadServerList(
-        ZooUtil.getRoot(Monitor.getContext().getInstanceID()) + Constants.ZDEADTSERVERS);
+        Monitor.getContext().getZooKeeperRoot() + Constants.ZDEADTSERVERS);
     obit.delete(server);
   }
 
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/AccumuloMonitorAppender.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/AccumuloMonitorAppender.java
index 37c6138..d925f63 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/AccumuloMonitorAppender.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/AccumuloMonitorAppender.java
@@ -31,7 +31,6 @@ import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.util.HostAndPort;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
 import org.apache.accumulo.fate.zookeeper.ZooCache.ZcStat;
-import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
 import org.apache.accumulo.server.ServerContext;
 import org.apache.log4j.AppenderSkeleton;
 import org.apache.log4j.AsyncAppender;
@@ -146,8 +145,7 @@ public class AccumuloMonitorAppender extends AsyncAppender implements AutoClosea
       if (this.zooCache == null) {
         ServerContext context = ServerContext.getInstance();
         this.path = context.getZooKeeperRoot() + Constants.ZMONITOR_LOG4J_ADDR;
-        this.zooCache = new ZooCacheFactory().getZooCache(context.getZooKeepers(),
-            context.getZooKeepersSessionTimeOut());
+        this.zooCache = context.getZooCache();
       }
 
       // get the current location from the cache and update if necessary
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
index 28ccd5c..7dd90f8 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
@@ -436,7 +436,7 @@ public class TabletServer implements Runnable {
       // Watcher to notice new AuthenticationKeys which enable delegation tokens
       authKeyWatcher = new ZooAuthenticationKeyWatcher(context.getSecretManager(),
           ZooReaderWriter.getInstance(),
-          ZooUtil.getRoot(getInstanceID()) + Constants.ZDELEGATION_TOKEN_KEYS);
+          context.getZooKeeperRoot() + Constants.ZDELEGATION_TOKEN_KEYS);
     } else {
       authKeyWatcher = null;
     }
@@ -1698,8 +1698,8 @@ public class TabletServer implements Runnable {
       }
 
       if (lock != null) {
-        ZooUtil.LockID lid = new ZooUtil.LockID(
-            ZooUtil.getRoot(getInstanceID()) + Constants.ZMASTER_LOCK, lock);
+        ZooUtil.LockID lid = new ZooUtil.LockID(context.getZooKeeperRoot() + Constants.ZMASTER_LOCK,
+            lock);
 
         try {
           if (!ZooLock.isLockHeld(masterLockCache, lid)) {
@@ -2696,11 +2696,9 @@ public class TabletServer implements Runnable {
       // The replication service is unique to the thrift service for a tserver, not just a host.
       // Advertise the host and port for replication service given the host and port for the
       // tserver.
-      ZooReaderWriter.getInstance()
-          .putPersistentData(
-              ZooUtil.getRoot(getInstanceID()) + ReplicationConstants.ZOO_TSERVERS + "/"
-                  + clientAddress,
-              sp.address.toString().getBytes(UTF_8), NodeExistsPolicy.OVERWRITE);
+      ZooReaderWriter.getInstance().putPersistentData(
+          context.getZooKeeperRoot() + ReplicationConstants.ZOO_TSERVERS + "/" + clientAddress,
+          sp.address.toString().getBytes(UTF_8), NodeExistsPolicy.OVERWRITE);
     } catch (Exception e) {
       log.error("Could not advertise replication service port", e);
       throw new RuntimeException(e);
@@ -2716,7 +2714,7 @@ public class TabletServer implements Runnable {
   private void announceExistence() {
     IZooReaderWriter zoo = ZooReaderWriter.getInstance();
     try {
-      String zPath = ZooUtil.getRoot(getInstanceID()) + Constants.ZTSERVERS + "/"
+      String zPath = context.getZooKeeperRoot() + Constants.ZTSERVERS + "/"
           + getClientAddressString();
 
       try {
@@ -2765,7 +2763,7 @@ public class TabletServer implements Runnable {
         if (tabletServerLock.tryLock(lw, lockContent)) {
           log.debug("Obtained tablet server lock {}", tabletServerLock.getLockPath());
           lockID = tabletServerLock.getLockID()
-              .serialize(ZooUtil.getRoot(getInstanceID()) + Constants.ZTSERVERS + "/");
+              .serialize(context.getZooKeeperRoot() + Constants.ZTSERVERS + "/");
           return;
         }
         log.info("Waiting for tablet server lock");
@@ -2789,7 +2787,7 @@ public class TabletServer implements Runnable {
     // We can just make the zookeeper paths before we try to use.
     try {
       ZooKeeperInitialization.ensureZooKeeperInitialized(ZooReaderWriter.getInstance(),
-          ZooUtil.getRoot(getInstanceID()));
+          context.getZooKeeperRoot());
     } catch (KeeperException | InterruptedException e) {
       log.error("Could not ensure that ZooKeeper is properly initialized", e);
       throw new RuntimeException(e);
@@ -2838,7 +2836,7 @@ public class TabletServer implements Runnable {
         getConfiguration().getCount(Property.TSERV_WORKQ_THREADS), "distributed work queue");
 
     bulkFailedCopyQ = new DistributedWorkQueue(
-        ZooUtil.getRoot(getInstanceID()) + Constants.ZBULK_FAILED_COPYQ, getConfiguration());
+        context.getZooKeeperRoot() + Constants.ZBULK_FAILED_COPYQ, getConfiguration());
     try {
       bulkFailedCopyQ.startProcessing(new BulkFailedCopyProcessor(), distWorkQThreadPool);
     } catch (Exception e1) {
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/LogSorter.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/LogSorter.java
index 33d9138..2041d9a 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/LogSorter.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/LogSorter.java
@@ -35,7 +35,6 @@ import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.master.thrift.RecoveryStatus;
 import org.apache.accumulo.core.util.Pair;
 import org.apache.accumulo.core.util.SimpleThreadPool;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.server.fs.VolumeManager;
 import org.apache.accumulo.server.log.SortedLogState;
 import org.apache.accumulo.server.zookeeper.DistributedWorkQueue;
@@ -232,7 +231,7 @@ public class LogSorter {
   public void startWatchingForRecoveryLogs(ThreadPoolExecutor distWorkQThreadPool)
       throws KeeperException, InterruptedException {
     this.threadPool = distWorkQThreadPool;
-    new DistributedWorkQueue(ZooUtil.getRoot(context.getInstanceID()) + Constants.ZRECOVERY, conf)
+    new DistributedWorkQueue(context.getZooKeeperRoot() + Constants.ZRECOVERY, conf)
         .startProcessing(new LogProcessor(), this.threadPool);
   }
 
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/ReplicationWorker.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/ReplicationWorker.java
index 27ce654..2ccfe76 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/ReplicationWorker.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/ReplicationWorker.java
@@ -23,7 +23,6 @@ import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.DefaultConfiguration;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.replication.ReplicationConstants;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.server.fs.VolumeManager;
 import org.apache.accumulo.server.zookeeper.DistributedWorkQueue;
 import org.apache.zookeeper.KeeperException;
@@ -64,12 +63,11 @@ public class ReplicationWorker implements Runnable {
         log.debug("Configuration DistributedWorkQueue with delay and period of {} and {}", delay,
             period);
         workQueue = new DistributedWorkQueue(
-            ZooUtil.getRoot(context.getInstanceID()) + ReplicationConstants.ZOO_WORK_QUEUE, conf,
-            delay, period);
+            context.getZooKeeperRoot() + ReplicationConstants.ZOO_WORK_QUEUE, conf, delay, period);
       } else {
         log.debug("Configuring DistributedWorkQueue with default delay and period");
         workQueue = new DistributedWorkQueue(
-            ZooUtil.getRoot(context.getInstanceID()) + ReplicationConstants.ZOO_WORK_QUEUE, conf);
+            context.getZooKeeperRoot() + ReplicationConstants.ZOO_WORK_QUEUE, conf);
       }
 
       workQueue.startProcessing(new ReplicationProcessor(context, conf, fs), executor);
diff --git a/test/src/main/java/org/apache/accumulo/test/TransportCachingIT.java b/test/src/main/java/org/apache/accumulo/test/TransportCachingIT.java
index 53fe102..5af4aee 100644
--- a/test/src/main/java/org/apache/accumulo/test/TransportCachingIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/TransportCachingIT.java
@@ -34,7 +34,6 @@ import org.apache.accumulo.core.util.ServerServices;
 import org.apache.accumulo.core.util.ServerServices.Service;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
-import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
 import org.apache.accumulo.harness.AccumuloClusterHarness;
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
@@ -54,9 +53,8 @@ public class TransportCachingIT extends AccumuloClusterHarness {
     long rpcTimeout = ConfigurationTypeHelper
         .getTimeInMillis(Property.GENERAL_RPC_TIMEOUT.getDefaultValue());
 
-    ZooCache zc = new ZooCacheFactory().getZooCache(context.getZooKeepers(),
-        context.getZooKeepersSessionTimeOut());
-    final String zkRoot = ZooUtil.getRoot(context.getInstanceID());
+    ZooCache zc = context.getZooCache();
+    final String zkRoot = context.getZooKeeperRoot();
 
     // wait until Zookeeper is populated
     List<String> children = zc.getChildren(zkRoot + Constants.ZTSERVERS);
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java b/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java
index bb32aec..dd2a136 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java
@@ -98,7 +98,7 @@ public class GarbageCollectorIT extends ConfigurableMacBase {
     getCluster().killProcess(ServerType.GARBAGE_COLLECTOR,
         getCluster().getProcesses().get(ServerType.GARBAGE_COLLECTOR).iterator().next());
     // delete lock in zookeeper if there, this will allow next GC to start quickly
-    String path = ZooUtil.getRoot(getConnector().getInstanceID()) + Constants.ZGC_LOCK;
+    String path = getServerContext().getZooKeeperRoot() + Constants.ZGC_LOCK;
     ZooReaderWriter zk = new ZooReaderWriter(cluster.getZooKeepers(), 30000, OUR_SECRET);
     try {
       ZooLock.deleteLock(zk, path);
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java b/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java
index 265db5d..c629321 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java
@@ -34,7 +34,6 @@ import org.apache.accumulo.core.trace.thrift.TInfo;
 import org.apache.accumulo.core.util.HostAndPort;
 import org.apache.accumulo.core.util.ServerServices;
 import org.apache.accumulo.core.util.ServerServices.Service;
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooLock.LockLossReason;
 import org.apache.accumulo.fate.zookeeper.ZooLock.LockWatcher;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
@@ -109,8 +108,7 @@ public class ZombieTServer {
         10 * 1024 * 1024, null, null, -1, HostAndPort.fromParts("0.0.0.0", port));
 
     String addressString = serverPort.address.toString();
-    String zPath = ZooUtil.getRoot(context.getInstanceID()) + Constants.ZTSERVERS + "/"
-        + addressString;
+    String zPath = context.getZooKeeperRoot() + Constants.ZTSERVERS + "/" + addressString;
     ZooReaderWriter zoo = ZooReaderWriter.getInstance();
     zoo.putPersistentData(zPath, new byte[] {}, NodeExistsPolicy.SKIP);
 


Mime
View raw message