You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/08/25 15:15:30 UTC

[1/4] git commit: SLIDER-353 killJavaProcesses doesn't work on windows: testcase

Repository: incubator-slider
Updated Branches:
  refs/heads/develop d8f8771b9 -> 7b7d29e9a


SLIDER-353 killJavaProcesses doesn't work on windows: testcase


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/73389fd5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/73389fd5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/73389fd5

Branch: refs/heads/develop
Commit: 73389fd57e36e2f5987161594c343009a618cebe
Parents: d8f8771
Author: Steve Loughran <st...@apache.org>
Authored: Mon Aug 25 12:30:37 2014 +0100
Committer: Steve Loughran <st...@apache.org>
Committed: Mon Aug 25 12:30:37 2014 +0100

----------------------------------------------------------------------
 .../common/tools/TestWindowsSupport.groovy      |  6 ++++
 .../apache/slider/test/SliderTestUtils.groovy   | 29 ++++++++++++++++++++
 .../slider/test/YarnMiniClusterTestBase.groovy  | 23 ----------------
 3 files changed, 35 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/73389fd5/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
index d11aa55..7f5edf3 100644
--- a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
@@ -103,4 +103,10 @@ class TestWindowsSupport extends SliderTestUtils {
     }
     
   }
+
+  @Test
+  public void testEmitKillCommand() throws Throwable {
+    killJavaProcesses("regionserver", 9)
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/73389fd5/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
index 3fc3e55..0a1354b 100644
--- a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
@@ -28,6 +28,7 @@ import org.apache.hadoop.conf.Configuration
 import org.apache.hadoop.fs.FileStatus
 import org.apache.hadoop.fs.FileSystem as HadoopFS
 import org.apache.hadoop.fs.Path
+import org.apache.hadoop.util.Shell
 import org.apache.hadoop.yarn.api.records.ApplicationReport
 import org.apache.hadoop.yarn.conf.YarnConfiguration
 import org.apache.slider.api.ClusterDescription
@@ -737,4 +738,32 @@ class SliderTestUtils extends Assert {
       log.info "$key -- ${config.description}"
     }
   }
+
+  /**
+   * Kill any java process with the given grep pattern
+   * @param grepString string to grep for
+   */
+  public void killJavaProcesses(String grepString, int signal) {
+
+    assume(!Shell.WINDOWS, "failed to kill -$signal $grepString - no windows support ")
+    
+    GString bashCommand = "jps -l| grep ${grepString} | awk '{print \$1}' | xargs kill $signal"
+    log.info("Bash command = $bashCommand" )
+    Process bash = ["bash", "-c", bashCommand].execute()
+    bash.waitFor()
+
+    log.info(bash.in.text)
+    log.error(bash.err.text)
+  }
+
+  /**
+   * Kill all processes which match one of the list of grepstrings
+   * @param greps
+   * @param signal
+   */
+  public void killJavaProcesses(List<String> greps, int signal) {
+    for (String grep : greps) {
+      killJavaProcesses(grep,signal)
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/73389fd5/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy b/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
index 09c56a5..5a091bf 100644
--- a/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
@@ -322,29 +322,6 @@ public abstract class YarnMiniClusterTestBase extends ServiceLauncherBaseTest {
   }
 
   /**
-   * Kill any java process with the given grep pattern
-   * @param grepString string to grep for
-   */
-  public void killJavaProcesses(String grepString, int signal) {
-
-    assume(!Shell.WINDOWS, "failed to kill -$signal $grepString - no windows support ")
-    
-    GString bashCommand = "jps -l| grep ${grepString} | awk '{print \$1}' | xargs kill $signal"
-    log.info("Bash command = $bashCommand" )
-    Process bash = ["bash", "-c", bashCommand].execute()
-    bash.waitFor()
-
-    log.info(bash.in.text)
-    log.error(bash.err.text)
-  }
-
-  public void killJavaProcesses(List<String> greps, int signal) {
-    for (String grep : greps) {
-      killJavaProcesses(grep,signal)
-    }
-  }
-
-  /**
    * List any java process with the given grep pattern
    * @param grepString string to grep for
    */


[2/4] git commit: SLIDER-353 killJavaProcesses doesn't work on windows

Posted by st...@apache.org.
SLIDER-353 killJavaProcesses doesn't work on windows


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/1d62a81d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/1d62a81d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/1d62a81d

Branch: refs/heads/develop
Commit: 1d62a81ddda40ebd6efc9159cf06c912817d2d55
Parents: 73389fd
Author: Steve Loughran <st...@apache.org>
Authored: Mon Aug 25 12:39:01 2014 +0100
Committer: Steve Loughran <st...@apache.org>
Committed: Mon Aug 25 12:39:01 2014 +0100

----------------------------------------------------------------------
 .../src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/1d62a81d/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
index 0a1354b..8057356 100644
--- a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
@@ -745,7 +745,7 @@ class SliderTestUtils extends Assert {
    */
   public void killJavaProcesses(String grepString, int signal) {
 
-    assume(!Shell.WINDOWS, "failed to kill -$signal $grepString - no windows support ")
+//    assume(!Shell.WINDOWS, "failed to kill -$signal $grepString - no windows support ")
     
     GString bashCommand = "jps -l| grep ${grepString} | awk '{print \$1}' | xargs kill $signal"
     log.info("Bash command = $bashCommand" )


[4/4] git commit: Merge branch 'feature/SLIDER-353_killJavaProcesses_doesn't_work_on_windows' into develop

Posted by st...@apache.org.
Merge branch 'feature/SLIDER-353_killJavaProcesses_doesn't_work_on_windows' into develop


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/7b7d29e9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/7b7d29e9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/7b7d29e9

Branch: refs/heads/develop
Commit: 7b7d29e9a0327d3108d57317896518ddefd677dd
Parents: d8f8771 38c2a13
Author: Steve Loughran <st...@apache.org>
Authored: Mon Aug 25 13:23:11 2014 +0100
Committer: Steve Loughran <st...@apache.org>
Committed: Mon Aug 25 13:23:11 2014 +0100

----------------------------------------------------------------------
 .../common/tools/TestWindowsSupport.groovy      |  6 +++
 .../apache/slider/test/SliderTestUtils.groovy   | 39 ++++++++++++++++++++
 .../slider/test/YarnMiniClusterTestBase.groovy  | 23 ------------
 3 files changed, 45 insertions(+), 23 deletions(-)
----------------------------------------------------------------------



[3/4] git commit: SLIDER-353 killJavaProcesses doesn't work on windows

Posted by st...@apache.org.
SLIDER-353 killJavaProcesses doesn't work on windows


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/38c2a138
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/38c2a138
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/38c2a138

Branch: refs/heads/develop
Commit: 38c2a138b54d9a87794446447a19707f0a51c4d4
Parents: 1d62a81
Author: Steve Loughran <st...@apache.org>
Authored: Mon Aug 25 13:01:54 2014 +0100
Committer: Steve Loughran <st...@apache.org>
Committed: Mon Aug 25 13:01:54 2014 +0100

----------------------------------------------------------------------
 .../apache/slider/test/SliderTestUtils.groovy   | 30 +++++++++++++-------
 1 file changed, 20 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/38c2a138/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
index 8057356..0036db7 100644
--- a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
@@ -743,17 +743,27 @@ class SliderTestUtils extends Assert {
    * Kill any java process with the given grep pattern
    * @param grepString string to grep for
    */
-  public void killJavaProcesses(String grepString, int signal) {
-
-//    assume(!Shell.WINDOWS, "failed to kill -$signal $grepString - no windows support ")
-    
-    GString bashCommand = "jps -l| grep ${grepString} | awk '{print \$1}' | xargs kill $signal"
-    log.info("Bash command = $bashCommand" )
-    Process bash = ["bash", "-c", bashCommand].execute()
-    bash.waitFor()
+  public int killJavaProcesses(String grepString, int signal) {
+
+    def commandString
+    if (!Shell.WINDOWS) {
+      GString killCommand = "jps -l| grep ${grepString} | awk '{print \$1}' | xargs kill $signal"
+      log.info("Command command = $killCommand" )
+
+      commandString = ["bash", "-c", killCommand]
+    } else {
+      /*
+      "jps -l | grep "String" | awk "{print $1}" | xargs -n 1 taskkill /PID"
+       */
+      GString killCommand = "\"jps -l | grep \"${grepString}\" | awk \"{print \$1}\" | xargs -n 1 taskkill /PID\""
+      commandString = ["CMD", "/C", killCommand]
+    }
+    Process command = commandString.execute()
+    def exitCode = command.waitFor()
 
-    log.info(bash.in.text)
-    log.error(bash.err.text)
+    log.info(command.in.text)
+    log.error(command.err.text)
+    return exitCode
   }
 
   /**