kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [8/8] kudu git commit: KUDU-1669. Java client tests leak orphan processes (part 2)
Date Thu, 06 Oct 2016 00:06:04 GMT
KUDU-1669. Java client tests leak orphan processes (part 2)

In some cases we weren't waiting for the processes to actually finish.

Change-Id: I61d33ca2339048a51acfbb35f5b71e827d3a47f7
Reviewed-on: http://gerrit.cloudera.org:8080/4636
Reviewed-by: Adar Dembo <adar@cloudera.com>
Tested-by: Kudu Jenkins


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

Branch: refs/heads/master
Commit: bce1dd7772c28a5521d97ffbcf02ee17216174a3
Parents: 3c33847
Author: Jean-Daniel Cryans <jdcryans@apache.org>
Authored: Wed Oct 5 14:55:13 2016 -0700
Committer: Jean-Daniel Cryans <jdcryans@apache.org>
Committed: Wed Oct 5 23:46:16 2016 +0000

----------------------------------------------------------------------
 .../org/apache/kudu/client/MiniKuduCluster.java | 36 +++++++++++++++-----
 1 file changed, 27 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/bce1dd77/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java b/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
index 386ce9e..22e4bfc 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
@@ -294,8 +294,7 @@ public class MiniKuduCluster implements AutoCloseable {
       return;
     }
     LOG.info("Killing server at port " + port);
-    ts.destroy();
-    ts.waitFor();
+    destroyAndWaitForProcess(ts);
   }
 
   /**
@@ -304,8 +303,7 @@ public class MiniKuduCluster implements AutoCloseable {
    */
   public void killTabletServers() throws InterruptedException {
     for (Process tserver : tserverProcesses.values()) {
-      tserver.destroy();
-      tserver.waitFor();
+      destroyAndWaitForProcess(tserver);
     }
     tserverProcesses.clear();
   }
@@ -333,8 +331,7 @@ public class MiniKuduCluster implements AutoCloseable {
       return;
     }
     LOG.info("Killing master at port " + port);
-    master.destroy();
-    master.waitFor();
+    destroyAndWaitForProcess(master);
   }
 
   /**
@@ -351,15 +348,31 @@ public class MiniKuduCluster implements AutoCloseable {
    */
   public void shutdown() {
     for (Iterator<Process> masterIter = masterProcesses.values().iterator(); masterIter.hasNext();
) {
-      masterIter.next().destroy();
+      try {
+        destroyAndWaitForProcess(masterIter.next());
+      } catch (InterruptedException e) {
+        // Need to continue cleaning up.
+      }
       masterIter.remove();
     }
+
     for (Iterator<Process> tsIter = tserverProcesses.values().iterator(); tsIter.hasNext();
) {
-      tsIter.next().destroy();
+      try {
+        destroyAndWaitForProcess(tsIter.next());
+      } catch (InterruptedException e) {
+        // Need to continue cleaning up.
+      }
       tsIter.remove();
     }
+
+    // Whether we were interrupted or not above we still destroyed all the processes, so
the input
+    // printers will hit EOFs and stop.
     for (Thread thread : PROCESS_INPUT_PRINTERS) {
-      thread.interrupt();
+      try {
+        thread.join();
+      } catch (InterruptedException e) {
+        // Need to continue cleaning up.
+      }
     }
 
     for (String path : pathsToDelete) {
@@ -376,6 +389,11 @@ public class MiniKuduCluster implements AutoCloseable {
     }
   }
 
+  private void destroyAndWaitForProcess(Process process) throws InterruptedException {
+    process.destroy();
+    process.waitFor();
+  }
+
   /**
    * Returns the comma-separated list of master addresses.
    * @return master addresses


Mime
View raw message