accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [15/16] git commit: Another round of updates
Date Mon, 22 Sep 2014 20:48:15 GMT
Another round of updates



git-svn-id: https://svn.apache.org/repos/asf/accumulo/branches/ACCUMULO-CURATOR@1499092 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/a951e789
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/a951e789
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/a951e789

Branch: refs/heads/ACCUMULO-CURATOR
Commit: a951e789f83b9b995ec8fff0eca52a51dda2953c
Parents: 4640866
Author: John Vines <vines@apache.org>
Authored: Tue Jul 2 20:13:20 2013 +0000
Committer: John Vines <vines@apache.org>
Committed: Tue Jul 2 20:13:20 2013 +0000

----------------------------------------------------------------------
 .../core/client/admin/TableOperationsImpl.java  |   2 -
 .../core/client/impl/OfflineScanner.java        |   7 +-
 .../accumulo/core/client/impl/ServerClient.java |   2 +-
 .../accumulo/core/client/impl/Tables.java       |   6 +-
 .../impl/TabletServerBatchReaderIterator.java   |   1 -
 .../client/impl/TabletServerBatchWriter.java    |   3 +-
 .../core/client/impl/ThriftScanner.java         |   6 +-
 .../core/client/mapred/InputFormatBase.java     |   5 +-
 .../core/client/mapreduce/InputFormatBase.java  |   5 +-
 .../core/util/shell/commands/FateCommand.java   |   7 +-
 .../java/org/apache/accumulo/fate/ZooStore.java |   2 +
 .../accumulo/fate/curator/CuratorCaches.java    |  45 ++++---
 .../accumulo/fate/curator/CuratorReader.java    |  14 ++-
 .../fate/curator/CuratorReaderWriter.java       |  47 +++++---
 .../accumulo/fate/curator/CuratorSession.java   |  11 +-
 .../accumulo/fate/curator/CuratorUtil.java      |  21 +++-
 .../apache/accumulo/fate/zookeeper/ZooLock.java |   2 +-
 .../accumulo/fate/zookeeper/ZooQueueLock.java   |   2 +-
 .../server/client/ClientServiceHandler.java     |   1 -
 .../accumulo/server/client/HdfsZooInstance.java |   2 +-
 .../server/conf/TableConfiguration.java         |   7 +-
 .../accumulo/server/conf/ZooConfiguration.java  |   4 +-
 .../server/constraints/MetadataConstraints.java |   6 +-
 .../accumulo/server/curator/CuratorCaches.java  |  49 ++++++++
 .../server/curator/CuratorReaderWriter.java     |   8 +-
 .../server/gc/SimpleGarbageCollector.java       |   4 +-
 .../accumulo/server/master/LiveTServerSet.java  |  14 +--
 .../apache/accumulo/server/master/Master.java   |   4 +-
 .../server/master/TabletGroupWatcher.java       |   4 +-
 .../server/master/recovery/RecoveryManager.java |  10 +-
 .../server/master/state/DeadServerList.java     |   2 +-
 .../server/master/state/MetaDataStateStore.java |   3 +-
 .../master/state/MetaDataTableScanner.java      |   3 +-
 .../master/state/TabletStateChangeIterator.java |   2 +-
 .../accumulo/server/master/state/ZooStore.java  |   6 +-
 .../master/state/ZooTabletStateStore.java       |   1 -
 .../master/state/tables/TableManager.java       |  21 ++--
 .../server/master/tableOps/BulkImport.java      |   1 -
 .../server/master/tableOps/CloneTable.java      |   4 -
 .../server/master/tableOps/CompactRange.java    |   1 -
 .../server/master/tableOps/CreateTable.java     |  10 +-
 .../server/master/tableOps/DeleteTable.java     |   2 -
 .../server/master/tableOps/ExportTable.java     |   1 -
 .../server/master/tableOps/ImportTable.java     |   7 +-
 .../server/master/tableOps/RenameTable.java     |   2 -
 .../server/security/SecurityOperation.java      |   6 +-
 .../security/handler/ZKAuthenticator.java       |   7 +-
 .../server/security/handler/ZKAuthorizor.java   |   6 +-
 .../server/security/handler/ZKPermHandler.java  | 118 +++++++++----------
 .../accumulo/server/tabletserver/Tablet.java    |   7 +-
 .../server/tabletserver/TabletServer.java       |  19 ++-
 .../tabletserver/UniqueNameAllocator.java       |   1 -
 .../apache/accumulo/server/util/Initialize.java |   2 +-
 .../accumulo/server/util/TablePropUtil.java     |  11 +-
 .../server/zookeeper/DistributedWorkQueue.java  |   5 +-
 .../accumulo/server/zookeeper/ZooCache.java     |  31 -----
 .../accumulo/server/zookeeper/ZooLock.java      |   3 +-
 .../test/functional/CacheTestReader.java        |   2 +-
 .../accumulo/fate/zookeeper/ZooLockTest.java    |  12 +-
 .../org/apache/accumulo/test/MetaSplitTest.java |   1 +
 60 files changed, 310 insertions(+), 288 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
index ece5eff..f354f9c 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
@@ -296,7 +296,6 @@ public class TableOperationsImpl extends TableOperationsHelper {
         return null;
       }
       String ret = waitForTableOperation(opid);
-      Tables.clearCache(instance);
       return ret;
     } catch (ThriftSecurityException e) {
       String tableName = ByteBufferUtil.toString(args.get(0));
@@ -483,7 +482,6 @@ public class TableOperationsImpl extends TableOperationsHelper {
           tabLocator.invalidateCache(tl.tablet_location);
           continue;
         } catch (ThriftSecurityException e) {
-          Tables.clearCache(instance);
           if (!Tables.exists(instance, tableId))
             throw new TableNotFoundException(tableId, tableName, null);
           throw new AccumuloSecurityException(e.user, e.code, e);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineScanner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineScanner.java b/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineScanner.java
index 9c53c1d..1f4539b 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineScanner.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineScanner.java
@@ -211,10 +211,7 @@ class OfflineIterator implements Iterator<Entry<Key,Value>> {
     
     while (eloc.getSecond() != null) {
       if (Tables.getTableState(instance, tableId) != TableState.OFFLINE) {
-        Tables.clearCache(instance);
-        if (Tables.getTableState(instance, tableId) != TableState.OFFLINE) {
-          throw new AccumuloException("Table is online " + tableId + " cannot scan tablet in offline mode " + eloc.getFirst());
-        }
+        throw new AccumuloException("Table is online " + tableId + " cannot scan tablet in offline mode " + eloc.getFirst());
       }
       
       UtilWaitThread.sleep(250);
@@ -230,7 +227,7 @@ class OfflineIterator implements Iterator<Entry<Key,Value>> {
     
     if (currentExtent != null && !extent.isPreviousExtent(currentExtent))
       throw new AccumuloException(" " + currentExtent + " is not previous extent " + extent);
-
+    
     String tablesDir = instance.getConfiguration().get(Property.INSTANCE_DFS_DIR) + "/tables";
     String[] volumes = instance.getConfiguration().get(Property.INSTANCE_VOLUMES).split(",");
     if (volumes.length > 1) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java
----------------------------------------------------------------------
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 68fce23..9ab9ca9 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
@@ -49,7 +49,7 @@ public class ServerClient {
   private synchronized static CuratorCaches getZooCache(Instance instance) {
     CuratorCaches result = zooCaches.get(instance.getZooKeepers());
     if (result == null) {
-      result = new CuratorCaches(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
+      result = CuratorCaches.getInstance(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
       zooCaches.put(instance.getZooKeepers(), result);
     }
     return result;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
----------------------------------------------------------------------
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 5471f43..fba6ebf 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
@@ -34,6 +34,8 @@ import org.apache.curator.framework.recipes.cache.ChildData;
 public class Tables {
   private static SecurityPermission TABLES_PERMISSION = new SecurityPermission("tablesPermission");
   
+  //TODO fix code base for removed Table.clearCache method
+  
   private static CuratorCaches getZooCache(Instance instance) {
     SecurityManager sm = System.getSecurityManager();
     if (sm != null) {
@@ -90,10 +92,6 @@ public class Tables {
     return table != null;
   }
   
-  public static void clearCache(Instance instance) {
-    getZooCache(instance).clear(ZooUtil.getRoot(instance) + Constants.ZTABLES);
-  }
-  
   public static String getPrintableTableNameFromId(Map<String,String> tidToNameMap, String tableId) {
     String tableName = tidToNameMap.get(tableId);
     return tableName == null ? "(ID:" + tableId + ")" : tableName;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java
index 883d1a3..9e34300 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java
@@ -382,7 +382,6 @@ public class TabletServerBatchReaderIterator implements Iterator<Entry<Key,Value
         e.setTableInfo(getTableInfo());
         log.debug(e.getMessage(), e);
         
-        Tables.clearCache(instance);
         if (!Tables.exists(instance, table))
           fatalException = new TableDeletedException(table);
         else

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java
index 772e0aa..1a59bba 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java
@@ -477,8 +477,7 @@ public class TabletServerBatchWriter {
       HashSet<String> tableIds = new HashSet<String>();
       for (KeyExtent ke : authorizationFailures.keySet())
         tableIds.add(ke.getTableId().toString());
-      
-      Tables.clearCache(instance);
+
       for (String tableId : tableIds)
         if (!Tables.exists(instance, tableId))
           throw new TableDeletedException(tableId);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java
index 37e4579..f54a5aa 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java
@@ -68,7 +68,6 @@ import org.apache.thrift.TApplicationException;
 import org.apache.thrift.TException;
 import org.apache.thrift.TServiceClient;
 
-
 public class ThriftScanner {
   private static final Logger log = Logger.getLogger(ThriftScanner.class);
   
@@ -122,7 +121,7 @@ public class ThriftScanner {
       throw new AccumuloSecurityException(e.user, e.code, e);
     } catch (TException e) {
       log.debug("Error getting transport to " + server + " : " + e);
-    } 
+    }
     
     throw new AccumuloException("getBatchFromServer: failed");
   }
@@ -214,7 +213,7 @@ public class ThriftScanner {
           Span locateSpan = Trace.start("scan:locateTablet");
           try {
             loc = TabletLocator.getInstance(instance, scanState.tableId).locateTablet(scanState.startRow, scanState.skipStartRow, false, credentials);
-
+            
             if (loc == null) {
               if (!Tables.exists(instance, scanState.tableId.toString()))
                 throw new TableDeletedException(scanState.tableId.toString());
@@ -266,7 +265,6 @@ public class ThriftScanner {
         try {
           results = scan(loc, scanState, conf);
         } catch (AccumuloSecurityException e) {
-          Tables.clearCache(instance);
           if (!Tables.exists(instance, scanState.tableId.toString()))
             throw new TableDeletedException(scanState.tableId.toString());
           e.setTableInfo(Tables.getPrintableTableInfoFromId(instance, scanState.tableId.toString()));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java b/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java
index f6fc744..058cdeb 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java
@@ -671,10 +671,7 @@ public abstract class InputFormatBase<K,V> implements InputFormat<K,V> {
     String tableId = Tables.getTableId(instance, tableName);
     
     if (Tables.getTableState(instance, tableId) != TableState.OFFLINE) {
-      Tables.clearCache(instance);
-      if (Tables.getTableState(instance, tableId) != TableState.OFFLINE) {
-        throw new AccumuloException("Table is online " + tableName + "(" + tableId + ") cannot scan table in offline mode ");
-      }
+      throw new AccumuloException("Table is online " + tableName + "(" + tableId + ") cannot scan table in offline mode ");
     }
     
     for (Range range : ranges) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
index c280b97..8341113 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
@@ -695,10 +695,7 @@ public abstract class InputFormatBase<K,V> extends InputFormat<K,V> {
     String tableId = Tables.getTableId(instance, tableName);
     
     if (Tables.getTableState(instance, tableId) != TableState.OFFLINE) {
-      Tables.clearCache(instance);
-      if (Tables.getTableState(instance, tableId) != TableState.OFFLINE) {
-        throw new AccumuloException("Table is online " + tableName + "(" + tableId + ") cannot scan table in offline mode ");
-      }
+      throw new AccumuloException("Table is online " + tableName + "(" + tableId + ") cannot scan table in offline mode ");
     }
     
     for (Range range : ranges) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FateCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FateCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FateCommand.java
index bb09e3a..efaac8f 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FateCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FateCommand.java
@@ -42,12 +42,13 @@ import org.apache.zookeeper.KeeperException;
 
 /**
  * Manage FATE transactions
- * 
  */
 public class FateCommand extends Command {
   
+  // Move to constants
+  @Deprecated
   private static final String SCHEME = "digest";
-  
+  @Deprecated
   private static final String USER = "accumulo";
   
   private Option secretOption;
@@ -144,7 +145,7 @@ public class FateCommand extends Command {
       secret = conf.get(Property.INSTANCE_SECRET);
     }
     
-    return CuratorReaderWriter.getInstance(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut(), SCHEME,
+    return new CuratorReaderWriter(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut(), SCHEME,
         (USER + ":" + secret).getBytes());
   }
   

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java
----------------------------------------------------------------------
diff --git a/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java b/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java
index 1564aa9..4a2b562 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/ZooStore.java
@@ -408,6 +408,8 @@ public class ZooStore<T> implements TStore<T> {
     
     try {
       byte[] data = curator.getData(getTXPath(tid) + "/prop_" + prop, null);
+      if (data == null)
+        return null;
       
       if (data[0] == 'O') {
         byte[] sera = new byte[data.length - 2];

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorCaches.java
----------------------------------------------------------------------
diff --git a/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorCaches.java b/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorCaches.java
index eac9b8f..8b42aac 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorCaches.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorCaches.java
@@ -28,8 +28,8 @@ import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.curator.framework.recipes.cache.NodeCache;
 import org.apache.curator.framework.recipes.cache.PathChildrenCache;
 import org.apache.curator.framework.recipes.cache.PathChildrenCache.StartMode;
-import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent.Type;
 import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
+import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent.Type;
 import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
 import org.apache.log4j.Logger;
 
@@ -45,11 +45,11 @@ public class CuratorCaches {
   
   private CuratorFramework curator;
   
-  public CuratorCaches(String zooKeepers, int sessionTimeout) {
-    this(CuratorSession.getSession(zooKeepers, sessionTimeout));
+  protected CuratorCaches(String zooKeepers, int sessionTimeout, String scheme, byte[] auths) {
+    this(CuratorSession.getSession(zooKeepers, sessionTimeout, scheme, auths));
   }
   
-  public CuratorCaches(CuratorFramework curator) {
+  private CuratorCaches(CuratorFramework curator) {
     this.curator = curator;
     this.nodeCache = new HashMap<String,NodeCache>();
     this.childrenCache = new HashMap<String,PathChildrenCache>();
@@ -67,7 +67,8 @@ public class CuratorCaches {
         cache.getListenable().addListener(listener);
       }
       try {
-        log.debug("Starting cache against " + zPath + (listener!=null? " using listener " + listener:""));
+        // TODO- spotted master listening to table configuration, possibly due to balancer?
+        log.debug("Starting cache against " + zPath + (listener != null ? " using listener " + listener : ""), new RuntimeException());
         cache.start(StartMode.BUILD_INITIAL_CACHE);
         // I'll do it myself!
         if (listener != null)
@@ -83,6 +84,8 @@ public class CuratorCaches {
             log.debug("Removing cache " + childCache.getCurrentData().getPath() + " because parent cache was added");
             childCache.close();
             nodeCache.remove(child.getPath());
+          } else if (childCache != null) {
+            log.debug("Not removing cache because it has a listener. This is a potential optimization point.");
           }
         }
       } catch (Exception e) {
@@ -137,8 +140,7 @@ public class CuratorCaches {
   }
   
   private synchronized void remove(String zPath) {
-    if (log.isTraceEnabled())
-      log.trace("removing " + zPath + " from cache");
+    log.debug("removing " + zPath + " from cache");
     NodeCache nc = nodeCache.get(zPath);
     if (nc != null) {
       try {
@@ -162,6 +164,7 @@ public class CuratorCaches {
   }
   
   public synchronized void clear() {
+    log.debug("Clearing cache", new RuntimeException());
     for (NodeCache nc : nodeCache.values()) {
       try {
         nc.close();
@@ -181,6 +184,7 @@ public class CuratorCaches {
     childrenCache.clear();
   }
   
+  @Deprecated
   public CuratorFramework getCurator() {
     return curator;
   }
@@ -205,14 +209,27 @@ public class CuratorCaches {
   
   private static Map<String,CuratorCaches> instances = new HashMap<String,CuratorCaches>();
   
+  // Multiton to handle cases of multiple zookeepers
+  public static synchronized CuratorCaches getInstance(String zooKeepers, int sessionTimeout, String scheme, byte[] auths) {
+    CuratorCaches instance = instances.get(zooKeepers);
+    if (instance == null) {
+      instance = new CuratorCaches(zooKeepers, sessionTimeout, scheme, auths);
+      instances.put(zooKeepers, instance);
+    }
+    return instance;
+  }
+  
   public static synchronized CuratorCaches getInstance(String zooKeepers, int sessionTimeout) {
-    String key = zooKeepers + ":" + sessionTimeout;
-    CuratorCaches zc = instances.get(key);
-    if (zc == null) {
-      zc = new CuratorCaches(zooKeepers, sessionTimeout);
-      instances.put(key, zc);
+    return getInstance(zooKeepers, sessionTimeout, null, null);
+  }
+  
+  public static synchronized CuratorCaches getInstance(CuratorFramework curator) {
+    String zooKeepers = curator.getZookeeperClient().getCurrentConnectionString();
+    CuratorCaches instance = instances.get(zooKeepers);
+    if (instance == null) {
+      instance = new CuratorCaches(curator);
+      instances.put(zooKeepers, instance);
     }
-    
-    return zc;
+    return instance;
   }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorReader.java
----------------------------------------------------------------------
diff --git a/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorReader.java b/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorReader.java
index 2f9c46f..0d3897f 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorReader.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorReader.java
@@ -32,7 +32,7 @@ public class CuratorReader {
   private CuratorFramework curator;
   
   public CuratorReader(String zooKeepers, int sessionTimeout) {
-    this(CuratorSession.getSession(zooKeepers, sessionTimeout));
+    this(CuratorSession.getSession(zooKeepers, sessionTimeout, null, null));
   }
   
   public CuratorReader(String zooKeepers, int sessionTimeout, String scheme, byte[] auth) {
@@ -52,7 +52,11 @@ public class CuratorReader {
     try {
       return getCurator().getData().forPath(zPath);
     } catch (Exception e) {
-      throw CuratorUtil.manageException(e);
+      try {
+        throw CuratorUtil.manageException(e);
+      } catch (KeeperException.NoNodeException nne) {
+        return null;
+      }
     }
   }
   
@@ -60,7 +64,11 @@ public class CuratorReader {
     try {
       return getCurator().getData().storingStatIn(stat).forPath(zPath);
     } catch (Exception e) {
-      throw CuratorUtil.manageException(e);
+      try {
+        throw CuratorUtil.manageException(e);
+      } catch (KeeperException.NoNodeException nne) {
+        return null;
+      }
     }
   }
   

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorReaderWriter.java
----------------------------------------------------------------------
diff --git a/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorReaderWriter.java b/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorReaderWriter.java
index c03cadb..f29c23d 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorReaderWriter.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorReaderWriter.java
@@ -18,9 +18,12 @@ package org.apache.accumulo.fate.curator;
 
 import java.security.SecurityPermission;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.utils.EnsurePath;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
@@ -31,19 +34,12 @@ import org.apache.zookeeper.data.Stat;
 
 public class CuratorReaderWriter extends CuratorReader {
   private static SecurityPermission ZOOWRITER_PERMISSION = new SecurityPermission("zookeeperWriterPermission");
+  private static Logger log = Logger.getLogger(CuratorReaderWriter.class);
   
-  protected CuratorReaderWriter(String zooKeepers, int sessionTimeout, String scheme, byte[] auth) {
+  public CuratorReaderWriter(String zooKeepers, int sessionTimeout, String scheme, byte[] auth) {
     super(constructCurator(zooKeepers, sessionTimeout, scheme, auth));
   }
   
-  private static CuratorReaderWriter instance = null;
-  
-  public static synchronized CuratorReaderWriter getInstance(String zookeepers, int timeInMillis, String scheme, byte[] auth) {
-    if (instance == null)
-      instance = new CuratorReaderWriter(zookeepers, timeInMillis, scheme, auth);
-    return instance;
-  }
-  
   private static CuratorFramework constructCurator(String zooKeepers, int sessionTimeout, String scheme, byte[] auth) {
     SecurityManager sm = System.getSecurityManager();
     if (sm != null) {
@@ -83,12 +79,11 @@ public class CuratorReaderWriter extends CuratorReader {
     CuratorFramework curator = getCurator();
     try {
       boolean exists = curator.checkExists().forPath(zPath) != null;
-
-      
-      if (!exists || policy.equals(NodeExistsPolicy.SEQUENTIAL)) {
+      // TODO this should probably be tweaked by to a try catch based implementation
+      // Needs to be made (caseless), needs to make the sequential node (Sequential), or needs to fail (FAIL)
+      if (!exists || policy.equals(NodeExistsPolicy.SEQUENTIAL) || policy.equals(NodeExistsPolicy.FAIL)) {
         return curator.create().withMode(mode).withACL(acls).forPath(zPath, data);
-      }
-      else if (policy.equals(NodeExistsPolicy.OVERWRITE)) {
+      } else if (policy.equals(NodeExistsPolicy.OVERWRITE)) {
         curator.setData().withVersion(version).forPath(zPath, data);
         return zPath;
       }
@@ -107,8 +102,7 @@ public class CuratorReaderWriter extends CuratorReader {
     return putPersistentData(zPath, data, -1, policy);
   }
   
-  public boolean putPersistentDataWithACL(String zPath, byte[] data, NodeExistsPolicy policy, List<ACL> acls)
-      throws KeeperException, InterruptedException {
+  public boolean putPersistentDataWithACL(String zPath, byte[] data, NodeExistsPolicy policy, List<ACL> acls) throws KeeperException, InterruptedException {
     return putData(zPath, data, CreateMode.PERSISTENT, -1, policy, acls) != null;
   }
   
@@ -191,9 +185,9 @@ public class CuratorReaderWriter extends CuratorReader {
     if (data == null)
       return data;
     if (privateACL)
-      putPrivatePersistentData(zPath, createValue, NodeExistsPolicy.OVERWRITE);
+      putPrivatePersistentData(zPath, data, NodeExistsPolicy.OVERWRITE);
     else
-      putPersistentData(zPath, createValue, NodeExistsPolicy.OVERWRITE);
+      putPersistentData(zPath, data, NodeExistsPolicy.OVERWRITE);
     return data;
   }
   
@@ -205,6 +199,23 @@ public class CuratorReaderWriter extends CuratorReader {
     }
   }
   
+  Map<String,EnsurePath> ensurePaths = new HashMap<String,EnsurePath>();
+  
+  public void ensurePath(String path) throws KeeperException, InterruptedException {
+    EnsurePath ep = ensurePaths.get(path);
+    if (ep == null) {
+      ep = getCurator().newNamespaceAwareEnsurePath(path);
+      ensurePaths.put(path, ep);
+    }
+    try {
+      ep.ensure(getCurator().getZookeeperClient());
+    } catch (Exception e) {
+      throw CuratorUtil.manageException(e);
+    }
+  }
+  
+  // Should probably be using ensurePath
+  @Deprecated
   public void mkdirs(String path) throws KeeperException, InterruptedException {
     try {
       getCurator().create().creatingParentsIfNeeded().forPath(path);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorSession.java
----------------------------------------------------------------------
diff --git a/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorSession.java b/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorSession.java
index 51b3476..b040020 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorSession.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorSession.java
@@ -39,22 +39,18 @@ class CuratorSession {
   }
   
   private static CuratorFramework constructCurator(String zookeeperConnectString, int sessionTimeoutMs, String namespace, String scheme, byte[] bytes) {
-    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder().canBeReadOnly(true).sessionTimeoutMs(sessionTimeoutMs).retryPolicy(retry)
+    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder().sessionTimeoutMs(sessionTimeoutMs).retryPolicy(retry)
         .connectString(zookeeperConnectString);
     if (scheme != null && bytes != null)
       builder = builder.authorization(scheme, bytes);
     if (namespace != null)
       builder = builder.namespace(namespace);
     
-    CuratorFramework toRet = builder.build();
+    final CuratorFramework toRet = builder.build();
     toRet.start();
     return toRet;
   }
   
-  public static synchronized CuratorFramework getSession(String zooKeepers, int timeout) {
-    return getSession(zooKeepers, timeout, null, null);
-  }
-  
   public static synchronized CuratorFramework getSession(String zooKeepers, int timeout, String scheme, byte[] auth) {
     
     String sessionKey = sessionKey(zooKeepers, timeout, scheme, auth);
@@ -75,7 +71,8 @@ class CuratorSession {
       sessions.put(sessionKey, curator);
       if (auth != null && !sessions.containsKey(readOnlySessionKey))
         sessions.put(readOnlySessionKey, curator);
-    }
+    } 
+    
     return curator;
   }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorUtil.java
----------------------------------------------------------------------
diff --git a/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorUtil.java b/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorUtil.java
index fee9712..008cd24 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorUtil.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/curator/CuratorUtil.java
@@ -16,7 +16,6 @@
  */
 package org.apache.accumulo.fate.curator;
 
-import java.io.File;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -27,7 +26,9 @@ import java.util.List;
 import org.apache.accumulo.fate.util.UtilWaitThread;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.recipes.cache.ChildData;
+import org.apache.curator.utils.ZKPaths;
 import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.KeeperException.Code;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.common.PathUtils;
 import org.apache.zookeeper.data.Stat;
@@ -37,20 +38,24 @@ public class CuratorUtil {
     SKIP, CREATE, FAIL
   }
   
+  @Deprecated
   public static String getNodeName(ChildData node) {
     return getNodeName(node.getPath());
   }
   
+  @Deprecated
   public static String getNodeName(String nodePath) {
-    return new File(nodePath).getName();
+    return ZKPaths.getNodeFromPath(nodePath);
   }
   
+  @Deprecated
   public static String getNodeParent(ChildData node) {
     return getNodeParent(node.getPath());
   }
   
+  @Deprecated
   public static String getNodeParent(String nodePath) {
-    return new File(nodePath).getParent();
+    return ZKPaths.getPathAndNode(nodePath).getPath();
   }
   
   public static void recursiveDelete(CuratorFramework curator, final String pathRoot, int version) throws KeeperException, InterruptedException {
@@ -62,6 +67,11 @@ public class CuratorUtil {
       try {
         curator.delete().withVersion(version).forPath(tree.get(i));
       } catch (Exception e) {
+        if (e instanceof KeeperException) {
+          KeeperException ke = (KeeperException) e;
+          if (ke.code().equals(Code.NONODE))
+            continue;
+        }
         throw CuratorUtil.manageException(e);
       } // Delete all versions of the node
     }
@@ -81,6 +91,11 @@ public class CuratorUtil {
       try {
         children = curator.getChildren().forPath(node);
       } catch (Exception e) {
+        if (e instanceof KeeperException) {
+          KeeperException ke = (KeeperException) e;
+          if (ke.code().equals(Code.NONODE))
+            continue;
+        }
         throw CuratorUtil.manageException(e);
       }
       for (final String child : children) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java
----------------------------------------------------------------------
diff --git a/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java b/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java
index 345889d..508d446 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java
@@ -74,7 +74,7 @@ public class ZooLock implements Watcher {
   }
   
   public ZooLock(String zookeepers, int timeInMillis, String scheme, byte[] auth, String path) {
-    this(new CuratorCaches(zookeepers, timeInMillis), CuratorReaderWriter.getInstance(zookeepers, timeInMillis, scheme, auth), path);
+    this(CuratorCaches.getInstance(zookeepers, timeInMillis), new CuratorReaderWriter(zookeepers, timeInMillis, scheme, auth), path);
   }
   
   protected ZooLock(CuratorCaches zc, CuratorReaderWriter zrw, String path) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooQueueLock.java
----------------------------------------------------------------------
diff --git a/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooQueueLock.java b/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooQueueLock.java
index bea7ad6..b11c0fb 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooQueueLock.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooQueueLock.java
@@ -40,7 +40,7 @@ public class ZooQueueLock implements QueueLock {
   
   public ZooQueueLock(String zookeepers, int timeInMillis, String scheme, byte[] auth, String path, boolean ephemeral) throws KeeperException,
       InterruptedException {
-    this(CuratorReaderWriter.getInstance(zookeepers, timeInMillis, scheme, auth), path, ephemeral);
+    this(new CuratorReaderWriter(zookeepers, timeInMillis, scheme, auth), path, ephemeral);
   }
   
   protected ZooQueueLock(CuratorReaderWriter zrw, String path, boolean ephemeral) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java b/server/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
index 6c3f110..c4b0058 100644
--- a/server/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
+++ b/server/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
@@ -78,7 +78,6 @@ public class ClientServiceHandler implements ClientService.Iface {
     String tableId = Tables.getNameToIdMap(instance).get(tableName);
     if (tableId == null) {
       // maybe the table exist, but the cache was not updated yet... so try to clear the cache and check again
-      Tables.clearCache(instance);
       tableId = Tables.getNameToIdMap(instance).get(tableName);
       if (tableId == null)
         throw new ThriftTableOperationException(null, tableName, operation, TableOperationExceptionType.NOTFOUND, null);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java b/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
index 6495e55..14e8c81 100644
--- a/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
+++ b/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
@@ -65,7 +65,7 @@ public class HdfsZooInstance implements Instance {
   
   private HdfsZooInstance() {
     AccumuloConfiguration acuConf = ServerConfiguration.getSiteConfiguration();
-    zooCache = new CuratorCaches(acuConf.get(Property.INSTANCE_ZK_HOST), (int) acuConf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT));
+    zooCache = CuratorCaches.getInstance(acuConf.get(Property.INSTANCE_ZK_HOST), (int) acuConf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT));
   }
   
   private static HdfsZooInstance cachedHdfsZooInstance = null;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java b/server/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
index 70b8676..cdca810 100644
--- a/server/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
+++ b/server/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
@@ -31,15 +31,14 @@ import org.apache.accumulo.core.conf.ConfigurationObserver;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.curator.CuratorUtil;
-import org.apache.accumulo.server.client.HdfsZooInstance;
-import org.apache.accumulo.server.zookeeper.ZooCache;
+import org.apache.accumulo.server.curator.CuratorCaches;
 import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.log4j.Logger;
 
 public class TableConfiguration extends AccumuloConfiguration {
   private static final Logger log = Logger.getLogger(TableConfiguration.class);
   
-  private static ZooCache tablePropCache = null;
+  private static CuratorCaches tablePropCache = null;
   private final String instanceId;
   private final AccumuloConfiguration parent;
   
@@ -55,7 +54,7 @@ public class TableConfiguration extends AccumuloConfiguration {
     if (tablePropCache == null)
       synchronized (TableConfiguration.class) {
         if (tablePropCache == null)
-          tablePropCache = new ZooCache(HdfsZooInstance.getInstance().getConfiguration());
+          tablePropCache = CuratorCaches.getInstance();
       }
     String confPath = ZooUtil.getRoot(instanceId) + Constants.ZTABLES + '/' + table + Constants.ZTABLE_CONF;
     tablePropCache.getChildren(confPath, new TableConfWatcher(this));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java b/server/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
index 3a9b73b..98fd63b 100644
--- a/server/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
+++ b/server/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
@@ -52,7 +52,7 @@ public class ZooConfiguration extends AccumuloConfiguration {
   
   synchronized public static ZooConfiguration getInstance(Instance inst, AccumuloConfiguration parent) {
     if (instance == null) {
-      propCache = new CuratorCaches(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut());
+      propCache = CuratorCaches.getInstance(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut());
       instance = new ZooConfiguration(parent);
       instanceId = inst.getInstanceID();
       // Sets up a child cache listener for all properties
@@ -63,7 +63,7 @@ public class ZooConfiguration extends AccumuloConfiguration {
   
   synchronized public static ZooConfiguration getInstance(AccumuloConfiguration parent) {
     if (instance == null) {
-      propCache = new CuratorCaches(parent.get(Property.INSTANCE_ZK_HOST), (int) parent.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT));
+      propCache = CuratorCaches.getInstance(parent.get(Property.INSTANCE_ZK_HOST), (int) parent.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT));
       instance = new ZooConfiguration(parent);
       @SuppressWarnings("deprecation")
       String deprecatedInstanceIdFromHdfs = ZooKeeperInstance.getInstanceIDFromHdfs(ServerConstants.getInstanceIdLocation());

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java b/server/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java
index 4673357..c03d27f 100644
--- a/server/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java
+++ b/server/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java
@@ -35,15 +35,15 @@ import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.curator.CuratorUtil;
 import org.apache.accumulo.fate.zookeeper.TransactionWatcher.Arbitrator;
 import org.apache.accumulo.server.client.HdfsZooInstance;
+import org.apache.accumulo.server.curator.CuratorCaches;
 import org.apache.accumulo.server.zookeeper.TransactionWatcher.ZooArbitrator;
-import org.apache.accumulo.server.zookeeper.ZooCache;
 import org.apache.accumulo.server.zookeeper.ZooLock;
 import org.apache.hadoop.io.Text;
 import org.apache.log4j.Logger;
 
 public class MetadataConstraints implements Constraint {
   
-  private ZooCache zooCache = null;
+  private CuratorCaches zooCache = null;
   private String zooRoot = null;
   
   private static final Logger log = Logger.getLogger(MetadataConstraints.class);
@@ -237,7 +237,7 @@ public class MetadataConstraints implements Constraint {
           }
         } else if (new ColumnFQ(columnUpdate).equals(MetadataTable.LOCK_COLUMN)) {
           if (zooCache == null) {
-            zooCache = new ZooCache();
+            zooCache = CuratorCaches.getInstance();
           }
           
           if (zooRoot == null) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/curator/CuratorCaches.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/curator/CuratorCaches.java b/server/src/main/java/org/apache/accumulo/server/curator/CuratorCaches.java
new file mode 100644
index 0000000..173f999
--- /dev/null
+++ b/server/src/main/java/org/apache/accumulo/server/curator/CuratorCaches.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.server.curator;
+
+import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.server.conf.ServerConfiguration;
+
+public class CuratorCaches extends org.apache.accumulo.fate.curator.CuratorCaches {
+  private static CuratorCaches instance = null;
+
+  private CuratorCaches(String string, int timeInMillis, String secret) {
+    super(string, timeInMillis, CuratorReaderWriter.SCHEME, (CuratorReaderWriter.USER + ":" + secret).getBytes());
+  }
+  
+  public static CuratorCaches getInstance() {
+    AccumuloConfiguration conf = ServerConfiguration.getSiteConfiguration();
+    return getInstance(conf.get(Property.INSTANCE_ZK_HOST), (int) conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT), conf.get(Property.INSTANCE_SECRET));
+  }
+  
+  public static CuratorCaches getInstance(String secret) {
+    AccumuloConfiguration conf = ServerConfiguration.getSiteConfiguration();
+    return getInstance(conf.get(Property.INSTANCE_ZK_HOST), (int) conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT), secret);
+  }
+  
+  // This should be a singleton since the caches are here.
+  public static synchronized CuratorCaches getInstance(String zkHosts, int timeout, String secret) {
+    if (instance == null) {
+      instance = new CuratorCaches(zkHosts, timeout, secret);
+    } 
+
+    return instance;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/curator/CuratorReaderWriter.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/curator/CuratorReaderWriter.java b/server/src/main/java/org/apache/accumulo/server/curator/CuratorReaderWriter.java
index 0fd1bcb..3a0ba5a 100644
--- a/server/src/main/java/org/apache/accumulo/server/curator/CuratorReaderWriter.java
+++ b/server/src/main/java/org/apache/accumulo/server/curator/CuratorReaderWriter.java
@@ -19,10 +19,11 @@ package org.apache.accumulo.server.curator;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.server.conf.ServerConfiguration;
+import org.apache.log4j.Logger;
 
 public class CuratorReaderWriter extends org.apache.accumulo.fate.curator.CuratorReaderWriter {
-  private static final String SCHEME = "digest";
-  private static final String USER = "accumulo";
+  protected static final String SCHEME = "digest";
+  protected static final String USER = "accumulo";
   private static CuratorReaderWriter instance = null;
   
   private CuratorReaderWriter(String string, int timeInMillis, String secret) {
@@ -39,9 +40,12 @@ public class CuratorReaderWriter extends org.apache.accumulo.fate.curator.Curato
     return getInstance(conf.get(Property.INSTANCE_ZK_HOST), (int) conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT), secret);
   }
   
+  // This probably doesn't need to be singletons since the CuratorFrameworks are already treated as such. CuratorReaderWriter is pretty lightweight.
   public static synchronized CuratorReaderWriter getInstance(String zkHosts, int timeout, String secret) {
     if (instance == null) {
       instance = new CuratorReaderWriter(zkHosts, timeout, secret);
+    } else {
+      Logger.getLogger(CuratorReaderWriter.class).error("Returning caches curator against " + instance.getCurator().getZookeeperClient().getCurrentConnectionString(), new RuntimeException());
     }
     return instance;
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java b/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
index 293c54d..2a7021b 100644
--- a/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
+++ b/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
@@ -77,6 +77,7 @@ import org.apache.accumulo.server.Accumulo;
 import org.apache.accumulo.server.ServerConstants;
 import org.apache.accumulo.server.client.HdfsZooInstance;
 import org.apache.accumulo.server.conf.ServerConfiguration;
+import org.apache.accumulo.server.curator.CuratorReaderWriter;
 import org.apache.accumulo.server.fs.VolumeManager;
 import org.apache.accumulo.server.fs.VolumeManagerImpl;
 import org.apache.accumulo.server.master.state.tables.TableManager;
@@ -160,6 +161,8 @@ public class SimpleGarbageCollector implements Iface {
     gc.init(fs, instance, SecurityConstants.getSystemCredentials(), serverConf.getConfiguration().getBoolean(Property.GC_TRASH_IGNORE));
     Accumulo.enableTracing(address, "gc");
     gc.run();
+    
+    CuratorReaderWriter.getInstance().getCurator().close();
   }
   
   public SimpleGarbageCollector() {}
@@ -349,7 +352,6 @@ public class SimpleGarbageCollector implements Iface {
       }
     }
     
-    Tables.clearCache(instance);
     Set<String> tableIdsInZookeeper = Tables.getIdToNameMap(instance).keySet();
     
     tableIdsWithDeletes.removeAll(tableIdsInZookeeper);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java b/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
index 16a5b07..70dc21c 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
@@ -41,13 +41,13 @@ import org.apache.accumulo.core.util.ServerServices;
 import org.apache.accumulo.core.util.ThriftUtil;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.curator.CuratorUtil;
+import org.apache.accumulo.server.curator.CuratorCaches;
 import org.apache.accumulo.server.curator.CuratorReaderWriter;
 import org.apache.accumulo.server.master.state.TServerInstance;
 import org.apache.accumulo.server.security.SecurityConstants;
 import org.apache.accumulo.server.util.AddressUtil;
 import org.apache.accumulo.server.util.Halt;
 import org.apache.accumulo.server.util.time.SimpleTimer;
-import org.apache.accumulo.server.zookeeper.ZooCache;
 import org.apache.accumulo.server.zookeeper.ZooLock;
 import org.apache.accumulo.trace.instrument.Tracer;
 import org.apache.curator.framework.CuratorFramework;
@@ -72,7 +72,7 @@ public class LiveTServerSet {
   private final Listener cback;
   private final Instance instance;
   private final AccumuloConfiguration conf;
-  private ZooCache zooCache;
+  private CuratorCaches zooCache;
   
   public class TServerConnection {
     private final InetSocketAddress address;
@@ -217,9 +217,9 @@ public class LiveTServerSet {
     
   }
   
-  public synchronized ZooCache getZooCache() {
+  public synchronized CuratorCaches getZooCache() {
     if (zooCache == null)
-      zooCache = new ZooCache();
+      zooCache = CuratorCaches.getInstance();
     return zooCache;
   }
   
@@ -243,7 +243,6 @@ public class LiveTServerSet {
     }, 0, 5000);
     
     Collection<ChildData> result = getZooCache().getChildren(ZooUtil.getRoot(instance) + Constants.ZTSERVERS, serversListener);
-    log.debug("Attaching SERVERSLISTENER to " + (ZooUtil.getRoot(instance) + Constants.ZTSERVERS) + " - received " + result);
   }
   
   private void deleteServerNode(String server) {
@@ -272,7 +271,6 @@ public class LiveTServerSet {
     @Override
     public void childEvent(CuratorFramework curator, PathChildrenCacheEvent event) throws Exception {
       final Set<TServerInstance> doomed = new HashSet<TServerInstance>();
-      log.debug("SERVERSLISTENER - Received event " + event.getType() + " for node " + event.getData().getPath());
 
       String server = CuratorUtil.getNodeName(event.getData());
       TServerInfo info = current.get(server);
@@ -309,8 +307,7 @@ public class LiveTServerSet {
     public void childEvent(CuratorFramework curator, PathChildrenCacheEvent event) throws Exception {
       final Set<TServerInstance> updates = new HashSet<TServerInstance>();
       final Set<TServerInstance> doomed = new HashSet<TServerInstance>();
-      log.debug("LOCKLISTENER - Received event " + event.getType() + " for node " + event.getData().getPath());
-
+      
       String server = CuratorUtil.getNodeName(CuratorUtil.getNodeParent(event.getData()));
       TServerInfo info = current.get(server);
       
@@ -368,7 +365,6 @@ public class LiveTServerSet {
     for (TServerInfo c : current.values()) {
       result.add(c.instance);
     }
-    log.debug("Returning " + result + " for current tservers");
     return result;
   }
   

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/Master.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/Master.java b/server/src/main/java/org/apache/accumulo/server/master/Master.java
index f5b5530..5aaf401 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/Master.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/Master.java
@@ -398,7 +398,6 @@ public class Master implements LiveTServerSet.Listener, TableObserver, CurrentSt
   }
   
   public void mustBeOnline(final String tableId) throws ThriftTableOperationException {
-    Tables.clearCache(instance);
     if (!Tables.getTableState(instance, tableId).equals(TableState.ONLINE))
       throw new ThriftTableOperationException(tableId, null, TableOperation.MERGE, TableOperationExceptionType.OFFLINE, "table is not online");
   }
@@ -480,7 +479,7 @@ public class Master implements LiveTServerSet.Listener, TableObserver, CurrentSt
           public byte[] mutate(byte[] currentValue) throws Exception {
             long flushID = Long.parseLong(new String(currentValue));
             flushID++;
-            return ("" + flushID).getBytes();
+            return (Long.toString(flushID)).getBytes();
           }
         });
       } catch (NoNodeException nne) {
@@ -1529,6 +1528,7 @@ public class Master implements LiveTServerSet.Listener, TableObserver, CurrentSt
     for (TabletGroupWatcher watcher : watchers) {
       watcher.join(remaining(deadline));
     }
+    
     log.info("exiting");
   }
   

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/TabletGroupWatcher.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/TabletGroupWatcher.java b/server/src/main/java/org/apache/accumulo/server/master/TabletGroupWatcher.java
index a7fb4c9..d937e3e 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/TabletGroupWatcher.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/TabletGroupWatcher.java
@@ -73,7 +73,6 @@ import org.apache.hadoop.io.Text;
 import org.apache.thrift.TException;
 
 class TabletGroupWatcher extends Daemon {
-  
   private final Master master;
   final TabletStateStore store;
   final TabletGroupWatcher dependentWatcher;
@@ -135,6 +134,7 @@ class TabletGroupWatcher extends Daemon {
           if (tls == null) {
             continue;
           }
+          
           // ignore entries for tables that do not exist in zookeeper
           if (TableManager.getInstance().getTableState(tls.extent.getTableId().toString()) == null)
             continue;
@@ -645,4 +645,4 @@ class TabletGroupWatcher extends Daemon {
     }
   }
   
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/recovery/RecoveryManager.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/recovery/RecoveryManager.java b/server/src/main/java/org/apache/accumulo/server/master/recovery/RecoveryManager.java
index fb3cc8f..89bd3dd 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/recovery/RecoveryManager.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/recovery/RecoveryManager.java
@@ -35,9 +35,9 @@ import org.apache.accumulo.core.data.KeyExtent;
 import org.apache.accumulo.core.util.NamingThreadFactory;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.server.ServerConstants;
+import org.apache.accumulo.server.curator.CuratorCaches;
 import org.apache.accumulo.server.master.Master;
 import org.apache.accumulo.server.zookeeper.DistributedWorkQueue;
-import org.apache.accumulo.server.zookeeper.ZooCache;
 import org.apache.hadoop.fs.Path;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.KeeperException;
@@ -51,12 +51,12 @@ public class RecoveryManager {
   private Set<String> sortsQueued = new HashSet<String>();
   private ScheduledExecutorService executor;
   private Master master;
-  private ZooCache zooCache;
+  private CuratorCaches zooCache;
   
   public RecoveryManager(Master master) {
     this.master = master;
     executor = Executors.newScheduledThreadPool(4, new NamingThreadFactory("Walog sort starter "));
-    zooCache = new ZooCache();
+    zooCache = CuratorCaches.getInstance();
     try {
       List<String> workIDs = new DistributedWorkQueue(ZooUtil.getRoot(master.getInstance()) + Constants.ZRECOVERY).getWorkQueued();
       sortsQueued.addAll(workIDs);
@@ -107,7 +107,7 @@ public class RecoveryManager {
   }
   
   private void initiateSort(String sortId, String source, final String destination) throws KeeperException, InterruptedException, IOException {
-    String work =  source + "|" + destination; 
+    String work = source + "|" + destination;
     new DistributedWorkQueue(ZooUtil.getRoot(master.getInstance()) + Constants.ZRECOVERY).addWork(sortId, work.getBytes());
     
     synchronized (this) {
@@ -141,7 +141,7 @@ public class RecoveryManager {
             sortsQueued.remove(sortId);
           }
         }
-
+        
         if (master.getFileSystem().exists(new Path(dest, "finished"))) {
           synchronized (this) {
             closeTasksQueued.remove(sortId);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/state/DeadServerList.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/DeadServerList.java b/server/src/main/java/org/apache/accumulo/server/master/state/DeadServerList.java
index e39664c..17d5ede 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/state/DeadServerList.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/state/DeadServerList.java
@@ -33,7 +33,7 @@ public class DeadServerList {
     this.path = path;
     CuratorReaderWriter zoo = CuratorReaderWriter.getInstance();
     try {
-      zoo.mkdirs(path);
+      zoo.ensurePath(path);
     } catch (Exception ex) {
       log.error("Unable to make parent directories of " + path, ex);
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataStateStore.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataStateStore.java b/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataStateStore.java
index ec25f85..2f2e07b 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataStateStore.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataStateStore.java
@@ -33,9 +33,10 @@ import org.apache.accumulo.core.util.RootTable;
 import org.apache.accumulo.server.client.HdfsZooInstance;
 import org.apache.accumulo.server.security.SecurityConstants;
 import org.apache.hadoop.io.Text;
+import org.apache.log4j.Logger;
 
 public class MetaDataStateStore extends TabletStateStore {
-  // private static final Logger log = Logger.getLogger(MetaDataStateStore.class);
+  private static final Logger log = Logger.getLogger(MetaDataStateStore.class);
   
   private static final int THREADS = 4;
   private static final int LATENCY = 1000;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java b/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java
index 9a20b2e..fbe3d97 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java
@@ -120,7 +120,8 @@ public class MetaDataTableScanner implements Iterator<TabletLocationState> {
   @Override
   public TabletLocationState next() {
     try {
-      return fetch();
+      TabletLocationState toRet = fetch();
+      return toRet;
     } catch (RuntimeException ex) {
       // something is wrong with the records in the !METADATA table, just skip over it
       log.error(ex, ex);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java b/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java
index 67ba62a..2aca575 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java
@@ -46,7 +46,7 @@ public class TabletStateChangeIterator extends SkippingIterator {
   private static final String SERVERS_OPTION = "servers";
   private static final String TABLES_OPTION = "tables";
   private static final String MERGES_OPTION = "merges";
-  // private static final Logger log = Logger.getLogger(TabletStateChangeIterator.class);
+//  private static final Logger log = Logger.getLogger(TabletStateChangeIterator.class);
   
   Set<TServerInstance> current;
   Set<String> onlineTables;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java b/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java
index 95b0771..38db162 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java
@@ -22,8 +22,8 @@ import java.util.List;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.curator.CuratorReaderWriter.NodeExistsPolicy;
 import org.apache.accumulo.server.client.HdfsZooInstance;
+import org.apache.accumulo.server.curator.CuratorCaches;
 import org.apache.accumulo.server.curator.CuratorReaderWriter;
-import org.apache.accumulo.server.zookeeper.ZooCache;
 import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.log4j.Logger;
 
@@ -33,8 +33,9 @@ public class ZooStore implements DistributedStore {
   
   String basePath;
   
-  ZooCache cache = new ZooCache();
+  CuratorCaches cache = CuratorCaches.getInstance();
   
+  // TODO I think this needs attention
   public ZooStore(String basePath) throws IOException {
     if (basePath.endsWith("/"))
       basePath = basePath.substring(0, basePath.length() - 1);
@@ -75,7 +76,6 @@ public class ZooStore implements DistributedStore {
     try {
       path = relative(path);
       CuratorReaderWriter.getInstance().putPersistentData(path, bs, NodeExistsPolicy.OVERWRITE);
-      cache.clear();
       log.debug("Wrote " + new String(bs) + " to " + path);
     } catch (Exception ex) {
       throw new DistributedStoreException(ex);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java b/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
index bcc342c..fb09ccf 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
@@ -89,7 +89,6 @@ public class ZooTabletStateStore extends TabletStateStore {
             }
           }
           TabletLocationState result = new TabletLocationState(RootTable.EXTENT, futureSession, currentSession, lastSession, logs, false);
-          log.debug("Returning root tablet state: " + result);
           return result;
         } catch (Exception ex) {
           throw new RuntimeException(ex);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/state/tables/TableManager.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/state/tables/TableManager.java b/server/src/main/java/org/apache/accumulo/server/master/state/tables/TableManager.java
index 296ffb3..1e37718 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/state/tables/TableManager.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/state/tables/TableManager.java
@@ -32,13 +32,12 @@ import org.apache.accumulo.fate.curator.CuratorReaderWriter.Mutator;
 import org.apache.accumulo.fate.curator.CuratorReaderWriter.NodeExistsPolicy;
 import org.apache.accumulo.fate.curator.CuratorUtil;
 import org.apache.accumulo.server.client.HdfsZooInstance;
+import org.apache.accumulo.server.curator.CuratorCaches;
 import org.apache.accumulo.server.curator.CuratorReaderWriter;
 import org.apache.accumulo.server.util.TablePropUtil;
-import org.apache.accumulo.server.zookeeper.ZooCache;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
-import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent.Type;
 import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.KeeperException;
@@ -53,7 +52,7 @@ public class TableManager {
   private static TableManager tableManager = null;
   
   private final Instance instance;
-  private ZooCache zooStateCache;
+  private CuratorCaches zooStateCache;
   
   public static void prepareNewTableState(String instanceId, String tableId, String tableName, TableState state, NodeExistsPolicy existsPolicy)
       throws KeeperException, InterruptedException {
@@ -81,7 +80,7 @@ public class TableManager {
   
   private TableManager() {
     instance = HdfsZooInstance.getInstance();
-    zooStateCache = new ZooCache();
+    zooStateCache = CuratorCaches.getInstance();
     setupListeners();
     updateTableStateCache();
   }
@@ -168,7 +167,6 @@ public class TableManager {
         String sState = new String(data);
         try {
           tState = TableState.valueOf(sState);
-          log.debug("updateTableStateCache reporting " + tableId + " with state " + tState + " based on " + new String(data));
         } catch (IllegalArgumentException e) {
           log.error("Unrecognized state for table with tableId=" + tableId + ": " + sState);
         }
@@ -234,10 +232,15 @@ public class TableManager {
   private class AllTablesListener implements PathChildrenCacheListener {
     @Override
     public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
-      if (event.getType().equals(Type.CHILD_ADDED)) {
-        zooStateCache.getChildren(event.getData().getPath(), new TableListener());
-      } else if (event.getType().equals(Type.CHILD_REMOVED)) {
-        zooStateCache.clear(event.getData().getPath());
+      switch (event.getType()) {
+        case CHILD_ADDED:
+        case INITIALIZED:
+          zooStateCache.getChildren(event.getData().getPath(), new TableListener());
+          break;
+        case CHILD_REMOVED:
+          zooStateCache.clear(event.getData().getPath());
+        default:
+          break;
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/tableOps/BulkImport.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/tableOps/BulkImport.java b/server/src/main/java/org/apache/accumulo/server/master/tableOps/BulkImport.java
index e8146f9..a08fa3c 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/tableOps/BulkImport.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/tableOps/BulkImport.java
@@ -127,7 +127,6 @@ public class BulkImport extends MasterRepo {
       return 100;
     
     Instance instance = HdfsZooInstance.getInstance();
-    Tables.clearCache(instance);
     if (Tables.getTableState(instance, tableId) == TableState.ONLINE) {
       long reserve1, reserve2;
       reserve1 = reserve2 = Utils.reserveHdfsDirectory(sourceDir, tid);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/tableOps/CloneTable.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/tableOps/CloneTable.java b/server/src/main/java/org/apache/accumulo/server/master/tableOps/CloneTable.java
index b57b003..4334b36 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/tableOps/CloneTable.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/tableOps/CloneTable.java
@@ -21,7 +21,6 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.accumulo.core.client.Instance;
-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.ThriftSecurityException;
 import org.apache.accumulo.core.master.state.tables.TableState;
@@ -146,7 +145,6 @@ class CloneZookeeper extends MasterRepo {
       
       TableManager.getInstance().cloneTable(cloneInfo.srcTableId, cloneInfo.tableId, cloneInfo.tableName, cloneInfo.propertiesToSet,
           cloneInfo.propertiesToExclude, NodeExistsPolicy.OVERWRITE);
-      Tables.clearCache(instance);
       return new CloneMetadata(cloneInfo);
     } finally {
       Utils.tableNameLock.unlock();
@@ -155,10 +153,8 @@ class CloneZookeeper extends MasterRepo {
   
   @Override
   public void undo(long tid, Master environment) throws Exception {
-    Instance instance = HdfsZooInstance.getInstance();
     TableManager.getInstance().removeTable(cloneInfo.tableId);
     Utils.unreserveTable(cloneInfo.tableId, tid, true);
-    Tables.clearCache(instance);
   }
   
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/tableOps/CompactRange.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/tableOps/CompactRange.java b/server/src/main/java/org/apache/accumulo/server/master/tableOps/CompactRange.java
index 5d98ed4..7b8f064 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/tableOps/CompactRange.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/tableOps/CompactRange.java
@@ -144,7 +144,6 @@ class CompactionDriver extends MasterRepo {
     long scanTime = System.currentTimeMillis() - t1;
     
     Instance instance = master.getInstance();
-    Tables.clearCache(instance);
     if (tabletCount == 0 && !Tables.exists(instance, tableId))
       throw new ThriftTableOperationException(tableId, null, TableOperation.COMPACT, TableOperationExceptionType.NOTFOUND, null);
     

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/tableOps/CreateTable.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/tableOps/CreateTable.java b/server/src/main/java/org/apache/accumulo/server/master/tableOps/CreateTable.java
index abce1a9..e130597 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/tableOps/CreateTable.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/tableOps/CreateTable.java
@@ -23,7 +23,6 @@ import java.util.Map.Entry;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.admin.TimeType;
-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.ThriftSecurityException;
 import org.apache.accumulo.core.data.KeyExtent;
@@ -153,7 +152,7 @@ class CreateDir extends MasterRepo {
   @Override
   public void undo(long tid, Master master) throws Exception {
     VolumeManager fs = master.getFileSystem();
-    for(String dir : ServerConstants.getTablesDirs()) {
+    for (String dir : ServerConstants.getTablesDirs()) {
       fs.deleteRecursively(new Path(dir + "/" + tableInfo.tableId));
     }
     
@@ -191,7 +190,6 @@ class PopulateZookeeper extends MasterRepo {
       for (Entry<String,String> entry : tableInfo.props.entrySet())
         TablePropUtil.setTableProperty(tableInfo.tableId, entry.getKey(), entry.getValue());
       
-      Tables.clearCache(instance);
       return new CreateDir(tableInfo);
     } finally {
       Utils.tableNameLock.unlock();
@@ -201,10 +199,8 @@ class PopulateZookeeper extends MasterRepo {
   
   @Override
   public void undo(long tid, Master master) throws Exception {
-    Instance instance = master.getInstance();
     TableManager.getInstance().removeTable(tableInfo.tableId);
     Utils.unreserveTable(tableInfo.tableId, tid, true);
-    Tables.clearCache(instance);
   }
   
 }
@@ -232,9 +228,7 @@ class SetupPermissions extends MasterRepo {
       }
     }
     
-    // setup permissions in zookeeper before table info in zookeeper
-    // this way concurrent users will not get a spurious permission denied
-    // error
+    // setup permissions in zookeeper before table info in zookeeper this way concurrent users will not get a spurious permission denied error
     return new PopulateZookeeper(tableInfo);
   }
   

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/tableOps/DeleteTable.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/tableOps/DeleteTable.java b/server/src/main/java/org/apache/accumulo/server/master/tableOps/DeleteTable.java
index 7b4c69b..1d746ef 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/tableOps/DeleteTable.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/tableOps/DeleteTable.java
@@ -24,7 +24,6 @@ import org.apache.accumulo.core.client.BatchScanner;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.client.Scanner;
-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.ThriftSecurityException;
 import org.apache.accumulo.core.data.Key;
@@ -179,7 +178,6 @@ class CleanUp extends MasterRepo {
     // remove table from zookeeper
     try {
       TableManager.getInstance().removeTable(tableId);
-      Tables.clearCache(master.getInstance());
     } catch (Exception e) {
       log.error("Failed to find table id in zookeeper", e);
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/tableOps/ExportTable.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/tableOps/ExportTable.java b/server/src/main/java/org/apache/accumulo/server/master/tableOps/ExportTable.java
index 5ec1eb9..a3fc269 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/tableOps/ExportTable.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/tableOps/ExportTable.java
@@ -77,7 +77,6 @@ class WriteExportFiles extends MasterRepo {
   
   private void checkOffline(Connector conn) throws Exception {
     if (Tables.getTableState(conn.getInstance(), tableInfo.tableID) != TableState.OFFLINE) {
-      Tables.clearCache(conn.getInstance());
       if (Tables.getTableState(conn.getInstance(), tableInfo.tableID) != TableState.OFFLINE) {
         throw new ThriftTableOperationException(tableInfo.tableID, tableInfo.tableName, TableOperation.EXPORT, TableOperationExceptionType.OTHER,
             "Table is not offline");

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/tableOps/ImportTable.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/tableOps/ImportTable.java b/server/src/main/java/org/apache/accumulo/server/master/tableOps/ImportTable.java
index 349e6e0..bb01bf1 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/tableOps/ImportTable.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/tableOps/ImportTable.java
@@ -35,7 +35,6 @@ import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.BatchWriterConfig;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.admin.TableOperationsImpl;
-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.client.impl.thrift.ThriftSecurityException;
@@ -315,7 +314,7 @@ class MapImportFileNames extends MasterRepo {
       VolumeManager fs = environment.getFileSystem();
       
       fs.mkdirs(new Path(tableInfo.importDir));
-
+      
       FileStatus[] files = fs.listStatus(new Path(tableInfo.exportDir));
       
       UniqueNameAllocator namer = UniqueNameAllocator.getInstance();
@@ -436,8 +435,6 @@ class ImportPopulateZookeeper extends MasterRepo {
       Utils.checkTableDoesNotExist(instance, tableInfo.tableName, tableInfo.tableId, TableOperation.CREATE);
       
       TableManager.getInstance().addTable(tableInfo.tableId, tableInfo.tableName, NodeExistsPolicy.OVERWRITE);
-      
-      Tables.clearCache(instance);
     } finally {
       Utils.tableNameLock.unlock();
     }
@@ -453,10 +450,8 @@ class ImportPopulateZookeeper extends MasterRepo {
   
   @Override
   public void undo(long tid, Master env) throws Exception {
-    Instance instance = HdfsZooInstance.getInstance();
     TableManager.getInstance().removeTable(tableInfo.tableId);
     Utils.unreserveTable(tableInfo.tableId, tid, true);
-    Tables.clearCache(instance);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/master/tableOps/RenameTable.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/master/tableOps/RenameTable.java b/server/src/main/java/org/apache/accumulo/server/master/tableOps/RenameTable.java
index 22103e2..18c3a34 100644
--- a/server/src/main/java/org/apache/accumulo/server/master/tableOps/RenameTable.java
+++ b/server/src/main/java/org/apache/accumulo/server/master/tableOps/RenameTable.java
@@ -18,7 +18,6 @@ package org.apache.accumulo.server.master.tableOps;
 
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Instance;
-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.client.impl.thrift.ThriftTableOperationException;
@@ -71,7 +70,6 @@ public class RenameTable extends MasterRepo {
           return newTableName.getBytes();
         }
       });
-      Tables.clearCache(instance);
     } finally {
       Utils.tableNameLock.unlock();
       Utils.unreserveTable(tableId, tid, true);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java b/server/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java
index 03f2fb6..77b8c89 100644
--- a/server/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java
+++ b/server/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java
@@ -43,6 +43,7 @@ import org.apache.accumulo.core.util.MetadataTable;
 import org.apache.accumulo.core.util.RootTable;
 import org.apache.accumulo.server.client.HdfsZooInstance;
 import org.apache.accumulo.server.conf.ServerConfiguration;
+import org.apache.accumulo.server.curator.CuratorCaches;
 import org.apache.accumulo.server.master.Master;
 import org.apache.accumulo.server.security.handler.Authenticator;
 import org.apache.accumulo.server.security.handler.Authorizor;
@@ -50,7 +51,6 @@ import org.apache.accumulo.server.security.handler.PermissionHandler;
 import org.apache.accumulo.server.security.handler.ZKAuthenticator;
 import org.apache.accumulo.server.security.handler.ZKAuthorizor;
 import org.apache.accumulo.server.security.handler.ZKPermHandler;
-import org.apache.accumulo.server.zookeeper.ZooCache;
 import org.apache.hadoop.io.Text;
 import org.apache.log4j.Logger;
 
@@ -64,7 +64,7 @@ public class SecurityOperation {
   protected Authenticator authenticator;
   protected PermissionHandler permHandle;
   private static String rootUserName = null;
-  private final ZooCache zooCache;
+  private final CuratorCaches zooCache;
   private final String ZKUserPath;
   
   protected static SecurityOperation instance;
@@ -110,7 +110,7 @@ public class SecurityOperation {
   @Deprecated
   public SecurityOperation(String instanceId) {
     ZKUserPath = Constants.ZROOT + "/" + instanceId + "/users";
-    zooCache = new ZooCache();
+    zooCache = CuratorCaches.getInstance();
   }
   
   public SecurityOperation(Authorizor author, Authenticator authent, PermissionHandler pm, String instanceId) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a951e789/server/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java b/server/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java
index 74d6730..2920859 100644
--- a/server/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java
+++ b/server/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java
@@ -28,8 +28,8 @@ import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.security.thrift.TCredentials;
 import org.apache.accumulo.fate.curator.CuratorReaderWriter.NodeExistsPolicy;
+import org.apache.accumulo.server.curator.CuratorCaches;
 import org.apache.accumulo.server.curator.CuratorReaderWriter;
-import org.apache.accumulo.server.zookeeper.ZooCache;
 import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.KeeperException;
@@ -40,7 +40,7 @@ public final class ZKAuthenticator implements Authenticator {
   private static Authenticator zkAuthenticatorInstance = null;
   
   private String ZKUserPath;
-  private final ZooCache zooCache;
+  private final CuratorCaches zooCache;
   
   public static synchronized Authenticator getInstance() {
     if (zkAuthenticatorInstance == null)
@@ -49,7 +49,7 @@ public final class ZKAuthenticator implements Authenticator {
   }
   
   public ZKAuthenticator() {
-    zooCache = new ZooCache();
+    zooCache = CuratorCaches.getInstance();
   }
   
   public void initialize(String instanceId, boolean initialize) {
@@ -150,7 +150,6 @@ public final class ZKAuthenticator implements Authenticator {
     if (userExists(principal)) {
       try {
         synchronized (zooCache) {
-          zooCache.clear(ZKUserPath + "/" + principal);
           CuratorReaderWriter.getInstance().putPrivatePersistentData(ZKUserPath + "/" + principal, ZKSecurityTool.createPass(pt.getPassword()),
               NodeExistsPolicy.OVERWRITE);
         }


Mime
View raw message