ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [40/46] incubator-ignite git commit: merging ignite-479
Date Mon, 06 Apr 2015 17:37:19 GMT
merging ignite-479


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

Branch: refs/heads/ignite-366
Commit: 1aaa0b09698d24380160e200fa03ab36feea1f34
Parents: 7e6d193
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Mon Apr 6 18:53:18 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Mon Apr 6 18:53:18 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/util/IgniteUtils.java       | 41 +++++++++++++++++++-
 .../hadoop/HadoopCommandLineTest.java           |  3 +-
 2 files changed, 41 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1aaa0b09/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 8aebac2..8a982bc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -964,6 +964,14 @@ public abstract class IgniteUtils {
     public static void dumpThreads(@Nullable IgniteLogger log) {
         ThreadMXBean mxBean = ManagementFactory.getThreadMXBean();
 
+        final Set<Long> deadlockedThreadsIds = getDeadlockedThreadIds(mxBean);
+
+        if (deadlockedThreadsIds.size() == 0)
+            warn(log, "No deadlocked threads detected.");
+        else
+            warn(log, "Deadlocked threads detected (see thread dump below) " +
+                    "[deadlockedThreadsCnt=" + deadlockedThreadsIds.size() + ']');
+
         ThreadInfo[] threadInfos =
             mxBean.dumpAllThreads(mxBean.isObjectMonitorUsageSupported(), mxBean.isSynchronizerUsageSupported());
 
@@ -971,7 +979,7 @@ public abstract class IgniteUtils {
             .a(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss z").format(new Date(U.currentTimeMillis()))).a(NL);
 
         for (ThreadInfo info : threadInfos) {
-            printThreadInfo(info, sb);
+            printThreadInfo(info, sb, deadlockedThreadsIds);
 
             sb.a(NL);
 
@@ -988,12 +996,41 @@ public abstract class IgniteUtils {
     }
 
     /**
+     * Get deadlocks from the thread bean.
+     * @param mxBean the bean
+     * @return the set of deadlocked threads (may be empty Set, but never null).
+     */
+    private static Set<Long> getDeadlockedThreadIds(ThreadMXBean mxBean) {
+        final long[] deadlockedIds = mxBean.findDeadlockedThreads();
+
+        final Set<Long> deadlockedThreadsIds;
+
+        if (!F.isEmpty(deadlockedIds)) {
+            Set<Long> set = new HashSet<>();
+
+            for (long id : deadlockedIds)
+                set.add(id);
+
+            deadlockedThreadsIds = Collections.unmodifiableSet(set);
+        }
+        else
+            deadlockedThreadsIds = Collections.emptySet();
+
+        return deadlockedThreadsIds;
+    }
+
+    /**
      * Prints single thread info to a buffer.
      *
      * @param threadInfo Thread info.
      * @param sb Buffer.
      */
-    private static void printThreadInfo(ThreadInfo threadInfo, GridStringBuilder sb) {
+    private static void printThreadInfo(ThreadInfo threadInfo, GridStringBuilder sb, Set<Long>
deadlockedIdSet) {
+        final long id = threadInfo.getThreadId();
+
+        if (deadlockedIdSet.contains(id))
+            sb.a("##### DEADLOCKED ");
+
         sb.a("Thread [name=\"").a(threadInfo.getThreadName())
             .a("\", id=").a(threadInfo.getThreadId())
             .a(", state=").a(threadInfo.getThreadState())

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1aaa0b09/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopCommandLineTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopCommandLineTest.java
b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopCommandLineTest.java
index d10ee5c..f6f7a01 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopCommandLineTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopCommandLineTest.java
@@ -200,7 +200,8 @@ public class HadoopCommandLineTest extends GridCommonAbstractTest {
     @Override protected void afterTestsStopped() throws Exception {
         super.afterTestsStopped();
 
-        U.delete(testWorkDir);
+        if (testWorkDir != null)
+            U.delete(testWorkDir);
     }
 
     /** {@inheritDoc} */


Mime
View raw message