java.lang.management.MonitorInfo Java Examples

The following examples show how to use java.lang.management.MonitorInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeadlockDetector.java    From mapleLemon with GNU General Public License v2.0 6 votes vote down vote up
private void printThreadInfo(ThreadInfo threadInfo) {
    printThread(threadInfo);
    this.sb.append(INDENT).append(threadInfo.toString()).append("\n");
    StackTraceElement[] stacktrace = threadInfo.getStackTrace();
    MonitorInfo[] monitors = threadInfo.getLockedMonitors();

    for (int i = 0; i < stacktrace.length; i++) {
        StackTraceElement ste = stacktrace[i];
        this.sb.append(INDENT).append("at ").append(ste.toString()).append("\n");
        for (MonitorInfo mi : monitors) {
            if (mi.getLockedStackDepth() == i) {
                this.sb.append(INDENT).append("  - locked ").append(mi).append("\n");
            }
        }
    }
}
 
Example #2
Source File: Detector.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void printThreadInfo(ThreadInfo ti, PrintStream out) {
   printThread(ti, out);

   // print stack trace with locks
   StackTraceElement[] stacktrace = ti.getStackTrace();
   MonitorInfo[] monitors = ti.getLockedMonitors();
   for (int i = 0; i < stacktrace.length; i++) {
       StackTraceElement ste = stacktrace[i];
       out.println(INDENT + "at " + ste.toString()); // NOI18N
       for (MonitorInfo mi : monitors) {
           if (mi.getLockedStackDepth() == i) {
               out.println(INDENT + "  - locked " + mi); // NOI18N
           }
       }
   }
   out.println();
}
 
Example #3
Source File: ThreadMonitor.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void printThreadInfo(ThreadInfo ti) {
   // print thread information
   printThread(ti);

   // print stack trace with locks
   StackTraceElement[] stacktrace = ti.getStackTrace();
   MonitorInfo[] monitors = ti.getLockedMonitors();
   for (int i = 0; i < stacktrace.length; i++) {
       StackTraceElement ste = stacktrace[i];
       System.out.println(INDENT + "at " + ste.toString());
       for (MonitorInfo mi : monitors) {
           if (mi.getLockedStackDepth() == i) {
               System.out.println(INDENT + "  - locked " + mi);
           }
       }
   }
   System.out.println();
}
 
Example #4
Source File: WatchdogThread.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
private static void dumpThread(ThreadInfo thread, Logger log) {
    log.log(Level.SEVERE, "------------------------------");
    //
    log.log(Level.SEVERE, "Current Thread: " + thread.getThreadName());
    log.log(Level.SEVERE, "\tPID: " + thread.getThreadId()
            + " | Suspended: " + thread.isSuspended()
            + " | Native: " + thread.isInNative()
            + " | State: " + thread.getThreadState());
    if (thread.getLockedMonitors().length != 0) {
        log.log(Level.SEVERE, "\tThread is waiting on monitor(s):");
        for (MonitorInfo monitor : thread.getLockedMonitors()) {
            log.log(Level.SEVERE, "\t\tLocked on:" + monitor.getLockedStackFrame());
        }
    }
    log.log(Level.SEVERE, "\tStack:");
    //
    for (StackTraceElement stack : thread.getStackTrace()) {
        log.log(Level.SEVERE, "\t\t" + stack);
    }
}
 
Example #5
Source File: ThreadMonitor.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void printThreadInfo(ThreadInfo ti) {
   // print thread information
   printThread(ti);

   // print stack trace with locks
   StackTraceElement[] stacktrace = ti.getStackTrace();
   MonitorInfo[] monitors = ti.getLockedMonitors();
   for (int i = 0; i < stacktrace.length; i++) {
       StackTraceElement ste = stacktrace[i];
       System.out.println(INDENT + "at " + ste.toString());
       for (MonitorInfo mi : monitors) {
           if (mi.getLockedStackDepth() == i) {
               System.out.println(INDENT + "  - locked " + mi);
           }
       }
   }
   System.out.println();
}
 
Example #6
Source File: MBeanDumper.java    From tda with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void printThreadInfo(ThreadInfo ti, StringBuilder dump) {
   // print thread information
   printThread(ti, dump);

   // print stack trace with locks
   StackTraceElement[] stacktrace = ti.getStackTrace();
   MonitorInfo[] monitors = ti.getLockedMonitors();
   for (int i = 0; i < stacktrace.length; i++) {
       StackTraceElement ste = stacktrace[i];
       dump.append(INDENT + "at " + ste.toString());
       dump.append("\n");
       for (int j = 1; j < monitors.length; j++) {
           MonitorInfo mi = monitors[j];
           if (mi.getLockedStackDepth() == i) {
               dump.append(INDENT + "  - locked " + mi);
               dump.append("\n");
           }
       }
   }
   dump.append("\n");
}
 
Example #7
Source File: ThreadMonitor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void printThreadInfo(ThreadInfo ti) {
   // print thread information
   printThread(ti);

   // print stack trace with locks
   StackTraceElement[] stacktrace = ti.getStackTrace();
   MonitorInfo[] monitors = ti.getLockedMonitors();
   for (int i = 0; i < stacktrace.length; i++) {
       StackTraceElement ste = stacktrace[i];
       System.out.println(INDENT + "at " + ste.toString());
       for (MonitorInfo mi : monitors) {
           if (mi.getLockedStackDepth() == i) {
               System.out.println(INDENT + "  - locked " + mi);
           }
       }
   }
   System.out.println();
}
 
Example #8
Source File: TimedOutTestsListener.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
private static void printThreadInfo(ThreadInfo ti, PrintWriter out) {
    // print thread information
    printThread(ti, out);

    // print stack trace with locks
    StackTraceElement[] stacktrace = ti.getStackTrace();
    MonitorInfo[] monitors = ti.getLockedMonitors();
    for (int i = 0; i < stacktrace.length; i++) {
        StackTraceElement ste = stacktrace[i];
        out.println(indent + "at " + ste.toString());
        for (MonitorInfo mi : monitors) {
            if (mi.getLockedStackDepth() == i) {
                out.println(indent + "  - locked " + mi);
            }
        }
    }
    out.println();
}
 
Example #9
Source File: NbTestCase.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static StringBuilder printThreadInfo(ThreadInfo ti, StringBuilder sb) {
    // print thread information
    printThread(ti, sb);

    // print stack trace with locks
    StackTraceElement[] stacktrace = ti.getStackTrace();
    MonitorInfo[] monitors = ti.getLockedMonitors();
    for (int i = 0; i < stacktrace.length; i++) {
        StackTraceElement ste = stacktrace[i];
        sb.append("\t at " + ste.toString()).append("\n");
        for (MonitorInfo mi : monitors) {
            if (mi.getLockedStackDepth() == i) {
                sb.append("\t  - locked " + mi).append("\n");
            }
        }
    }
    sb.append("\n");
    return sb;
}
 
Example #10
Source File: Watchdog.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
private static void dumpThread(ThreadInfo thread, Logger logger) {
    logger.emergency("Current Thread: " + thread.getThreadName());
    logger.emergency("\tPID: " + thread.getThreadId() + " | Suspended: " + thread.isSuspended() + " | Native: " + thread.isInNative() + " | State: " + thread.getThreadState());
    // Monitors
    if (thread.getLockedMonitors().length != 0) {
        logger.emergency("\tThread is waiting on monitor(s):");
        for (MonitorInfo monitor : thread.getLockedMonitors()) {
            logger.emergency("\t\tLocked on:" + monitor.getLockedStackFrame());
        }
    }

    logger.emergency("\tStack:");
    for (StackTraceElement stack : thread.getStackTrace()) {
        logger.emergency("\t\t" + stack);
    }
}
 
Example #11
Source File: TimedOutTestsListener.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private static void printThreadInfo(ThreadInfo ti, PrintWriter out) {
  // print thread information
  printThread(ti, out);

  // print stack trace with locks
  StackTraceElement[] stacktrace = ti.getStackTrace();
  MonitorInfo[] monitors = ti.getLockedMonitors();
  for (int i = 0; i < stacktrace.length; i++) {
    StackTraceElement ste = stacktrace[i];
    out.println(INDENT + "at " + ste.toString());
    for (MonitorInfo mi : monitors) {
      if (mi.getLockedStackDepth() == i) {
        out.println(INDENT + "  - locked " + mi);
      }
    }
  }
  out.println();
}
 
Example #12
Source File: ThreadMonitor.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private void printThreadInfo(ThreadInfo ti) {
   // print thread information
   printThread(ti);

   // print stack trace with locks
   StackTraceElement[] stacktrace = ti.getStackTrace();
   MonitorInfo[] monitors = ti.getLockedMonitors();
   for (int i = 0; i < stacktrace.length; i++) {
       StackTraceElement ste = stacktrace[i];
       System.out.println(INDENT + "at " + ste.toString());
       for (MonitorInfo mi : monitors) {
           if (mi.getLockedStackDepth() == i) {
               System.out.println(INDENT + "  - locked " + mi);
           }
       }
   }
   System.out.println();
}
 
Example #13
Source File: ThreadMonitor.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void printThreadInfo(ThreadInfo ti) {
   // print thread information
   printThread(ti);

   // print stack trace with locks
   StackTraceElement[] stacktrace = ti.getStackTrace();
   MonitorInfo[] monitors = ti.getLockedMonitors();
   for (int i = 0; i < stacktrace.length; i++) {
       StackTraceElement ste = stacktrace[i];
       System.out.println(INDENT + "at " + ste.toString());
       for (MonitorInfo mi : monitors) {
           if (mi.getLockedStackDepth() == i) {
               System.out.println(INDENT + "  - locked " + mi);
           }
       }
   }
   System.out.println();
}
 
Example #14
Source File: ThreadMonitor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void printMonitorInfo(ThreadInfo ti) {
   MonitorInfo[] monitors = ti.getLockedMonitors();
   System.out.println(INDENT + "Locked monitors: count = " + monitors.length);
   for (MonitorInfo mi : monitors) {
       System.out.println(INDENT + "  - " + mi + " locked at ");
       System.out.println(INDENT + "      " + mi.getLockedStackDepth() +
                          " " + mi.getLockedStackFrame());
   }
}
 
Example #15
Source File: ThreadMonitor.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void printMonitorInfo(ThreadInfo ti) {
   MonitorInfo[] monitors = ti.getLockedMonitors();
   System.out.println(INDENT + "Locked monitors: count = " + monitors.length);
   for (MonitorInfo mi : monitors) {
       System.out.println(INDENT + "  - " + mi + " locked at ");
       System.out.println(INDENT + "      " + mi.getLockedStackDepth() +
                          " " + mi.getLockedStackFrame());
   }
}
 
Example #16
Source File: TestRunRecording.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Prints the owned locks for the thread.
 * Must have explicitly obtained Monitor and Synchronizer information for anything to show up from here.
 *
 * @param info
 *          the {@code:ThreadInfo} for the thread in question, must not be {@code:null}
 * @return the owned lock information
 */
private static String getOwnedLockInfo(final ThreadInfo info) {
  StringBuilder trace = new StringBuilder("  Holding locks for:\r\n");
  for (LockInfo lock : info.getLockedSynchronizers()) {
    trace.append("    " + lock.toString() + "\r\n");
  }
  for (MonitorInfo monitor : info.getLockedMonitors()) {
    trace.append("    " + monitor.toString() + "\r\n");
  }
  return trace.toString();
}
 
Example #17
Source File: ThreadDumpWindow.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void printMonitors(final StringBuilder sb, final MonitorInfo[] monitors, final int index) {
    if (monitors != null) {
        for (MonitorInfo mi : monitors) {
            if (mi.getLockedStackDepth() == index) {
                sb.append("    - locked ");   // NOI18N
                printLock(sb, mi);
                sb.append("<br>");    // NOI18N
            }
        }
    }
}
 
Example #18
Source File: ThreadInfoCompositeData.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public MonitorInfo[] lockedMonitors() {
    CompositeData[] lockedMonitorsData =
        (CompositeData[]) cdata.get(LOCKED_MONITORS);

    // The LockedMonitors item cannot be null, but if it is we will get
    // a NullPointerException when we ask for its length.
    MonitorInfo[] monitors =
        new MonitorInfo[lockedMonitorsData.length];
    for (int i = 0; i < lockedMonitorsData.length; i++) {
        CompositeData cdi = lockedMonitorsData[i];
        monitors[i] = MonitorInfo.from(cdi);
    }
    return monitors;
}
 
Example #19
Source File: ThreadMonitor.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void printMonitorInfo(ThreadInfo ti) {
   MonitorInfo[] monitors = ti.getLockedMonitors();
   System.out.println(INDENT + "Locked monitors: count = " + monitors.length);
   for (MonitorInfo mi : monitors) {
       System.out.println(INDENT + "  - " + mi + " locked at ");
       System.out.println(INDENT + "      " + mi.getLockedStackDepth() +
                          " " + mi.getLockedStackFrame());
   }
}
 
Example #20
Source File: MappedMXBeanType.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
Object toOpenTypeData(Object data) throws OpenDataException {
    if (data instanceof MemoryUsage) {
        return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
    }

    if (data instanceof ThreadInfo) {
        return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
    }

    if (data instanceof LockInfo) {
        if (data instanceof java.lang.management.MonitorInfo) {
            return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
        }
        return LockInfoCompositeData.toCompositeData((LockInfo) data);
    }

    if (data instanceof MemoryNotificationInfo) {
        return MemoryNotifInfoCompositeData.
            toCompositeData((MemoryNotificationInfo) data);
    }

    if (data instanceof VMOption) {
        return VMOptionCompositeData.toCompositeData((VMOption) data);
    }

    if (isCompositeData) {
        // Classes that implement CompositeData
        //
        // construct a new CompositeDataSupport object
        // so that no other classes are sent over the wire
        CompositeData cd = (CompositeData) data;
        CompositeType ct = cd.getCompositeType();
        String[] itemNames = ct.keySet().toArray(new String[0]);
        Object[] itemValues = cd.getAll(itemNames);
        return new CompositeDataSupport(ct, itemNames, itemValues);
    }

    throw new OpenDataException(javaClass.getName() +
        " is not supported for platform MXBeans");
}
 
Example #21
Source File: Detector.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void printMonitorInfo(ThreadInfo ti, PrintStream out) {
   MonitorInfo[] monitors = ti.getLockedMonitors();
   out.println(INDENT + "Locked monitors: count = " + monitors.length); // NOI18N
   for (MonitorInfo mi : monitors) {
       out.println(INDENT + "  - " + mi + " locked at "); // NOI18N
       out.println(INDENT + "      " + mi.getLockedStackDepth() + // NOI18N
                          " " + mi.getLockedStackFrame());       // NOI18N
   }
}
 
Example #22
Source File: ThreadDumpWindow.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void printMonitors(final StringBuilder sb, final MonitorInfo[] monitors, final int index) {
    if (monitors != null) {
        for (MonitorInfo mi : monitors) {
            if (mi.getLockedStackDepth() == index) {
                sb.append("    - locked ");   // NOI18N
                printLock(sb, mi);
                sb.append("<br>");    // NOI18N
            }
        }
    }
}
 
Example #23
Source File: PlatformMBeanUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static ModelNode getDetypedMonitorInfo(final MonitorInfo monitorInfo) {
    final ModelNode result = getDetypedLockInfo(monitorInfo);
    if (monitorInfo != null) {
        result.get(PlatformMBeanConstants.LOCKED_STACK_DEPTH).set(monitorInfo.getLockedStackDepth());
        final ModelNode frame = getDetypedStackTraceElement(monitorInfo.getLockedStackFrame());
        result.get(PlatformMBeanConstants.LOCKED_STACK_FRAME).set(frame);
    }
    return result;
}
 
Example #24
Source File: NbTestCase.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void printMonitorInfo(ThreadInfo ti, MonitorInfo[] monitors, StringBuilder sb) {
    sb.append("\tLocked monitors: count = " + monitors.length).append("\n");
    for (MonitorInfo mi : monitors) {
        sb.append("\t  - " + mi + " locked at ").append("\n");
        sb.append("\t      " + mi.getLockedStackDepth() + " "
                + mi.getLockedStackFrame()).append("\n");
    }
}
 
Example #25
Source File: ThreadMonitor.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void printMonitorInfo(ThreadInfo ti) {
   MonitorInfo[] monitors = ti.getLockedMonitors();
   System.out.println(INDENT + "Locked monitors: count = " + monitors.length);
   for (MonitorInfo mi : monitors) {
       System.out.println(INDENT + "  - " + mi + " locked at ");
       System.out.println(INDENT + "      " + mi.getLockedStackDepth() +
                          " " + mi.getLockedStackFrame());
   }
}
 
Example #26
Source File: ThreadMonitor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void printMonitorInfo(ThreadInfo ti) {
   MonitorInfo[] monitors = ti.getLockedMonitors();
   System.out.println(INDENT + "Locked monitors: count = " + monitors.length);
   for (MonitorInfo mi : monitors) {
       System.out.println(INDENT + "  - " + mi + " locked at ");
       System.out.println(INDENT + "      " + mi.getLockedStackDepth() +
                          " " + mi.getLockedStackFrame());
   }
}
 
Example #27
Source File: MappedMXBeanType.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
Object toOpenTypeData(Object data) throws OpenDataException {
    if (data instanceof MemoryUsage) {
        return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
    }

    if (data instanceof ThreadInfo) {
        return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
    }

    if (data instanceof LockInfo) {
        if (data instanceof java.lang.management.MonitorInfo) {
            return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
        }
        return LockInfoCompositeData.toCompositeData((LockInfo) data);
    }

    if (data instanceof MemoryNotificationInfo) {
        return MemoryNotifInfoCompositeData.
            toCompositeData((MemoryNotificationInfo) data);
    }

    if (data instanceof VMOption) {
        return VMOptionCompositeData.toCompositeData((VMOption) data);
    }

    if (isCompositeData) {
        // Classes that implement CompositeData
        //
        // construct a new CompositeDataSupport object
        // so that no other classes are sent over the wire
        CompositeData cd = (CompositeData) data;
        CompositeType ct = cd.getCompositeType();
        String[] itemNames = ct.keySet().toArray(new String[0]);
        Object[] itemValues = cd.getAll(itemNames);
        return new CompositeDataSupport(ct, itemNames, itemValues);
    }

    throw new OpenDataException(javaClass.getName() +
        " is not supported for platform MXBeans");
}
 
Example #28
Source File: DeadlockDetector.java    From mapleLemon with GNU General Public License v2.0 5 votes vote down vote up
private void printMonitorInfo(ThreadInfo threadInfo, MonitorInfo[] monitorInfos) {
    this.sb.append(INDENT).append("Locked monitors: count = ").append(monitorInfos.length).append("\n");
    for (MonitorInfo monitorInfo : monitorInfos) {
        this.sb.append(INDENT).append("  - ").append(monitorInfo).append(" locked at \n");
        this.sb.append(INDENT).append("      ").append(monitorInfo.getLockedStackDepth()).append(" ").append(monitorInfo.getLockedStackFrame()).append("\n");
    }
}
 
Example #29
Source File: JmxSupport.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void printMonitors(final StringBuilder sb, final MonitorInfo[] monitors, final int index) {
    if (monitors != null) {
        for (MonitorInfo mi : monitors) {
            if (mi.getLockedStackDepth() == index) {
                sb.append("\t- locked ");   // NOI18N
                printLock(sb,mi);
                sb.append("\n");    // NOI18N
            }
        }
    }
}
 
Example #30
Source File: ThreadInfoCompositeData.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public MonitorInfo[] lockedMonitors() {
    CompositeData[] lockedMonitorsData =
        (CompositeData[]) cdata.get(LOCKED_MONITORS);

    // The LockedMonitors item cannot be null, but if it is we will get
    // a NullPointerException when we ask for its length.
    MonitorInfo[] monitors =
        new MonitorInfo[lockedMonitorsData.length];
    for (int i = 0; i < lockedMonitorsData.length; i++) {
        CompositeData cdi = lockedMonitorsData[i];
        monitors[i] = MonitorInfo.from(cdi);
    }
    return monitors;
}