accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1424050 - /accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReader.java
Date Wed, 19 Dec 2012 19:30:08 GMT
Author: ecn
Date: Wed Dec 19 19:30:08 2012
New Revision: 1424050

URL: http://svn.apache.org/viewvc?rev=1424050&view=rev
Log:
ACCUMULO-408 use sync to make sure we do not read old data from zookeeper

Modified:
    accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReader.java

Modified: accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReader.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReader.java?rev=1424050&r1=1424049&r2=1424050&view=diff
==============================================================================
--- accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReader.java (original)
+++ accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReader.java Wed
Dec 19 19:30:08 2012
@@ -23,6 +23,7 @@ import org.apache.zookeeper.KeeperExcept
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.AsyncCallback.VoidCallback;
+import org.apache.zookeeper.KeeperException.Code;
 import org.apache.zookeeper.data.Stat;
 
 public class ZooReader implements IZooReader {
@@ -75,10 +76,12 @@ public class ZooReader implements IZooRe
   
   @Override
   public void sync(final String path) throws KeeperException, InterruptedException {
+    final int[] rc = { 0 };
     final AtomicBoolean waiter = new AtomicBoolean(false);
     getZooKeeper().sync(path, new VoidCallback() {
       @Override
-      public void processResult(int arg0, String arg1, Object arg2) {
+      public void processResult(int code, String arg1, Object arg2) {
+        rc[0] = code;
         synchronized (waiter) {
           waiter.set(true);
           waiter.notifyAll();
@@ -88,6 +91,10 @@ public class ZooReader implements IZooRe
       while (!waiter.get())
         waiter.wait();
     }
+    Code code = Code.get(rc[0]);
+    if (code != KeeperException.Code.OK) {
+      throw KeeperException.create(code);
+    }
   }
   
   



Mime
View raw message