You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by vi...@apache.org on 2013/06/21 00:56:44 UTC

svn commit: r1495223 - in /accumulo/branches/ACCUMULO-CURATOR: ./ assemble/ assemble/src/main/assemblies/ core/ core/src/main/java/org/apache/accumulo/core/client/ core/src/main/java/org/apache/accumulo/core/client/admin/ core/src/main/java/org/apache/...

Author: vines
Date: Thu Jun 20 22:56:43 2013
New Revision: 1495223

URL: http://svn.apache.org/r1495223
Log:
checkpointing before rejiggering watchers. This is a functionally broken commit


Modified:
    accumulo/branches/ACCUMULO-CURATOR/assemble/pom.xml
    accumulo/branches/ACCUMULO-CURATOR/assemble/src/main/assemblies/component.xml
    accumulo/branches/ACCUMULO-CURATOR/core/pom.xml
    accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
    accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java
    accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java
    accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
    accumulo/branches/ACCUMULO-CURATOR/fate/pom.xml
    accumulo/branches/ACCUMULO-CURATOR/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooCache.java
    accumulo/branches/ACCUMULO-CURATOR/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java
    accumulo/branches/ACCUMULO-CURATOR/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooUtil.java
    accumulo/branches/ACCUMULO-CURATOR/minicluster/pom.xml
    accumulo/branches/ACCUMULO-CURATOR/pom.xml
    accumulo/branches/ACCUMULO-CURATOR/proxy/pom.xml
    accumulo/branches/ACCUMULO-CURATOR/server/pom.xml
    accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
    accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
    accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
    accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
    accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/Master.java
    accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java
    accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/state/tables/TableManager.java
    accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java
    accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java
    accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java
    accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/handler/ZKPermHandler.java
    accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/util/ListInstances.java
    accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/util/MetadataTable.java
    accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/util/TabletServerLocks.java
    accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooCache.java
    accumulo/branches/ACCUMULO-CURATOR/test/pom.xml
    accumulo/branches/ACCUMULO-CURATOR/test/src/main/java/org/apache/accumulo/test/functional/CacheTestReader.java
    accumulo/branches/ACCUMULO-CURATOR/trace/pom.xml

Modified: accumulo/branches/ACCUMULO-CURATOR/assemble/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/assemble/pom.xml?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/assemble/pom.xml (original)
+++ accumulo/branches/ACCUMULO-CURATOR/assemble/pom.xml Thu Jun 20 22:56:43 2013
@@ -87,6 +87,10 @@
       <artifactId>commons-vfs2</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.curator</groupId>
+      <artifactId>curator-framework</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.thrift</groupId>
       <artifactId>libthrift</artifactId>
     </dependency>

Modified: accumulo/branches/ACCUMULO-CURATOR/assemble/src/main/assemblies/component.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/assemble/src/main/assemblies/component.xml?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/assemble/src/main/assemblies/component.xml (original)
+++ accumulo/branches/ACCUMULO-CURATOR/assemble/src/main/assemblies/component.xml Thu Jun 20 22:56:43 2013
@@ -39,6 +39,22 @@
       </excludes>
     </dependencySet>
     <dependencySet>
+      <outputDirectory>lib</outputDirectory>
+      <directoryMode>0755</directoryMode>
+      <fileMode>0644</fileMode>
+      <useProjectArtifact>true</useProjectArtifact>
+      <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+      <useTransitiveDependencies>true</useTransitiveDependencies>
+      <includes>
+        <include>org.apache.curator:curator-framework</include>
+        <include>org.apache.curator:curator-client</include>
+        <include>org.apache.curator:curator-recipes</include>
+      </includes>
+      <excludes>
+        <exclude>${groupId}:${artifactId}-docs</exclude>
+      </excludes>
+    </dependencySet>
+    <dependencySet>
       <outputDirectory>docs</outputDirectory>
       <directoryMode>0755</directoryMode>
       <fileMode>0644</fileMode>

Modified: accumulo/branches/ACCUMULO-CURATOR/core/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/core/pom.xml?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/core/pom.xml (original)
+++ accumulo/branches/ACCUMULO-CURATOR/core/pom.xml Thu Jun 20 22:56:43 2013
@@ -50,6 +50,10 @@
       <artifactId>commons-vfs2</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.curator</groupId>
+      <artifactId>curator-framework</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.thrift</groupId>
       <artifactId>libthrift</artifactId>
     </dependency>
@@ -99,11 +103,6 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
-      <groupId>org.apache.zookeeper</groupId>
-      <artifactId>zookeeper</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
       <scope>provided</scope>

Modified: accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java Thu Jun 20 22:56:43 2013
@@ -38,7 +38,9 @@ import org.apache.accumulo.core.util.Cac
 import org.apache.accumulo.core.util.OpTimer;
 import org.apache.accumulo.core.util.TextUtil;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
+import org.apache.accumulo.fate.curator.CuratorUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
+import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -140,7 +142,7 @@ public class ZooKeeperInstance implement
       // want the instance id to be stable for the life of this instance object,
       // so only get it once
       String instanceNamePath = Constants.ZROOT + Constants.ZINSTANCES + "/" + instanceName;
-      byte[] iidb = zooCache.get(instanceNamePath);
+      byte[] iidb = zooCache.get(instanceNamePath).getData();
       if (iidb == null) {
         throw new RuntimeException("Instance name " + instanceName
             + " does not exist in zookeeper.  Run \"accumulo org.apache.accumulo.server.util.ListInstances\" to see a list.");
@@ -177,14 +179,14 @@ public class ZooKeeperInstance implement
     String zRootLocPath = ZooUtil.getRoot(this) + Constants.ZROOT_TABLET_LOCATION;
     
     OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Looking up root tablet location in zookeeper.");
-    byte[] loc = zooCache.get(zRootLocPath);
-    opTimer.stop("Found root tablet at " + (loc == null ? null : new String(loc)) + " in %DURATION%");
+    ChildData loc = zooCache.get(zRootLocPath);
+    opTimer.stop("Found root tablet at " + (loc == null ? null : new String(loc.getData())) + " in %DURATION%");
     
     if (loc == null) {
       return null;
     }
     
-    return new String(loc).split("\\|")[0];
+    return new String(loc.getData()).split("\\|")[0];
   }
   
   @Override
@@ -248,14 +250,6 @@ public class ZooKeeperInstance implement
   }
   
   /**
-   * @deprecated Use {@link #lookupInstanceName(org.apache.accumulo.fate.zookeeper.ZooCache, UUID)} instead
-   */
-  @Deprecated
-  public static String lookupInstanceName(org.apache.accumulo.core.zookeeper.ZooCache zooCache, UUID instanceId) {
-    return lookupInstanceName((ZooCache) zooCache, instanceId);
-  }
-  
-  /**
    * Given a zooCache and instanceId, look up the instance name.
    * 
    * @param zooCache
@@ -264,11 +258,11 @@ public class ZooKeeperInstance implement
    */
   public static String lookupInstanceName(ZooCache zooCache, UUID instanceId) {
     ArgumentChecker.notNull(zooCache, instanceId);
-    for (String name : zooCache.getChildren(Constants.ZROOT + Constants.ZINSTANCES)) {
-      String instanceNamePath = Constants.ZROOT + Constants.ZINSTANCES + "/" + name;
-      UUID iid = UUID.fromString(new String(zooCache.get(instanceNamePath)));
+    String path = Constants.ZROOT + Constants.ZINSTANCES;
+    for (ChildData name : zooCache.getChildren(path)) {
+      UUID iid = UUID.fromString(new String(name.getData()));
       if (iid.equals(instanceId)) {
-        return name;
+        return CuratorUtil.getNodeName(name);
       }
     }
     return null;

Modified: accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java Thu Jun 20 22:56:43 2013
@@ -41,8 +41,10 @@ import org.apache.accumulo.core.util.Add
 import org.apache.accumulo.core.util.ArgumentChecker;
 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.fate.zookeeper.ZooCache;
 import org.apache.accumulo.trace.instrument.Tracer;
+import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.thrift.TException;
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
@@ -133,20 +135,19 @@ public class InstanceOperationsImpl impl
    * 
    * @see org.apache.accumulo.core.client.admin.InstanceOperations#getTabletServers()
    */
-  
   @Override
   public List<String> getTabletServers() {
     ZooCache cache = ZooCache.getInstance(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
     String path = ZooUtil.getRoot(instance) + Constants.ZTSERVERS;
     List<String> results = new ArrayList<String>();
-    for (String candidate : cache.getChildren(path)) {
-      List<String> children = cache.getChildren(path + "/" + candidate);
+    for (ChildData candidate : cache.getChildren(path)) {
+      List<ChildData> children = cache.getChildren(path + "/" + candidate);
       if (children != null && children.size() > 0) {
-        List<String> copy = new ArrayList<String>(children);
+        List<ChildData> copy = new ArrayList<ChildData>(children);
         Collections.sort(copy);
-        byte[] data = cache.get(path + "/" + candidate + "/" + copy.get(0));
+        byte[] data = copy.get(0).getData();
         if (data != null && !"master".equals(new String(data))) {
-          results.add(candidate);
+          results.add(CuratorUtil.getNodeName(candidate));
         }
       }
     }

Modified: accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java Thu Jun 20 22:56:43 2013
@@ -25,8 +25,8 @@ import org.apache.accumulo.core.client.A
 import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.impl.thrift.ClientService;
-import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
 import org.apache.accumulo.core.client.impl.thrift.ClientService.Client;
+import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.util.ArgumentChecker;
@@ -37,6 +37,7 @@ import org.apache.accumulo.core.util.Thr
 import org.apache.accumulo.core.util.UtilWaitThread;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
+import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.log4j.Logger;
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
@@ -48,7 +49,7 @@ public class ServerClient {
   private synchronized static ZooCache getZooCache(Instance instance) {
     ZooCache result = zooCaches.get(instance.getZooKeepers());
     if (result == null) {
-      result = new ZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut(), null);
+      result = new ZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
       zooCaches.put(instance.getZooKeepers(), result);
     }
     return result;
@@ -135,8 +136,8 @@ public class ServerClient {
     
     // add tservers
     ZooCache zc = getZooCache(instance);
-    for (String tserver : zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZTSERVERS)) {
-      String path = ZooUtil.getRoot(instance) + Constants.ZTSERVERS + "/" + tserver;
+    for (ChildData tserver : zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZTSERVERS)) {
+      String path = tserver.getPath();
       byte[] data = ZooUtil.getLockData(zc, path);
       if (data != null && !new String(data).equals("master"))
         servers.add(new ThriftTransportKey(

Modified: accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java Thu Jun 20 22:56:43 2013
@@ -27,7 +27,9 @@ import org.apache.accumulo.core.client.I
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.master.state.tables.TableState;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
+import org.apache.accumulo.fate.curator.CuratorUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
+import org.apache.curator.framework.recipes.cache.ChildData;
 
 public class Tables {
   private static SecurityPermission TABLES_PERMISSION = new SecurityPermission("tablesPermission");
@@ -43,17 +45,17 @@ public class Tables {
   private static SortedMap<String,String> getMap(Instance instance, boolean nameAsKey) {
     ZooCache zc = getZooCache(instance);
     
-    List<String> tableIds = zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZTABLES);
+    List<ChildData> tableIds = zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZTABLES);
     
     TreeMap<String,String> tableMap = new TreeMap<String,String>();
     
-    for (String tableId : tableIds) {
-      byte[] tblPath = zc.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_NAME);
-      if (tblPath != null) {
+    for (ChildData tableId : tableIds) {
+      ChildData namePath = zc.get(tableId.getPath() + Constants.ZTABLE_NAME);
+      if (namePath != null) {
         if (nameAsKey)
-          tableMap.put(new String(tblPath), tableId);
+          tableMap.put(new String(namePath.getData()), CuratorUtil.getNodeName(tableId));
         else
-          tableMap.put(tableId, new String(tblPath));
+          tableMap.put(CuratorUtil.getNodeName(tableId), new String(namePath.getData()));
       }
     }
     
@@ -84,8 +86,8 @@ public class Tables {
   
   public static boolean exists(Instance instance, String tableId) {
     ZooCache zc = getZooCache(instance);
-    List<String> tableIds = zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZTABLES);
-    return tableIds.contains(tableId);
+    ChildData table = zc.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + '/' + tableId);
+    return table != null;
   }
   
   public static void clearCache(Instance instance) {
@@ -107,7 +109,7 @@ public class Tables {
     try {
       tableName = getTableName(instance, tableId);
     } catch (TableNotFoundException e) {
-      //handled in the string formatting
+      // handled in the string formatting
     }
     return tableName == null ? String.format("?(ID:%s)", tableId) : String.format("%s(ID:%s)", tableName, tableId);
   }
@@ -117,7 +119,7 @@ public class Tables {
     try {
       tableId = getTableId(instance, tableName);
     } catch (TableNotFoundException e) {
-      //handled in the string formatting
+      // handled in the string formatting
     }
     return tableId == null ? String.format("%s(?)", tableName) : String.format("%s(ID:%s)", tableName, tableId);
   }
@@ -125,7 +127,7 @@ public class Tables {
   public static TableState getTableState(Instance instance, String tableId) {
     String statePath = ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_STATE;
     ZooCache zc = getZooCache(instance);
-    byte[] state = zc.get(statePath);
+    byte[] state = zc.get(statePath).getData();
     if (state == null)
       return TableState.UNKNOWN;
     

Modified: accumulo/branches/ACCUMULO-CURATOR/fate/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/fate/pom.xml?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/fate/pom.xml (original)
+++ accumulo/branches/ACCUMULO-CURATOR/fate/pom.xml Thu Jun 20 22:56:43 2013
@@ -1,20 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
--->
+<!-- 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. -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
@@ -26,6 +15,14 @@
   <name>Fate</name>
   <dependencies>
     <dependency>
+      <groupId>org.apache.curator</groupId>
+      <artifactId>curator-framework</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.curator</groupId>
+      <artifactId>curator-recipes</artifactId>
+    </dependency>
+    <dependency>
       <groupId>commons-lang</groupId>
       <artifactId>commons-lang</artifactId>
       <scope>provided</scope>
@@ -36,11 +33,6 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
-      <groupId>org.apache.zookeeper</groupId>
-      <artifactId>zookeeper</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>

Modified: accumulo/branches/ACCUMULO-CURATOR/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooCache.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooCache.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooCache.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooCache.java Thu Jun 20 22:56:43 2013
@@ -16,25 +16,21 @@
  */
 package org.apache.accumulo.fate.zookeeper;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
 import java.io.IOException;
-import java.util.Collections;
-import java.util.ConcurrentModificationException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.accumulo.fate.curator.CuratorUtil;
+import org.apache.curator.framework.CuratorFramework;
+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.log4j.Logger;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.KeeperException.Code;
-import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.data.Stat;
 
 /**
  * Caches values stored in zookeeper and keeps them up to date as they change in zookeeper.
@@ -43,256 +39,151 @@ import org.apache.zookeeper.data.Stat;
 public class ZooCache {
   private static final Logger log = Logger.getLogger(ZooCache.class);
   
-  private ZCacheWatcher watcher = new ZCacheWatcher();
-  private Watcher externalWatcher = null;
+  private HashMap<String,NodeCache> nodeCache;
+  private HashMap<String,PathChildrenCache> childrenCache;
   
-  private HashMap<String,byte[]> cache;
-  private HashMap<String,Stat> statCache;
-  private HashMap<String,List<String>> childrenCache;
-  
-  private ZooReader zReader;
-  
-  private ZooKeeper getZooKeeper() {
-    return zReader.getZooKeeper();
-  }
-  
-  private class ZCacheWatcher implements Watcher {
-    @Override
-    public void process(WatchedEvent event) {
-      
-      if (log.isTraceEnabled())
-        log.trace(event);
-      
-      switch (event.getType()) {
-        case NodeDataChanged:
-        case NodeChildrenChanged:
-        case NodeCreated:
-        case NodeDeleted:
-          remove(event.getPath());
-          break;
-        case None:
-          switch (event.getState()) {
-            case Disconnected:
-              if (log.isTraceEnabled())
-                log.trace("Zoo keeper connection disconnected, clearing cache");
-              clear();
-              break;
-            case SyncConnected:
-              break;
-            case Expired:
-              if (log.isTraceEnabled())
-                log.trace("Zoo keeper connection expired, clearing cache");
-              clear();
-              break;
-            default:
-              log.warn("Unhandled: " + event);
-          }
-          break;
-        default:
-          log.warn("Unhandled: " + event);
-      }
-      
-      if (externalWatcher != null) {
-        externalWatcher.process(event);
-      }
-    }
-  }
+  private CuratorFramework curator;
   
   public ZooCache(String zooKeepers, int sessionTimeout) {
     this(zooKeepers, sessionTimeout, null);
   }
   
   public ZooCache(String zooKeepers, int sessionTimeout, Watcher watcher) {
-    this(new ZooReader(zooKeepers, sessionTimeout), watcher);
-  }
-  
-  public ZooCache(ZooReader reader, Watcher watcher) {
-    this.zReader = reader;
-    this.cache = new HashMap<String,byte[]>();
-    this.statCache = new HashMap<String,Stat>();
-    this.childrenCache = new HashMap<String,List<String>>();
-    this.externalWatcher = watcher;
+    this(CuratorUtil.constructCurator(zooKeepers, sessionTimeout, null), watcher);
   }
   
-  private static interface ZooRunnable {
-    void run(ZooKeeper zooKeeper) throws KeeperException, InterruptedException;
+  public ZooCache(CuratorFramework curator, Watcher watcher) {
+    this.curator = curator;
+    this.nodeCache = new HashMap<String,NodeCache>();
+    this.childrenCache = new HashMap<String,PathChildrenCache>();
   }
   
-  private synchronized void retry(ZooRunnable op) {
-    
-    int sleepTime = 100;
-    
-    while (true) {
-      
-      ZooKeeper zooKeeper = getZooKeeper();
-      
+  public synchronized List<ChildData> getChildren(final String zPath) {
+    PathChildrenCache cache = childrenCache.get(zPath);
+    if (cache == null) {
+      cache = new PathChildrenCache(curator, zPath, true);
       try {
-        op.run(zooKeeper);
-        return;
+        cache.start(StartMode.BUILD_INITIAL_CACHE);
         
-      } catch (KeeperException e) {
-        if (e.code() == Code.NONODE) {
-          log.error("Looked up non existant node in cache " + e.getPath(), e);
+        // Because parent's children are being watched, we don't need a node watcher on the individual node
+        for (ChildData child : cache.getCurrentData()) {
+          NodeCache childCache = nodeCache.get(child.getPath());
+          if (childCache != null)
+          {
+            childCache.close();
+            nodeCache.remove(child.getPath());
+          }
         }
-        log.warn("Zookeeper error, will retry", e);
-      } catch (InterruptedException e) {
-        log.info("Zookeeper error, will retry", e);
-      } catch (ConcurrentModificationException e) {
-        log.debug("Zookeeper was modified, will retry");
-      }
-      
-      try {
-        // do not hold lock while sleeping
-        wait(sleepTime);
-      } catch (InterruptedException e) {
-        e.printStackTrace();
-      }
-      if (sleepTime < 10000)
-        sleepTime = (int) (sleepTime + sleepTime * Math.random());
-      
-    }
-  }
-  
-  public synchronized List<String> getChildren(final String zPath) {
-    
-    ZooRunnable zr = new ZooRunnable() {
-      
-      @Override
-      public void run(ZooKeeper zooKeeper) throws KeeperException, InterruptedException {
-        
-        if (childrenCache.containsKey(zPath))
-          return;
-        
+      } catch (Exception e) {
+        log.error(e, e);
         try {
-          List<String> children = zooKeeper.getChildren(zPath, watcher);
-          childrenCache.put(zPath, children);
-        } catch (KeeperException ke) {
-          if (ke.code() != Code.NONODE) {
-            throw ke;
-          }
+          cache.close();
+        } catch (IOException e1) {
+          // We're already in a bad state at this point, I think, but just in case
+          log.error(e, e);
         }
+        return null;
       }
-      
-    };
-    
-    retry(zr);
-    
-    List<String> children = childrenCache.get(zPath);
-    if (children == null) {
-      return null;
+      childrenCache.put(zPath, cache);
     }
-    return Collections.unmodifiableList(children);
+    return cache.getCurrentData();
   }
   
-  public synchronized byte[] get(final String zPath) {
-    return get(zPath, null);
+  public List<String> getChildKeys(final String zPath) {
+    List<String> toRet = new ArrayList<String>();
+    for (ChildData child : getChildren(zPath)) {
+      toRet.add(CuratorUtil.getNodeName(child));
+    }
+    return toRet;
   }
   
-  public synchronized byte[] get(final String zPath, Stat stat) {
-    ZooRunnable zr = new ZooRunnable() {
-      
-      @Override
-      public void run(ZooKeeper zooKeeper) throws KeeperException, InterruptedException {
-        
-        if (cache.containsKey(zPath))
-          return;
-        
-        /*
-         * The following call to exists() is important, since we are caching that a node does not exist. Once the node comes into existance, it will be added to
-         * the cache. But this notification of a node coming into existance will only be given if exists() was previously called.
-         * 
-         * If the call to exists() is bypassed and only getData() is called with a special case that looks for Code.NONODE in the KeeperException, then
-         * non-existance can not be cached.
-         */
-        
-        Stat stat = zooKeeper.exists(zPath, watcher);
-        
-        byte[] data = null;
-        
-        if (stat == null) {
-          if (log.isTraceEnabled())
-            log.trace("zookeeper did not contain " + zPath);
-        } else {
-          try {
-            data = zooKeeper.getData(zPath, watcher, stat);
-          } catch (KeeperException.BadVersionException e1) {
-            throw new ConcurrentModificationException();
-          } catch (KeeperException.NoNodeException e2) {
-            throw new ConcurrentModificationException();
-          }
-          if (log.isTraceEnabled())
-            log.trace("zookeeper contained " + zPath + " " + (data == null ? null : new String(data)));
-        }
-        if (log.isTraceEnabled())
-          log.trace("putting " + zPath + " " + (data == null ? null : new String(data)) + " in cache");
-        put(zPath, data, stat);
+  public synchronized ChildData get(final String zPath) {
+    NodeCache cache = nodeCache.get(zPath);
+    if (cache == null) {
+      PathChildrenCache cCache = childrenCache.get(CuratorUtil.getNodeParent(zPath));
+      if (cCache != null) {
+        return cCache.getCurrentData(zPath);
       }
-      
-    };
-    
-    retry(zr);
-    
-    if (stat != null) {
-      Stat cstat = statCache.get(zPath);
-      if (cstat != null) {
+      cache = new NodeCache(curator, zPath);
+      try {
+        cache.start(true);
+      } catch (Exception e) {
+        log.error(e, e);
         try {
-          ByteArrayOutputStream baos = new ByteArrayOutputStream();
-          DataOutputStream dos = new DataOutputStream(baos);
-          cstat.write(dos);
-          dos.close();
-          
-          ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-          DataInputStream dis = new DataInputStream(bais);
-          stat.readFields(dis);
-          
-          dis.close();
-        } catch (IOException e) {
-          throw new RuntimeException(e);
+          cache.close();
+        } catch (IOException e1) {
+          // We're already in a bad state at this point, I think, but just in case
+          log.error(e, e);
         }
+        return null;
       }
+      nodeCache.put(zPath, cache);
     }
     
-    return cache.get(zPath);
-  }
-  
-  private synchronized void put(String zPath, byte[] data, Stat stat) {
-    cache.put(zPath, data);
-    statCache.put(zPath, stat);
+    return cache.getCurrentData();
   }
   
   private synchronized void remove(String zPath) {
     if (log.isTraceEnabled())
       log.trace("removing " + zPath + " from cache");
-    cache.remove(zPath);
+    NodeCache nc = nodeCache.get(zPath);
+    if (nc != null) {
+      try {
+        nc.close();
+      } catch (IOException e) {
+        log.error(e, e);
+      }
+    }
+    
+    PathChildrenCache pc = childrenCache.get(zPath);
+    if (pc != null) {
+      try {
+        pc.close();
+      } catch (IOException e) {
+        log.error(e, e);
+      }
+    }
+    
+    nodeCache.remove(zPath);
     childrenCache.remove(zPath);
-    statCache.remove(zPath);
   }
   
   public synchronized void clear() {
-    cache.clear();
+    for (NodeCache nc : nodeCache.values()) {
+      try {
+        nc.close();
+      } catch (IOException e) {
+        log.error(e, e);
+      }
+    }
+    for (PathChildrenCache pc : childrenCache.values()) {
+      try {
+        pc.close();
+      } catch (IOException e) {
+        log.error(e, e);
+      }
+    }
+    
+    nodeCache.clear();
     childrenCache.clear();
-    statCache.clear();
   }
   
   public synchronized void clear(String zPath) {
-    
-    for (Iterator<String> i = cache.keySet().iterator(); i.hasNext();) {
+    List<String> pathsToRemove = new ArrayList<String>();
+    for (Iterator<String> i = nodeCache.keySet().iterator(); i.hasNext();) {
       String path = i.next();
       if (path.startsWith(zPath))
-        i.remove();
+        pathsToRemove.add(path);
     }
     
     for (Iterator<String> i = childrenCache.keySet().iterator(); i.hasNext();) {
       String path = i.next();
       if (path.startsWith(zPath))
-        i.remove();
+        pathsToRemove.add(path);
     }
     
-    for (Iterator<String> i = statCache.keySet().iterator(); i.hasNext();) {
-      String path = i.next();
-      if (path.startsWith(zPath))
-        i.remove();
-    }
+    for (String path : pathsToRemove)
+      remove(path);
   }
   
   private static Map<String,ZooCache> instances = new HashMap<String,ZooCache>();

Modified: accumulo/branches/ACCUMULO-CURATOR/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java Thu Jun 20 22:56:43 2013
@@ -20,8 +20,10 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.accumulo.fate.curator.CuratorUtil;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.LockID;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
+import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.WatchedEvent;
@@ -66,6 +68,10 @@ public class ZooLock implements Watcher 
   private boolean watchingParent = false;
   private String asyncLock;
   
+  public String toString() {
+    return path + ' ' + lock;
+  }
+  
   public ZooLock(String zookeepers, int timeInMillis, String scheme, byte[] auth, String path) {
     this(new ZooCache(zookeepers, timeInMillis), ZooReaderWriter.getInstance(zookeepers, timeInMillis, scheme, auth), path);
   }
@@ -380,21 +386,20 @@ public class ZooLock implements Watcher 
   
   public static boolean isLockHeld(ZooCache zc, LockID lid) {
     
-    List<String> children = zc.getChildren(lid.path);
+    List<ChildData> children = zc.getChildren(lid.path);
     
     if (children == null || children.size() == 0) {
       return false;
     }
     
-    children = new ArrayList<String>(children);
+    children = new ArrayList<ChildData>(children);
     Collections.sort(children);
     
-    String lockNode = children.get(0);
+    String lockNode = CuratorUtil.getNodeName(children.get(0));
     if (!lid.node.equals(lockNode))
       return false;
     
-    Stat stat = new Stat();
-    return zc.get(lid.path + "/" + lid.node, stat) != null && stat.getEphemeralOwner() == lid.eid;
+    return children.get(0).getStat().getEphemeralOwner() == lid.eid;
   }
   
   public static byte[] getLockData(ZooKeeper zk, String path) throws KeeperException, InterruptedException {
@@ -411,52 +416,43 @@ public class ZooLock implements Watcher 
     return zk.getData(path + "/" + lockNode, false, null);
   }
   
-  public static byte[] getLockData(org.apache.accumulo.fate.zookeeper.ZooCache zc, String path, Stat stat) {
+  public static ChildData getLockData(org.apache.accumulo.fate.zookeeper.ZooCache zc, String path) {
     
-    List<String> children = zc.getChildren(path);
+    List<ChildData> children = zc.getChildren(path);
     
     if (children == null || children.size() == 0) {
       return null;
     }
     
-    children = new ArrayList<String>(children);
+    children = new ArrayList<ChildData>(children);
     Collections.sort(children);
     
-    String lockNode = children.get(0);
+    String lockNode = CuratorUtil.getNodeName(children.get(0));
     
     if (!lockNode.startsWith(LOCK_PREFIX)) {
       throw new RuntimeException("Node " + lockNode + " at " + path + " is not a lock node");
     }
     
-    return zc.get(path + "/" + lockNode, stat);
+    return children.get(0);
   }
   
   private static ZooCache getLockDataZooCache;
   
-  public static byte[] getLockData(String path) {
-    return getLockData(path, null);
-  }
-  
-  public static byte[] getLockData(String path, Stat stat) {
-    return getLockData(getLockDataZooCache, path, stat);
+  public static ChildData getLockData(String path) {
+    return getLockData(getLockDataZooCache, path);
   }
   
   public static long getSessionId(ZooCache zc, String path) throws KeeperException, InterruptedException {
-    List<String> children = zc.getChildren(path);
+    List<ChildData> children = zc.getChildren(path);
     
     if (children == null || children.size() == 0) {
       return 0;
     }
     
-    children = new ArrayList<String>(children);
+    children = new ArrayList<ChildData>(children);
     Collections.sort(children);
     
-    String lockNode = children.get(0);
-    
-    Stat stat = new Stat();
-    if (zc.get(path + "/" + lockNode, stat) != null)
-      return stat.getEphemeralOwner();
-    return 0;
+    return children.get(0).getStat().getEphemeralOwner();
   }
   
   public long getSessionId() throws KeeperException, InterruptedException {

Modified: accumulo/branches/ACCUMULO-CURATOR/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooUtil.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooUtil.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooUtil.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooUtil.java Thu Jun 20 22:56:43 2013
@@ -22,6 +22,7 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.accumulo.fate.util.UtilWaitThread;
+import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.KeeperException.Code;
@@ -223,18 +224,16 @@ public class ZooUtil {
   
   public static byte[] getLockData(ZooCache zc, String path) {
     
-    List<String> children = zc.getChildren(path);
+    List<ChildData> children = zc.getChildren(path);
     
     if (children == null || children.size() == 0) {
       return null;
     }
     
-    children = new ArrayList<String>(children);
+    children = new ArrayList<ChildData>(children);
     Collections.sort(children);
     
-    String lockNode = children.get(0);
-    
-    return zc.get(path + "/" + lockNode);
+    return children.get(0).getData();
   }
   
   public static boolean isLockHeld(ZooKeeper zk, LockID lid) throws KeeperException, InterruptedException {

Modified: accumulo/branches/ACCUMULO-CURATOR/minicluster/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/minicluster/pom.xml?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
Binary files - no diff available.

Modified: accumulo/branches/ACCUMULO-CURATOR/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/pom.xml?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/pom.xml (original)
+++ accumulo/branches/ACCUMULO-CURATOR/pom.xml Thu Jun 20 22:56:43 2013
@@ -108,14 +108,14 @@
   <properties>
     <!-- used for filtering the java source with the current version -->
     <accumulo.release.version>${project.version}</accumulo.release.version>
+    <!-- ZooKeeper 3.4.x works also, but we're not using new features yet; this ensures 3.3.x compatibility. -->
+    <curator.version>2.0.1-incubating</curator.version>
     <!-- the maven-release-plugin makes this recommendation, due to plugin bugs -->
     <maven.min-version>3.0.4</maven.min-version>
     <powermock.version>1.5</powermock.version>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
     <sealJars>false</sealJars>
-    <!-- ZooKeeper 3.4.x works also, but we're not using new features yet; this ensures 3.3.x compatibility. -->
-    <zookeeper.version>3.3.6</zookeeper.version>
   </properties>
   <dependencyManagement>
     <dependencies>
@@ -277,6 +277,16 @@
         <version>2.0</version>
       </dependency>
       <dependency>
+        <groupId>org.apache.curator</groupId>
+        <artifactId>curator-framework</artifactId>
+        <version>${curator.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.curator</groupId>
+        <artifactId>curator-recipes</artifactId>
+        <version>${curator.version}</version>
+      </dependency>
+      <dependency>
         <groupId>org.apache.hadoop</groupId>
         <artifactId>hadoop-client</artifactId>
         <version>${hadoop.version}</version>
@@ -302,11 +312,6 @@
         <version>0.9.0</version>
       </dependency>
       <dependency>
-        <groupId>org.apache.zookeeper</groupId>
-        <artifactId>zookeeper</artifactId>
-        <version>${zookeeper.version}</version>
-      </dependency>
-      <dependency>
         <groupId>org.easymock</groupId>
         <artifactId>easymock</artifactId>
         <version>3.1</version>

Modified: accumulo/branches/ACCUMULO-CURATOR/proxy/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/proxy/pom.xml?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/proxy/pom.xml (original)
+++ accumulo/branches/ACCUMULO-CURATOR/proxy/pom.xml Thu Jun 20 22:56:43 2013
@@ -90,8 +90,8 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.apache.zookeeper</groupId>
-      <artifactId>zookeeper</artifactId>
+      <groupId>org.apache.curator</groupId>
+      <artifactId>curator-framework</artifactId>
       <scope>test</scope>
     </dependency>
   </dependencies>

Modified: accumulo/branches/ACCUMULO-CURATOR/server/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/pom.xml?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/pom.xml (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/pom.xml Thu Jun 20 22:56:43 2013
@@ -54,6 +54,10 @@
       <artifactId>accumulo-trace</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.curator</groupId>
+      <artifactId>curator-framework</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.thrift</groupId>
       <artifactId>libthrift</artifactId>
     </dependency>
@@ -98,11 +102,6 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
-      <groupId>org.apache.zookeeper</groupId>
-      <artifactId>zookeeper</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
       <groupId>org.mortbay.jetty</groupId>
       <artifactId>jetty</artifactId>
       <scope>provided</scope>

Modified: accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java Thu Jun 20 22:56:43 2013
@@ -43,6 +43,7 @@ import org.apache.accumulo.fate.zookeepe
 import org.apache.accumulo.server.ServerConstants;
 import org.apache.accumulo.server.conf.ServerConfiguration;
 import org.apache.accumulo.server.zookeeper.ZooLock;
+import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.hadoop.io.Text;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
@@ -84,15 +85,15 @@ public class HdfsZooInstance implements 
     
     OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Looking up root tablet location in zoocache.");
     
-    byte[] loc = zooCache.get(zRootLocPath);
+    ChildData loc = zooCache.get(zRootLocPath);
     
-    opTimer.stop("Found root tablet at " + (loc == null ? null : new String(loc)) + " in %DURATION%");
+    opTimer.stop("Found root tablet at " + (loc == null ? null : new String(loc.getData())) + " in %DURATION%");
     
     if (loc == null) {
       return null;
     }
     
-    return new String(loc).split("\\|")[0];
+    return new String(loc.getData()).split("\\|")[0];
   }
   
   @Override
@@ -102,7 +103,7 @@ public class HdfsZooInstance implements 
     
     OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Looking up master location in zoocache.");
     
-    byte[] loc = ZooLock.getLockData(zooCache, masterLocPath, null);
+    byte[] loc = ZooLock.getLockData(zooCache, masterLocPath).getData();
     
     opTimer.stop("Found master at " + (loc == null ? null : new String(loc)) + " in %DURATION%");
     

Modified: accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java Thu Jun 20 22:56:43 2013
@@ -31,8 +31,10 @@ import org.apache.accumulo.core.conf.Acc
 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.fate.zookeeper.ZooCache;
 import org.apache.accumulo.server.client.HdfsZooInstance;
+import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.log4j.Logger;
 
 public class TableConfiguration extends AccumuloConfiguration {
@@ -118,10 +120,10 @@ public class TableConfiguration extends 
   
   private String get(String key) {
     String zPath = ZooUtil.getRoot(instanceId) + Constants.ZTABLES + "/" + table + Constants.ZTABLE_CONF + "/" + key;
-    byte[] v = getTablePropCache().get(zPath);
+    ChildData v = getTablePropCache().get(zPath);
     String value = null;
     if (v != null)
-      value = new String(v);
+      value = new String(v.getData());
     return value;
   }
   
@@ -132,12 +134,11 @@ public class TableConfiguration extends 
     for (Entry<String,String> parentEntry : parent)
       entries.put(parentEntry.getKey(), parentEntry.getValue());
     
-    List<String> children = getTablePropCache().getChildren(ZooUtil.getRoot(instanceId) + Constants.ZTABLES + "/" + table + Constants.ZTABLE_CONF);
+    String path = ZooUtil.getRoot(instanceId) + Constants.ZTABLES + "/" + table + Constants.ZTABLE_CONF;
+    List<ChildData> children = getTablePropCache().getChildren(path);
     if (children != null) {
-      for (String child : children) {
-        String value = get(child);
-        if (child != null && value != null)
-          entries.put(child, value);
+      for (ChildData child : children) {
+        entries.put(CuratorUtil.getNodeName(child), new String(child.getData()));
       }
     }
     

Modified: accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java Thu Jun 20 22:56:43 2013
@@ -30,9 +30,11 @@ import org.apache.accumulo.core.client.Z
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 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.fate.zookeeper.ZooCache;
 import org.apache.accumulo.server.ServerConstants;
 import org.apache.accumulo.server.client.HdfsZooInstance.AccumuloNotInitializedException;
+import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.log4j.Logger;
 
 public class ZooConfiguration extends AccumuloConfiguration {
@@ -53,6 +55,8 @@ public class ZooConfiguration extends Ac
       propCache = new ZooCache(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut());
       instance = new ZooConfiguration(parent);
       instanceId = inst.getInstanceID();
+      // Sets up a child cache listener for all properties
+      propCache.getChildKeys(ZooUtil.getRoot(instanceId) + Constants.ZCONFIG);
     }
     return instance;
   }
@@ -64,6 +68,8 @@ public class ZooConfiguration extends Ac
       @SuppressWarnings("deprecation")
       String deprecatedInstanceIdFromHdfs = ZooKeeperInstance.getInstanceIDFromHdfs(ServerConstants.getInstanceIdLocation());
       instanceId = deprecatedInstanceIdFromHdfs;
+      // Sets up a child cache listener for all properties
+      propCache.getChildKeys(ZooUtil.getRoot(instanceId) + Constants.ZCONFIG);
     }
     return instance;
   }
@@ -113,10 +119,10 @@ public class ZooConfiguration extends Ac
   
   private String get(String key) {
     String zPath = ZooUtil.getRoot(instanceId) + Constants.ZCONFIG + "/" + key;
-    byte[] v = propCache.get(zPath);
+    ChildData v = propCache.get(zPath);
     String value = null;
     if (v != null)
-      value = new String(v);
+      value = new String(v.getData());
     return value;
   }
   
@@ -127,12 +133,13 @@ public class ZooConfiguration extends Ac
     for (Entry<String,String> parentEntry : parent)
       entries.put(parentEntry.getKey(), parentEntry.getValue());
     
-    List<String> children = propCache.getChildren(ZooUtil.getRoot(instanceId) + Constants.ZCONFIG);
+    List<ChildData> children = propCache.getChildren(ZooUtil.getRoot(instanceId) + Constants.ZCONFIG);
     if (children != null) {
-      for (String child : children) {
-        String value = get(child);
-        if (child != null && value != null)
-          entries.put(child, value);
+      for (ChildData child : children) {
+        String node = CuratorUtil.getNodeName(child);
+        String value = get(node);
+        if (node != null && value != null)
+          entries.put(node, value);
       }
     }
     

Modified: accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java Thu Jun 20 22:56:43 2013
@@ -45,6 +45,7 @@ import org.apache.accumulo.server.zookee
 import org.apache.accumulo.server.zookeeper.ZooLock;
 import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
 import org.apache.accumulo.trace.instrument.Tracer;
+import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.hadoop.io.Text;
 import org.apache.log4j.Logger;
 import org.apache.thrift.TException;
@@ -54,7 +55,6 @@ import org.apache.zookeeper.KeeperExcept
 import org.apache.zookeeper.KeeperException.NotEmptyException;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.data.Stat;
 
 public class LiveTServerSet implements Watcher {
   
@@ -236,7 +236,7 @@ public class LiveTServerSet implements W
       final String path = ZooUtil.getRoot(instance) + Constants.ZTSERVERS;
       
       HashSet<String> all = new HashSet<String>(current.keySet());
-      all.addAll(getZooCache().getChildren(path));
+      all.addAll(getZooCache().getChildKeys(path));
       
       locklessServers.keySet().retainAll(all);
       
@@ -268,8 +268,7 @@ public class LiveTServerSet implements W
     TServerInfo info = current.get(server);
     
     final String lockPath = path + "/" + server;
-    Stat stat = new Stat();
-    byte[] lockData = ZooLock.getLockData(getZooCache(), lockPath, stat);
+    ChildData lockData = ZooLock.getLockData(getZooCache(), lockPath);
     
     if (lockData == null) {
       if (info != null) {
@@ -286,10 +285,10 @@ public class LiveTServerSet implements W
       }
     } else {
       locklessServers.remove(server);
-      ServerServices services = new ServerServices(new String(lockData));
+      ServerServices services = new ServerServices(new String(lockData.getData()));
       InetSocketAddress client = services.getAddress(ServerServices.Service.TSERV_CLIENT);
       InetSocketAddress addr = AddressUtil.parseAddress(server);
-      TServerInstance instance = new TServerInstance(client, stat.getEphemeralOwner());
+      TServerInstance instance = new TServerInstance(client, lockData.getStat().getEphemeralOwner());
       
       if (info == null) {
         updates.add(instance);

Modified: accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/Master.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/Master.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/Master.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/Master.java Thu Jun 20 22:56:43 2013
@@ -1302,8 +1302,7 @@ public class Master implements LiveTServ
           
           int[] counts = new int[TabletState.values().length];
           stats.begin();
-          // Walk through the tablets in our store, and work tablets
-          // towards their goal
+          // Walk through the tablets in our store, and work tablets towards their goal
           for (TabletLocationState tls : store) {
             if (tls == null) {
               continue;
@@ -2099,11 +2098,9 @@ public class Master implements LiveTServ
     });
     
     TCredentials systemAuths = SecurityConstants.getSystemCredentials();
-    final TabletStateStore stores[] = {new ZooTabletStateStore(new ZooStore(zroot)), new RootTabletStateStore(instance, systemAuths, this),
-        new MetaDataStateStore(instance, systemAuths, this)};
-    watchers.add(new TabletGroupWatcher(stores[2], null));
-    watchers.add(new TabletGroupWatcher(stores[1], watchers.get(0)));
-    watchers.add(new TabletGroupWatcher(stores[0], watchers.get(1)));
+    watchers.add(new TabletGroupWatcher(new MetaDataStateStore(instance, systemAuths, this), null));
+    watchers.add(new TabletGroupWatcher(new RootTabletStateStore(instance, systemAuths, this), watchers.get(0)));
+    watchers.add(new TabletGroupWatcher(new ZooTabletStateStore(new ZooStore(zroot)), watchers.get(1)));
     for (TabletGroupWatcher watcher : watchers) {
       watcher.start();
     }
@@ -2122,8 +2119,7 @@ public class Master implements LiveTServ
     final long deadline = System.currentTimeMillis() + MAX_CLEANUP_WAIT_TIME;
     statusThread.join(remaining(deadline));
     
-    // quit, even if the tablet servers somehow jam up and the watchers
-    // don't stop
+    // quit, even if the tablet servers somehow jam up and the watchers don't stop
     for (TabletGroupWatcher watcher : watchers) {
       watcher.join(remaining(deadline));
     }

Modified: accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java Thu Jun 20 22:56:43 2013
@@ -26,6 +26,7 @@ import org.apache.accumulo.fate.zookeepe
 import org.apache.accumulo.server.client.HdfsZooInstance;
 import org.apache.accumulo.server.zookeeper.ZooCache;
 import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
+import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.log4j.Logger;
 
 public class ZooStore implements DistributedStore {
@@ -49,7 +50,10 @@ public class ZooStore implements Distrib
   @Override
   public byte[] get(String path) throws DistributedStoreException {
     try {
-      return cache.get(relative(path));
+      ChildData cd = cache.get(relative(path));
+      if (cd != null)
+        return cd.getData();
+      return null;
     } catch (Exception ex) {
       throw new DistributedStoreException(ex);
     }
@@ -62,7 +66,7 @@ public class ZooStore implements Distrib
   @Override
   public List<String> getChildren(String path) throws DistributedStoreException {
     try {
-      return cache.getChildren(relative(path));
+      return cache.getChildKeys(relative(path));
     } catch (Exception ex) {
       throw new DistributedStoreException(ex);
     }

Modified: accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/state/tables/TableManager.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/state/tables/TableManager.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/state/tables/TableManager.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/master/state/tables/TableManager.java Thu Jun 20 22:56:43 2013
@@ -28,6 +28,7 @@ import org.apache.accumulo.core.Constant
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.master.state.tables.TableState;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
+import org.apache.accumulo.fate.curator.CuratorUtil;
 import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
 import org.apache.accumulo.fate.zookeeper.ZooReaderWriter.Mutator;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
@@ -36,6 +37,7 @@ import org.apache.accumulo.server.client
 import org.apache.accumulo.server.util.TablePropUtil;
 import org.apache.accumulo.server.zookeeper.ZooCache;
 import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
+import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.WatchedEvent;
@@ -151,20 +153,21 @@ public class TableManager {
   
   private void updateTableStateCache() {
     synchronized (tableStateCache) {
-      for (String tableId : zooStateCache.getChildren(ZooUtil.getRoot(instance) + Constants.ZTABLES))
-        if (zooStateCache.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_STATE) != null)
-          updateTableStateCache(tableId);
+      for (ChildData tableId : zooStateCache.getChildren(ZooUtil.getRoot(instance) + Constants.ZTABLES))
+        if (zooStateCache.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + CuratorUtil.getNodeName(tableId) + Constants.ZTABLE_STATE) != null)
+          updateTableStateCache(CuratorUtil.getNodeName(tableId));
     }
   }
   
   public TableState updateTableStateCache(String tableId) {
     synchronized (tableStateCache) {
       TableState tState = TableState.UNKNOWN;
-      byte[] data = zooStateCache.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_STATE);
+      byte[] data = zooStateCache.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_STATE).getData();
       if (data != null) {
         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);
         }

Modified: accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java Thu Jun 20 22:56:43 2013
@@ -141,7 +141,7 @@ public class SecurityOperation {
   
   public synchronized String getRootUsername() {
     if (rootUserName == null)
-      rootUserName = new String(zooCache.get(ZKUserPath));
+      rootUserName = new String(zooCache.get(ZKUserPath).getData());
     return rootUserName;
   }
   

Modified: accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java Thu Jun 20 22:56:43 2013
@@ -99,7 +99,7 @@ public final class ZKAuthenticator imple
   
   @Override
   public Set<String> listUsers() {
-    return new TreeSet<String>(zooCache.getChildren(ZKUserPath));
+    return new TreeSet<String>(zooCache.getChildKeys(ZKUserPath));
   }
   
   /**
@@ -189,13 +189,8 @@ public final class ZKAuthenticator imple
     PasswordToken pt = (PasswordToken) token;
     byte[] pass;
     String zpath = ZKUserPath + "/" + principal;
-    pass = zooCache.get(zpath);
+    pass = zooCache.get(zpath).getData();
     boolean result = ZKSecurityTool.checkPass(pt.getPassword(), pass);
-    if (!result) {
-      zooCache.clear(zpath);
-      pass = zooCache.get(zpath);
-      result = ZKSecurityTool.checkPass(pt.getPassword(), pass);
-    }
     return result;
   }
   

Modified: accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java Thu Jun 20 22:56:43 2013
@@ -61,7 +61,7 @@ public class ZKAuthorizor implements Aut
   }
   
   public Authorizations getCachedUserAuthorizations(String user) {
-    byte[] authsBytes = zooCache.get(ZKUserPath + "/" + user + ZKUserAuths);
+    byte[] authsBytes = zooCache.get(ZKUserPath + "/" + user + ZKUserAuths).getData();
     if (authsBytes != null)
       return ZKSecurityTool.convertAuthorizations(authsBytes);
     return Constants.NO_AUTHS;

Modified: accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/handler/ZKPermHandler.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/handler/ZKPermHandler.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/handler/ZKPermHandler.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/security/handler/ZKPermHandler.java Thu Jun 20 22:56:43 2013
@@ -35,6 +35,7 @@ import org.apache.accumulo.fate.zookeepe
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
 import org.apache.accumulo.server.zookeeper.ZooCache;
 import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
+import org.apache.curator.framework.recipes.cache.ChildData;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.KeeperException.Code;
@@ -108,9 +109,9 @@ public class ZKPermHandler implements Pe
   
   @Override
   public boolean hasCachedTablePermission(String user, String table, TablePermission permission) throws AccumuloSecurityException, TableNotFoundException {
-    byte[] serializedPerms = zooCache.get(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table);
+    ChildData serializedPerms = zooCache.get(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table);
     if (serializedPerms != null) {
-      return ZKSecurityTool.convertTablePermissions(serializedPerms).contains(permission);
+      return ZKSecurityTool.convertTablePermissions(serializedPerms.getData()).contains(permission);
     }
     return false;
   }
@@ -118,12 +119,12 @@ public class ZKPermHandler implements Pe
   @Override
   public void grantSystemPermission(String user, SystemPermission permission) throws AccumuloSecurityException {
     try {
-      byte[] permBytes = zooCache.get(ZKUserPath + "/" + user + ZKUserSysPerms);
+      ChildData permBytes = zooCache.get(ZKUserPath + "/" + user + ZKUserSysPerms);
       Set<SystemPermission> perms;
       if (permBytes == null) {
         perms = new TreeSet<SystemPermission>();
       } else {
-        perms = ZKSecurityTool.convertSystemPermissions(permBytes);
+        perms = ZKSecurityTool.convertSystemPermissions(permBytes.getData());
       }
       
       if (perms.add(permission)) {
@@ -145,9 +146,9 @@ public class ZKPermHandler implements Pe
   @Override
   public void grantTablePermission(String user, String table, TablePermission permission) throws AccumuloSecurityException {
     Set<TablePermission> tablePerms;
-    byte[] serializedPerms = zooCache.get(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table);
+    ChildData serializedPerms = zooCache.get(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table);
     if (serializedPerms != null)
-      tablePerms = ZKSecurityTool.convertTablePermissions(serializedPerms);
+      tablePerms = ZKSecurityTool.convertTablePermissions(serializedPerms.getData());
     else
       tablePerms = new TreeSet<TablePermission>();
     
@@ -171,13 +172,13 @@ public class ZKPermHandler implements Pe
   
   @Override
   public void revokeSystemPermission(String user, SystemPermission permission) throws AccumuloSecurityException {
-    byte[] sysPermBytes = zooCache.get(ZKUserPath + "/" + user + ZKUserSysPerms);
+    ChildData sysPermBytes = zooCache.get(ZKUserPath + "/" + user + ZKUserSysPerms);
     
     // User had no system permission, nothing to revoke.
     if (sysPermBytes == null)
       return;
     
-    Set<SystemPermission> sysPerms = ZKSecurityTool.convertSystemPermissions(sysPermBytes);
+    Set<SystemPermission> sysPerms = ZKSecurityTool.convertSystemPermissions(sysPermBytes.getData());
     
     try {
       if (sysPerms.remove(permission)) {
@@ -198,13 +199,13 @@ public class ZKPermHandler implements Pe
   
   @Override
   public void revokeTablePermission(String user, String table, TablePermission permission) throws AccumuloSecurityException {
-    byte[] serializedPerms = zooCache.get(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table);
+    ChildData serializedPerms = zooCache.get(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table);
     
     // User had no table permission, nothing to revoke.
     if (serializedPerms == null)
       return;
     
-    Set<TablePermission> tablePerms = ZKSecurityTool.convertTablePermissions(serializedPerms);
+    Set<TablePermission> tablePerms = ZKSecurityTool.convertTablePermissions(serializedPerms.getData());
     try {
       if (tablePerms.remove(permission)) {
         zooCache.clear();
@@ -230,7 +231,7 @@ public class ZKPermHandler implements Pe
       synchronized (zooCache) {
         zooCache.clear();
         IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
-        for (String user : zooCache.getChildren(ZKUserPath))
+        for (String user : zooCache.getChildKeys(ZKUserPath))
           zoo.recursiveDelete(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table, NodeMissingPolicy.SKIP);
       }
     } catch (KeeperException e) {
@@ -347,10 +348,10 @@ public class ZKPermHandler implements Pe
   
   @Override
   public boolean hasCachedSystemPermission(String user, SystemPermission permission) throws AccumuloSecurityException {
-    byte[] perms = zooCache.get(ZKUserPath + "/" + user + ZKUserSysPerms);
+    ChildData perms = zooCache.get(ZKUserPath + "/" + user + ZKUserSysPerms);
     if (perms == null)
       return false;
-    return ZKSecurityTool.convertSystemPermissions(perms).contains(permission);
+    return ZKSecurityTool.convertSystemPermissions(perms.getData()).contains(permission);
   }
   
   @Override

Modified: accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/util/ListInstances.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/util/ListInstances.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/util/ListInstances.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/util/ListInstances.java Thu Jun 20 22:56:43 2013
@@ -140,7 +140,7 @@ public class ListInstances {
     try {
       String masterLocPath = Constants.ZROOT + "/" + iid + Constants.ZMASTER_LOCK;
       
-      byte[] master = ZooLock.getLockData(masterLocPath);
+      byte[] master = ZooLock.getLockData(masterLocPath).getData();
       if (master == null) {
         return null;
       }

Modified: accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/util/MetadataTable.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/util/MetadataTable.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/util/MetadataTable.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/util/MetadataTable.java Thu Jun 20 22:56:43 2013
@@ -92,9 +92,7 @@ public class MetadataTable extends org.a
   private static final Text EMPTY_TEXT = new Text();
   private static Map<TCredentials,Writer> metadata_tables = new HashMap<TCredentials,Writer>();
   private static final Logger log = Logger.getLogger(MetadataTable.class);
-  
-  private static final int SAVE_ROOT_TABLET_RETRIES = 3;
-  
+    
   private MetadataTable() {
     
   }
@@ -319,22 +317,6 @@ public class MetadataTable extends org.a
     return results;
   }
   
-  public static boolean recordRootTabletLocation(String address) {
-    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
-    for (int i = 0; i < SAVE_ROOT_TABLET_RETRIES; i++) {
-      try {
-        log.info("trying to write root tablet location to ZooKeeper as " + address);
-        String zRootLocPath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZROOT_TABLET_LOCATION;
-        zoo.putPersistentData(zRootLocPath, address.getBytes(), NodeExistsPolicy.OVERWRITE);
-        return true;
-      } catch (Exception e) {
-        log.error("Master: unable to save root tablet location in zookeeper. exception: " + e, e);
-      }
-    }
-    log.error("Giving up after " + SAVE_ROOT_TABLET_RETRIES + " retries");
-    return false;
-  }
-  
   public static SortedMap<String,DataFileValue> getDataFileSizes(KeyExtent extent, TCredentials credentials) {
     TreeMap<String,DataFileValue> sizes = new TreeMap<String,DataFileValue>();
     

Modified: accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/util/TabletServerLocks.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/util/TabletServerLocks.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/util/TabletServerLocks.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/util/TabletServerLocks.java Thu Jun 20 22:56:43 2013
@@ -51,7 +51,7 @@ public class TabletServerLocks {
       List<String> tabletServers = zoo.getChildren(tserverPath);
       
       for (String tabletServer : tabletServers) {
-        byte[] lockData = ZooLock.getLockData(tserverPath + "/" + tabletServer);
+        byte[] lockData = ZooLock.getLockData(tserverPath + "/" + tabletServer).getData();
         String holder = null;
         if (lockData != null) {
           holder = new String(lockData);

Modified: accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooCache.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooCache.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooCache.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooCache.java Thu Jun 20 22:56:43 2013
@@ -18,18 +18,14 @@ package org.apache.accumulo.server.zooke
 
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;
-import org.apache.zookeeper.Watcher;
+import org.apache.accumulo.server.curator.CuratorUtil;
 
 public class ZooCache extends org.apache.accumulo.fate.zookeeper.ZooCache {
   public ZooCache() {
-    this(null);
+    super(CuratorUtil.getInstance());
   }
   
-  public ZooCache(Watcher watcher) {
-    super(ZooReaderWriter.getInstance(), watcher);
-  }
-  
-  public ZooCache(AccumuloConfiguration conf, Watcher watcher) {
-    super(conf.get(Property.INSTANCE_ZK_HOST), (int) conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT), watcher);
+  public ZooCache(AccumuloConfiguration conf) {
+    super(conf.get(Property.INSTANCE_ZK_HOST), (int) conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT));
   }
 }

Modified: accumulo/branches/ACCUMULO-CURATOR/test/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/test/pom.xml?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/test/pom.xml (original)
+++ accumulo/branches/ACCUMULO-CURATOR/test/pom.xml Thu Jun 20 22:56:43 2013
@@ -58,6 +58,10 @@
       <artifactId>accumulo-trace</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.curator</groupId>
+      <artifactId>curator-framework</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.thrift</groupId>
       <artifactId>libthrift</artifactId>
     </dependency>
@@ -92,11 +96,6 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
-      <groupId>org.apache.zookeeper</groupId>
-      <artifactId>zookeeper</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
       <scope>provided</scope>

Modified: accumulo/branches/ACCUMULO-CURATOR/test/src/main/java/org/apache/accumulo/test/functional/CacheTestReader.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/test/src/main/java/org/apache/accumulo/test/functional/CacheTestReader.java?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/test/src/main/java/org/apache/accumulo/test/functional/CacheTestReader.java (original)
+++ accumulo/branches/ACCUMULO-CURATOR/test/src/main/java/org/apache/accumulo/test/functional/CacheTestReader.java Thu Jun 20 22:56:43 2013
@@ -50,16 +50,16 @@ public class CacheTestReader {
       Map<String,String> readData = new TreeMap<String,String>();
       
       for (int i = 0; i < numData; i++) {
-        byte[] v = zc.get(rootDir + "/data" + i);
+        byte[] v = zc.get(rootDir + "/data" + i).getData();
         if (v != null)
           readData.put(rootDir + "/data" + i, new String(v));
       }
       
-      byte[] v = zc.get(rootDir + "/dataS");
+      byte[] v = zc.get(rootDir + "/dataS").getData();
       if (v != null)
         readData.put(rootDir + "/dataS", new String(v));
       
-      List<String> children = zc.getChildren(rootDir + "/dir");
+      List<String> children = zc.getChildKeys(rootDir + "/dir");
       if (children != null)
         for (String child : children) {
           readData.put(rootDir + "/dir/" + child, "");

Modified: accumulo/branches/ACCUMULO-CURATOR/trace/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-CURATOR/trace/pom.xml?rev=1495223&r1=1495222&r2=1495223&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-CURATOR/trace/pom.xml (original)
+++ accumulo/branches/ACCUMULO-CURATOR/trace/pom.xml Thu Jun 20 22:56:43 2013
@@ -26,6 +26,10 @@
   <name>Trace</name>
   <dependencies>
     <dependency>
+      <groupId>org.apache.curator</groupId>
+      <artifactId>curator-framework</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.thrift</groupId>
       <artifactId>libthrift</artifactId>
     </dependency>
@@ -35,11 +39,6 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
-      <groupId>org.apache.zookeeper</groupId>
-      <artifactId>zookeeper</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
       <scope>provided</scope>