accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [08/50] [abbrv] git commit: ACCUMULO-1418 use ZooReaderWriter, and not raw ZooKeeper
Date Wed, 31 Jul 2013 15:13:45 GMT
ACCUMULO-1418 use ZooReaderWriter, and not raw ZooKeeper

git-svn-id: https://svn.apache.org/repos/asf/accumulo/branches/1.4@1482989 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/3d886c25
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/3d886c25
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/3d886c25

Branch: refs/heads/master
Commit: 3d886c256e3ef4e299d792b10f099d43a496d55f
Parents: 854b91f
Author: Eric C. Newton <ecn@apache.org>
Authored: Wed May 15 18:27:12 2013 +0000
Committer: Eric C. Newton <ecn@apache.org>
Committed: Wed May 15 18:27:12 2013 +0000

----------------------------------------------------------------------
 .../accumulo/server/util/RestoreZookeeper.java  | 21 ++++++--------------
 1 file changed, 6 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/3d886c25/src/server/src/main/java/org/apache/accumulo/server/util/RestoreZookeeper.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/util/RestoreZookeeper.java
b/src/server/src/main/java/org/apache/accumulo/server/util/RestoreZookeeper.java
index 6b0c7dc..b5b330e 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/util/RestoreZookeeper.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/util/RestoreZookeeper.java
@@ -23,15 +23,13 @@ import java.util.Stack;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
-import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.core.zookeeper.ZooUtil.NodeExistsPolicy;
+import org.apache.accumulo.server.zookeeper.IZooReaderWriter;
+import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZooKeeper;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
@@ -39,11 +37,11 @@ import org.xml.sax.helpers.DefaultHandler;
 public class RestoreZookeeper {
   
   private static class Restore extends DefaultHandler {
-    ZooKeeper zk = null;
+    IZooReaderWriter zk = null;
     Stack<String> cwd = new Stack<String>();
     boolean overwrite = false;
     
-    Restore(ZooKeeper zk, boolean overwrite) {
+    Restore(IZooReaderWriter zk, boolean overwrite) {
       this.zk = zk;
       this.overwrite = overwrite;
     }
@@ -79,7 +77,7 @@ public class RestoreZookeeper {
         data = Base64.decodeBase64(value.getBytes());
       try {
         try {
-          ZooUtil.putPersistentData(zk, path, data, overwrite ? NodeExistsPolicy.OVERWRITE
: NodeExistsPolicy.FAIL);
+          zk.putPersistentData(path, data, overwrite ? NodeExistsPolicy.OVERWRITE : NodeExistsPolicy.FAIL);
         } catch (KeeperException e) {
           if (e.code().equals(KeeperException.Code.NODEEXISTS))
             throw new RuntimeException(path + " exists.  Remove it first.");
@@ -98,8 +96,6 @@ public class RestoreZookeeper {
   public static void main(String[] args) throws Exception {
     Logger.getRootLogger().setLevel(Level.WARN);
     
-    String server = args[0];
-    int timeout = 30 * 1000;
     InputStream in = System.in;
     boolean overwrite = false;
     if (args.length > 1) {
@@ -109,14 +105,9 @@ public class RestoreZookeeper {
       if (arg.equals("--overwrite"))
         overwrite = true;
     
-    ZooKeeper zk = new ZooKeeper(server, timeout, new Watcher() {
-      @Override
-      public void process(WatchedEvent event) {}
-    });
-    
     SAXParserFactory factory = SAXParserFactory.newInstance();
     SAXParser parser = factory.newSAXParser();
-    parser.parse(in, new Restore(zk, overwrite));
+    parser.parse(in, new Restore(ZooReaderWriter.getInstance(), overwrite));
     in.close();
   }
 }


Mime
View raw message