accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1359620 - in /accumulo/trunk: server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/ test/system/randomwalk/conf/modules/
Date Tue, 10 Jul 2012 11:52:44 GMT
Author: ecn
Date: Tue Jul 10 11:52:43 2012
New Revision: 1359620

URL: http://svn.apache.org/viewvc?rev=1359620&view=rev
Log:
ACCUMULO-678 add administrative shutdown to randomwalk tests

Modified:
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/StartAll.java
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/StopTabletServer.java
    accumulo/trunk/test/system/randomwalk/conf/modules/Concurrent.xml

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/StartAll.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/StartAll.java?rev=1359620&r1=1359619&r2=1359620&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/StartAll.java
(original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/StartAll.java
Tue Jul 10 11:52:43 2012
@@ -10,7 +10,8 @@ public class StartAll extends Test {
   @Override
   public void visit(State state, Properties props) throws Exception {
     log.info("Starting all servers");
-    Runtime.getRuntime().exec(new String[]{System.getenv().get("ACCUMULO_HOME") + "/bin/start-all.sh"});
+    Process exec = Runtime.getRuntime().exec(new String[]{System.getenv().get("ACCUMULO_HOME")
+ "/bin/start-all.sh"});
+    exec.waitFor();
   }
   
 }

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/StopTabletServer.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/StopTabletServer.java?rev=1359620&r1=1359619&r2=1359620&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/StopTabletServer.java
(original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/test/randomwalk/concurrent/StopTabletServer.java
Tue Jul 10 11:52:43 2012
@@ -2,36 +2,59 @@ package org.apache.accumulo.server.test.
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 
-import org.apache.accumulo.core.conf.DefaultConfiguration;
-import org.apache.accumulo.server.master.LiveTServerSet;
-import org.apache.accumulo.server.master.LiveTServerSet.Listener;
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.Instance;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.zookeeper.ZooUtil;
+import org.apache.accumulo.fate.zookeeper.ZooReader;
 import org.apache.accumulo.server.master.state.TServerInstance;
 import org.apache.accumulo.server.test.randomwalk.State;
 import org.apache.accumulo.server.test.randomwalk.Test;
+import org.apache.accumulo.server.util.AddressUtil;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.data.Stat;
 
 public class StopTabletServer extends Test {
   
+  Set<TServerInstance> getTServers(Instance instance) throws KeeperException, InterruptedException
{
+    Set<TServerInstance> result = new HashSet<TServerInstance>();
+    ZooReader rdr = new ZooReader(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
+    String base = ZooUtil.getRoot(instance) + Constants.ZTSERVERS;
+    for (String child : rdr.getChildren(base)) {
+      List<String> children = rdr.getChildren(base + "/" + child);
+      if (children.size() > 0) {
+        Collections.sort(children);
+        Stat stat = new Stat();
+        byte[] data = rdr.getData(base + "/" + child + "/" + children.get(0), stat);
+        if (!"master".equals(new String(data))) {
+          result.add(new TServerInstance(AddressUtil.parseAddress(child, Property.TSERV_CLIENTPORT),
stat.getEphemeralOwner()));
+        }
+      }
+    }
+    return result;
+  }
+  
   @Override
   public void visit(State state, Properties props) throws Exception {
     
-    LiveTServerSet set = new LiveTServerSet(state.getInstance(), DefaultConfiguration.getDefaultConfiguration(),
new Listener() {
-      @Override
-      public void update(LiveTServerSet current, Set<TServerInstance> deleted, Set<TServerInstance>
added) {
-        log.info("Tablet server set changed: " + deleted + " deleted and " + added + " added");
-      }
-    });
-    List<TServerInstance> currentServers = new ArrayList<TServerInstance>(set.getCurrentServers());
+    Instance instance = state.getInstance();
+    
+    List<TServerInstance> currentServers = new ArrayList<TServerInstance>(getTServers(instance));
     Collections.shuffle(currentServers);
     Runtime runtime = Runtime.getRuntime();
     if (currentServers.size() > 1) {
       TServerInstance victim = currentServers.get(0);
       log.info("Stopping " + victim.hostPort());
-      runtime.exec(new String[] {System.getenv("ACCUMULO_HOME") + "/bin/accumulo", "admin",
"stop", victim.hostPort()});
-      if (set.getCurrentServers().contains(victim))
+      Process exec = runtime.exec(new String[] {System.getenv("ACCUMULO_HOME") + "/bin/accumulo",
"admin", "stop", victim.hostPort()});
+      if (exec.waitFor() != 0)
+        throw new RuntimeException("admin stop returned a non-zero response: " + exec.exitValue());
+      Set<TServerInstance> set = getTServers(instance);
+      if (set.contains(victim))
         throw new RuntimeException("Failed to stop " + victim);
     }
   }

Modified: accumulo/trunk/test/system/randomwalk/conf/modules/Concurrent.xml
URL: http://svn.apache.org/viewvc/accumulo/trunk/test/system/randomwalk/conf/modules/Concurrent.xml?rev=1359620&r1=1359619&r2=1359620&view=diff
==============================================================================
--- accumulo/trunk/test/system/randomwalk/conf/modules/Concurrent.xml (original)
+++ accumulo/trunk/test/system/randomwalk/conf/modules/Concurrent.xml Tue Jul 10 11:52:43
2012
@@ -138,7 +138,7 @@
   <edge id="dummy.ToAll" weight="1"/>
 </node>
 
-<node id="StartAll">
+<node id="ct.StartAll">
   <edge id="dummy.ToAll" weight="1"/>
 </node>
 



Mime
View raw message