accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [1/3] git commit: ACCUMULO-3139 Reflect on UNIXProcess to get the pid and use kill instead of pkill.
Date Wed, 17 Sep 2014 20:08:15 GMT
Repository: accumulo
Updated Branches:
  refs/heads/1.6.1-SNAPSHOT 0bd5d4385 -> 4cf467b92
  refs/heads/master ff01c6860 -> f90da7c7b


ACCUMULO-3139 Reflect on UNIXProcess to get the pid and use kill instead of pkill.

pkill has the potential to overmatch and SIGSTOP+SIGCONT other tablet
servers on the same node. If it tries to match tservers started by
other users, this will also fail, AFAICT.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/4cf467b9
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/4cf467b9
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/4cf467b9

Branch: refs/heads/1.6.1-SNAPSHOT
Commit: 4cf467b926d7beae17b47103105d892f24e75e70
Parents: 0bd5d43
Author: Josh Elser <elserj@apache.org>
Authored: Wed Sep 17 15:06:41 2014 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Wed Sep 17 15:06:41 2014 -0400

----------------------------------------------------------------------
 .../minicluster/impl/ProcessReference.java      |  7 +++++
 .../functional/BalanceAfterCommsFailureIT.java  | 32 +++++++++++++++++---
 2 files changed, 34 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/4cf467b9/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/ProcessReference.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/ProcessReference.java
b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/ProcessReference.java
index 9aa2449..ff58869 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/ProcessReference.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/ProcessReference.java
@@ -27,6 +27,13 @@ public class ProcessReference {
     this.process = process;
   }
 
+  /**
+   * Visible for testing, not intended for client consumption
+   */
+  public Process getProcess() {
+    return process;
+  }
+
   @Override
   public String toString() {
     return process.toString();

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4cf467b9/test/src/test/java/org/apache/accumulo/test/functional/BalanceAfterCommsFailureIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/BalanceAfterCommsFailureIT.java
b/test/src/test/java/org/apache/accumulo/test/functional/BalanceAfterCommsFailureIT.java
index 5e3966e..f062c8f 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/BalanceAfterCommsFailureIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/BalanceAfterCommsFailureIT.java
@@ -19,7 +19,9 @@ package org.apache.accumulo.test.functional;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import java.lang.reflect.Field;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.SortedSet;
@@ -35,19 +37,21 @@ import org.apache.accumulo.core.master.thrift.TableInfo;
 import org.apache.accumulo.core.master.thrift.TabletServerStatus;
 import org.apache.accumulo.core.security.Credentials;
 import org.apache.accumulo.fate.util.UtilWaitThread;
+import org.apache.accumulo.minicluster.ServerType;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
+import org.apache.accumulo.minicluster.impl.ProcessReference;
 import org.apache.accumulo.trace.instrument.Tracer;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.Text;
 import org.junit.Test;
 
 public class BalanceAfterCommsFailureIT extends ConfigurableMacIT {
-  
+
   @Override
   public void configure(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
     cfg.setSiteConfig(Collections.singletonMap(Property.GENERAL_RPC_TIMEOUT.getKey(), "2s"));
   }
-  
+
   @Override
   protected int defaultTimeoutSeconds() {
     return 2 * 60;
@@ -57,9 +61,27 @@ public class BalanceAfterCommsFailureIT extends ConfigurableMacIT {
   public void test() throws Exception {
     Connector c = this.getConnector();
     c.tableOperations().create("test");
-    assertEquals(0, Runtime.getRuntime().exec(new String[]{"pkill", "-SIGSTOP", "-f", "TabletServer"}).waitFor());
+    Collection<ProcessReference> tservers = getCluster().getProcesses().get(ServerType.TABLET_SERVER);
+    ArrayList<Integer> tserverPids = new ArrayList<Integer>(tservers.size());
+    for (ProcessReference tserver : tservers) {
+      Process p = tserver.getProcess();
+      if (!p.getClass().getName().equals("java.lang.UNIXProcess")) {
+        log.info("Found process that was not UNIXProcess, exiting test");
+        return;
+      }
+
+      Field f = p.getClass().getDeclaredField("pid");
+      f.setAccessible(true);
+      tserverPids.add(f.getInt(p));
+    }
+
+    for (int pid : tserverPids) {
+      assertEquals(0, Runtime.getRuntime().exec(new String[] {"kill", "-SIGSTOP", Integer.toString(pid)}).waitFor());
+    }
     UtilWaitThread.sleep(20 * 1000);
-    assertEquals(0, Runtime.getRuntime().exec(new String[]{"pkill", "-SIGCONT", "-f", "TabletServer"}).waitFor());
+    for (int pid : tserverPids) {
+      assertEquals(0, Runtime.getRuntime().exec(new String[] {"kill", "-SIGCONT", Integer.toString(pid)}).waitFor());
+    }
     SortedSet<Text> splits = new TreeSet<Text>();
     for (String split : "a b c d e f g h i j k l m n o p q r s t u v w x y z".split(" "))
{
       splits.add(new Text(split));
@@ -71,7 +93,7 @@ public class BalanceAfterCommsFailureIT extends ConfigurableMacIT {
 
   private void checkBalance(Connector c) throws Exception {
     Credentials creds = new Credentials("root", new PasswordToken(ROOT_PASSWORD));
-    
+
     MasterClientService.Iface client = null;
     MasterMonitorInfo stats = null;
     try {


Mime
View raw message