accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1359721 - in /accumulo/trunk: fate/src/main/java/org/apache/accumulo/fate/zookeeper/ server/src/main/java/org/apache/accumulo/server/master/state/ server/src/main/java/org/apache/accumulo/server/tabletserver/
Date Tue, 10 Jul 2012 15:16:13 GMT
Author: ecn
Date: Tue Jul 10 15:16:13 2012
New Revision: 1359721

URL: http://svn.apache.org/viewvc?rev=1359721&view=rev
Log:
ACCUMULO-681 sync after setting the future location, and check the future location when loading
the root tablet

Modified:
    accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/IZooReaderWriter.java
    accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReaderWriter.java
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java

Modified: accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/IZooReaderWriter.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/IZooReaderWriter.java?rev=1359721&r1=1359720&r2=1359721&view=diff
==============================================================================
--- accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/IZooReaderWriter.java
(original)
+++ accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/IZooReaderWriter.java
Tue Jul 10 15:16:13 2012
@@ -60,4 +60,6 @@ public interface IZooReaderWriter extend
   
   public abstract void mkdirs(String path) throws KeeperException, InterruptedException;
   
+  public abstract void sync(String path) throws KeeperException, InterruptedException;
+  
 }

Modified: accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReaderWriter.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReaderWriter.java?rev=1359721&r1=1359720&r2=1359721&view=diff
==============================================================================
--- accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReaderWriter.java
(original)
+++ accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReaderWriter.java
Tue Jul 10 15:16:13 2012
@@ -22,11 +22,13 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.security.SecurityPermission;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.accumulo.fate.util.UtilWaitThread;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
 import org.apache.log4j.Logger;
+import org.apache.zookeeper.AsyncCallback.VoidCallback;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.KeeperException.BadVersionException;
@@ -200,5 +202,22 @@ public class ZooReaderWriter extends Zoo
     mkdirs(parent);
     putPersistentData(path, new byte[] {}, NodeExistsPolicy.SKIP);
   }
+
+  @Override
+  public void sync(final String path) throws KeeperException, InterruptedException {
+    final AtomicBoolean waiter = new AtomicBoolean(false);
+    getZooKeeper().sync(path, new VoidCallback() {
+      @Override
+      public void processResult(int arg0, String arg1, Object arg2) {
+        synchronized (waiter) {
+          waiter.set(true);
+          waiter.notifyAll();
+        }
+      }}, null);
+    synchronized (waiter) {
+      if (!waiter.get())
+        waiter.wait();
+    }
+  }
   
 }

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java?rev=1359721&r1=1359720&r2=1359721&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java
(original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java
Tue Jul 10 15:16:13 2012
@@ -73,6 +73,7 @@ public class ZooStore implements Distrib
     try {
       path = relative(path);
       ZooReaderWriter.getInstance().putPersistentData(path, bs, NodeExistsPolicy.OVERWRITE);
+      ZooReaderWriter.getInstance().sync(path);
       cache.clear();
       log.debug("Wrote " + new String(bs) + " to " + path);
     } catch (Exception ex) {

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java?rev=1359721&r1=1359720&r2=1359721&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
(original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
Tue Jul 10 15:16:13 2012
@@ -151,6 +151,7 @@ import org.apache.accumulo.server.master
 import org.apache.accumulo.server.master.state.TServerInstance;
 import org.apache.accumulo.server.master.state.TabletLocationState;
 import org.apache.accumulo.server.master.state.TabletStateStore;
+import org.apache.accumulo.server.master.state.ZooTabletStateStore;
 import org.apache.accumulo.server.metrics.AbstractMetricsImpl;
 import org.apache.accumulo.server.problems.ProblemReport;
 import org.apache.accumulo.server.problems.ProblemReports;
@@ -210,6 +211,7 @@ import org.apache.thrift.TServiceClient;
 import org.apache.thrift.server.TServer;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.KeeperException.NoNodeException;
+import org.mortbay.log.Log;
 
 enum ScanRunState {
   QUEUED, RUNNING, FINISHED
@@ -2844,11 +2846,21 @@ public class TabletServer extends Abstra
   private long totalMinorCompactions;
   
   public static SortedMap<KeyExtent,Text> verifyTabletInformation(KeyExtent extent,
TServerInstance instance, SortedMap<Key,Value> tabletsKeyValues,
-      String clientAddress, ZooLock lock) throws AccumuloSecurityException {
+      String clientAddress, ZooLock lock) throws AccumuloSecurityException, DistributedStoreException
{
     for (int tries = 0; tries < 3; tries++) {
       try {
         log.debug("verifying extent " + extent);
         if (extent.isRootTablet()) {
+          ZooTabletStateStore store = new ZooTabletStateStore();
+          if (!store.iterator().hasNext()) {
+            log.warn("Illegal state: location is not set in zookeeper");
+            return null;
+          }
+          TabletLocationState next = store.iterator().next();
+          if (!instance.equals(next.future)) {
+            log.warn("Future location is not to this server for the root tablet");
+            return null;
+          }
           TreeMap<KeyExtent,Text> set = new TreeMap<KeyExtent,Text>();
           set.put(extent, new Text(Constants.ZROOT_TABLET));
           return set;



Mime
View raw message