[Swift-commit] r7077 - trunk/src/org/griphyn/vdl/karajan

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Mon Sep 16 22:04:38 CDT 2013


Author: hategan
Date: 2013-09-16 22:04:38 -0500 (Mon, 16 Sep 2013)
New Revision: 7077

Modified:
   trunk/src/org/griphyn/vdl/karajan/HangChecker.java
Log:
also dump waiting/sleeping/blocked JVM threads if everything else fails

Modified: trunk/src/org/griphyn/vdl/karajan/HangChecker.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/HangChecker.java	2013-09-17 02:36:25 UTC (rev 7076)
+++ trunk/src/org/griphyn/vdl/karajan/HangChecker.java	2013-09-17 03:04:38 UTC (rev 7077)
@@ -108,6 +108,9 @@
                     if (!found) {
                         found = findJVMDeadlocks(ps);
                     }
+                    if (!found) {
+                        dumpJVMThreads(ps);
+                    }
                     logger.warn(os.toString());
                     ps.close();
                     if (found) {
@@ -122,9 +125,26 @@
         }
     }
     
+    private void dumpJVMThreads(PrintStream pw) {
+        ThreadMXBean b = ManagementFactory.getThreadMXBean();
+        if (b != null) {
+            long[] ids = b.getAllThreadIds();
+            if (ids != null && ids.length != 0) {
+                ThreadInfo[] tis = b.getThreadInfo(ids, true, true); 
+                pw.println("\nWaiting JVM threads:");
+                for (ThreadInfo ti : tis) {
+                    Thread.State state = ti.getThreadState();
+                    if (state != Thread.State.RUNNABLE && state != Thread.State.TERMINATED) {
+                        printThreadInfo(pw, ti);
+                    }
+                }
+            }
+        }
+    }
+
     private boolean findJVMDeadlocks(PrintStream pw) {;
-        try {
-            ThreadMXBean b = ManagementFactory.getThreadMXBean();
+        ThreadMXBean b = ManagementFactory.getThreadMXBean();
+        if (b != null) {
             long[] ids = b.findDeadlockedThreads();
             if (ids != null && ids.length != 0) {
                 ThreadInfo[] tis = b.getThreadInfo(ids, true, true); 
@@ -135,9 +155,6 @@
                 return true;
             }
         }
-        catch (Exception e) {
-            logger.warn("Exception caught trying to find JVM deadlocks", e);
-        }
         return false;
     }
 




More information about the Swift-commit mailing list