ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [20/23] incubator-ignite git commit: # ignite-648: smart kill all
Date Mon, 29 Jun 2015 14:05:32 GMT
# ignite-648: smart kill all


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

Branch: refs/heads/ignite-648-failover
Commit: e4f9cc21b652829a559e8673c34f4f5a929b2bcb
Parents: d1ac4dc
Author: ashutak <ashutak@gridgain.com>
Authored: Mon Jun 29 17:05:02 2015 +0300
Committer: ashutak <ashutak@gridgain.com>
Committed: Mon Jun 29 17:05:02 2015 +0300

----------------------------------------------------------------------
 modules/core/pom.xml                            | 32 ++++++++++++++++
 ...OnlyFairAffinityMultiJvmFullApiSelfTest.java |  2 +-
 .../testframework/junits/GridAbstractTest.java  |  5 +++
 .../junits/multijvm/IgniteNodeRunner.java       | 39 ++++++++++++++++++++
 4 files changed, 77 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e4f9cc21/modules/core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index 27235cf..b23d874 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -164,6 +164,14 @@
             <version>2.4</version>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>com.sun</groupId>
+            <artifactId>tools</artifactId>
+            <version>1.4.2</version>
+            <scope>system</scope>
+            <systemPath>${toolsjar}</systemPath>
+        </dependency>
     </dependencies>
 
     <build>
@@ -429,5 +437,29 @@
                 </plugins>
             </build>
         </profile>
+
+        <profile>
+            <id>tools.jar-default</id>
+            <activation>
+                <file>
+                    <exists>${java.home}/../lib/tools.jar</exists>
+                </file>
+            </activation>
+            <properties>
+                <toolsjar>${java.home}/../lib/tools.jar</toolsjar>
+            </properties>
+        </profile>
+
+        <profile>
+            <id>tools.jar-mac</id>
+            <activation>
+                <file>
+                    <exists>${java.home}/../Classes/classes.jar</exists>
+                </file>
+            </activation>
+            <properties>
+                <toolsjar>${java.home}/../Classes/classes.jar</toolsjar>
+            </properties>
+        </profile>
     </profiles>
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e4f9cc21/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicClientOnlyFairAffinityMultiJvmFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicClientOnlyFairAffinityMultiJvmFullApiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicClientOnlyFairAffinityMultiJvmFullApiSelfTest.java
index 91e7f96..85269f5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicClientOnlyFairAffinityMultiJvmFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicClientOnlyFairAffinityMultiJvmFullApiSelfTest.java
@@ -22,7 +22,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.*;
 /**
  * Multy Jvm tests.
  */
-public class GridCacheAtomicClientOnlyFairAffinityMultiJvmFullApiSelfTest 
+public class GridCacheAtomicClientOnlyFairAffinityMultiJvmFullApiSelfTest
     extends GridCacheAtomicClientOnlyFairAffinityMultiNodeFullApiSelfTest {
     /** {@inheritDoc} */
     protected boolean isMultiJvm() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e4f9cc21/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 77a5537..0a43059 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -475,6 +475,11 @@ public abstract class GridAbstractTest extends TestCase {
             }
 
             try {
+                List<Integer> jvmIds = IgniteNodeRunner.killAll();
+
+                if (!jvmIds.isEmpty())
+                    log.info("Next processes of IgniteNodeRunner were killed: " + jvmIds);
+
                 beforeTestsStarted();
             }
             catch (Exception | Error t) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e4f9cc21/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
index e8b9be2..385e485 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
@@ -27,6 +27,7 @@ import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.marshaller.optimized.*;
 import org.apache.ignite.spi.discovery.tcp.*;
+import sun.jvmstat.monitor.*;
 
 import java.io.*;
 import java.util.*;
@@ -119,4 +120,42 @@ public class IgniteNodeRunner {
             new File(fileName).delete();
         }
     }
+
+    /**
+     * Kill all Jvm runned by {#link IgniteNodeRunner}. Works based on jps command.
+     *
+     * @return List of killed process ids.
+     * @throws Exception If exception.
+     */
+    public static List<Integer> killAll() throws Exception{
+        MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(new HostIdentifier("localhost"));
+
+        Set<Integer> jvms = monitoredHost.activeVms();
+
+        List<Integer> res = new ArrayList<>();
+
+        for (Integer jvmId : jvms) {
+            try {
+                MonitoredVm vm = monitoredHost.getMonitoredVm(new VmIdentifier("//" + jvmId
+ "?mode=r"), 0);
+
+                System.out.println(IgniteNodeRunner.class.getName());
+
+                if (IgniteNodeRunner.class.getName().equals(MonitoredVmUtil.mainClass(vm,
true))) {
+                    Process killProc = U.isWindows() ?
+                        Runtime.getRuntime().exec(new String[] {"taskkill", "/pid", jvmId.toString(),
"/f", "/t"}) :
+                        Runtime.getRuntime().exec(new String[] {"kill", "-9", jvmId.toString()});
+
+                    killProc.waitFor();
+
+                    res.add(jvmId);
+                }
+            }
+            catch (Exception e) {
+                // Print stack trace just for information.
+                X.printerrln("Could not kill IgniteNodeRunner java processes. Jvm pid = "
+ jvmId, e);
+            }
+        }
+
+        return res;
+    }
 }


Mime
View raw message