Java Code Examples for java.lang.management.ThreadMXBean#isThreadContentionMonitoringEnabled()

The following examples show how to use java.lang.management.ThreadMXBean#isThreadContentionMonitoringEnabled() . 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: JvmThreadingImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Getter for the "JvmThreadContentionMonitoring" variable.
 */
public EnumJvmThreadContentionMonitoring getJvmThreadContentionMonitoring()
    throws SnmpStatusException {

    ThreadMXBean mbean = getThreadMXBean();

    if(!mbean.isThreadContentionMonitoringSupported()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Unsupported ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringUnsupported;
    }

    if(mbean.isThreadContentionMonitoringEnabled()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Enabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringEnabled;
    } else {
        log.debug("getJvmThreadContentionMonitoring",
                  "Disabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringDisabled;
    }
}
 
Example 2
Source File: JvmThreadingImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Getter for the "JvmThreadContentionMonitoring" variable.
 */
public EnumJvmThreadContentionMonitoring getJvmThreadContentionMonitoring()
    throws SnmpStatusException {

    ThreadMXBean mbean = getThreadMXBean();

    if(!mbean.isThreadContentionMonitoringSupported()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Unsupported ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringUnsupported;
    }

    if(mbean.isThreadContentionMonitoringEnabled()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Enabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringEnabled;
    } else {
        log.debug("getJvmThreadContentionMonitoring",
                  "Disabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringDisabled;
    }
}
 
Example 3
Source File: JvmThreadingImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Getter for the "JvmThreadContentionMonitoring" variable.
 */
public EnumJvmThreadContentionMonitoring getJvmThreadContentionMonitoring()
    throws SnmpStatusException {

    ThreadMXBean mbean = getThreadMXBean();

    if(!mbean.isThreadContentionMonitoringSupported()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Unsupported ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringUnsupported;
    }

    if(mbean.isThreadContentionMonitoringEnabled()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Enabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringEnabled;
    } else {
        log.debug("getJvmThreadContentionMonitoring",
                  "Disabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringDisabled;
    }
}
 
Example 4
Source File: JvmThreadingImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Getter for the "JvmThreadContentionMonitoring" variable.
 */
public EnumJvmThreadContentionMonitoring getJvmThreadContentionMonitoring()
    throws SnmpStatusException {

    ThreadMXBean mbean = getThreadMXBean();

    if(!mbean.isThreadContentionMonitoringSupported()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Unsupported ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringUnsupported;
    }

    if(mbean.isThreadContentionMonitoringEnabled()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Enabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringEnabled;
    } else {
        log.debug("getJvmThreadContentionMonitoring",
                  "Disabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringDisabled;
    }
}
 
Example 5
Source File: JvmThreadingImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Getter for the "JvmThreadContentionMonitoring" variable.
 */
public EnumJvmThreadContentionMonitoring getJvmThreadContentionMonitoring()
    throws SnmpStatusException {

    ThreadMXBean mbean = getThreadMXBean();

    if(!mbean.isThreadContentionMonitoringSupported()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Unsupported ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringUnsupported;
    }

    if(mbean.isThreadContentionMonitoringEnabled()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Enabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringEnabled;
    } else {
        log.debug("getJvmThreadContentionMonitoring",
                  "Disabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringDisabled;
    }
}
 
Example 6
Source File: JvmThreadingImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Getter for the "JvmThreadContentionMonitoring" variable.
 */
public EnumJvmThreadContentionMonitoring getJvmThreadContentionMonitoring()
    throws SnmpStatusException {

    ThreadMXBean mbean = getThreadMXBean();

    if(!mbean.isThreadContentionMonitoringSupported()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Unsupported ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringUnsupported;
    }

    if(mbean.isThreadContentionMonitoringEnabled()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Enabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringEnabled;
    } else {
        log.debug("getJvmThreadContentionMonitoring",
                  "Disabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringDisabled;
    }
}
 
Example 7
Source File: JvmThreadingImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Getter for the "JvmThreadContentionMonitoring" variable.
 */
public EnumJvmThreadContentionMonitoring getJvmThreadContentionMonitoring()
    throws SnmpStatusException {

    ThreadMXBean mbean = getThreadMXBean();

    if(!mbean.isThreadContentionMonitoringSupported()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Unsupported ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringUnsupported;
    }

    if(mbean.isThreadContentionMonitoringEnabled()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Enabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringEnabled;
    } else {
        log.debug("getJvmThreadContentionMonitoring",
                  "Disabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringDisabled;
    }
}
 
Example 8
Source File: JvmThreadingImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Getter for the "JvmThreadContentionMonitoring" variable.
 */
public EnumJvmThreadContentionMonitoring getJvmThreadContentionMonitoring()
    throws SnmpStatusException {

    ThreadMXBean mbean = getThreadMXBean();

    if(!mbean.isThreadContentionMonitoringSupported()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Unsupported ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringUnsupported;
    }

    if(mbean.isThreadContentionMonitoringEnabled()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Enabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringEnabled;
    } else {
        log.debug("getJvmThreadContentionMonitoring",
                  "Disabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringDisabled;
    }
}
 
Example 9
Source File: JvmThreadingImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Getter for the "JvmThreadContentionMonitoring" variable.
 */
public EnumJvmThreadContentionMonitoring getJvmThreadContentionMonitoring()
    throws SnmpStatusException {

    ThreadMXBean mbean = getThreadMXBean();

    if(!mbean.isThreadContentionMonitoringSupported()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Unsupported ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringUnsupported;
    }

    if(mbean.isThreadContentionMonitoringEnabled()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Enabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringEnabled;
    } else {
        log.debug("getJvmThreadContentionMonitoring",
                  "Disabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringDisabled;
    }
}
 
Example 10
Source File: JvmThreadingImpl.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Getter for the "JvmThreadContentionMonitoring" variable.
 */
public EnumJvmThreadContentionMonitoring getJvmThreadContentionMonitoring()
    throws SnmpStatusException {

    ThreadMXBean mbean = getThreadMXBean();

    if(!mbean.isThreadContentionMonitoringSupported()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Unsupported ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringUnsupported;
    }

    if(mbean.isThreadContentionMonitoringEnabled()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Enabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringEnabled;
    } else {
        log.debug("getJvmThreadContentionMonitoring",
                  "Disabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringDisabled;
    }
}
 
Example 11
Source File: JvmThreadingImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Getter for the "JvmThreadContentionMonitoring" variable.
 */
public EnumJvmThreadContentionMonitoring getJvmThreadContentionMonitoring()
    throws SnmpStatusException {

    ThreadMXBean mbean = getThreadMXBean();

    if(!mbean.isThreadContentionMonitoringSupported()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Unsupported ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringUnsupported;
    }

    if(mbean.isThreadContentionMonitoringEnabled()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Enabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringEnabled;
    } else {
        log.debug("getJvmThreadContentionMonitoring",
                  "Disabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringDisabled;
    }
}
 
Example 12
Source File: JvmThreadingImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Getter for the "JvmThreadContentionMonitoring" variable.
 */
public EnumJvmThreadContentionMonitoring getJvmThreadContentionMonitoring()
    throws SnmpStatusException {

    ThreadMXBean mbean = getThreadMXBean();

    if(!mbean.isThreadContentionMonitoringSupported()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Unsupported ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringUnsupported;
    }

    if(mbean.isThreadContentionMonitoringEnabled()) {
        log.debug("getJvmThreadContentionMonitoring",
                  "Enabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringEnabled;
    } else {
        log.debug("getJvmThreadContentionMonitoring",
                  "Disabled ThreadContentionMonitoring");
        return JvmThreadContentionMonitoringDisabled;
    }
}
 
Example 13
Source File: LiveJvmServiceImpl.java    From glowroot with Apache License 2.0 6 votes vote down vote up
private static Availability getThreadContentionAvailability() {
    ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
    if (!threadMXBean.isThreadContentionMonitoringSupported()) {
        return Availability.newBuilder()
                .setAvailable(false)
                .setReason("java.lang.management.ThreadMXBean"
                        + ".isThreadContentionMonitoringSupported() returned false")
                .build();
    }
    if (!threadMXBean.isThreadContentionMonitoringEnabled()) {
        return Availability.newBuilder()
                .setAvailable(false)
                .setReason("java.lang.management.ThreadMXBean"
                        + ".isThreadContentionMonitoringEnabled() returned false")
                .build();
    }
    return Availability.newBuilder().setAvailable(true).build();
}
 
Example 14
Source File: ThreadDumpProvider.java    From TNT4J with Apache License 2.0 6 votes vote down vote up
@Override
public DumpCollection getDump() {
	Dump dump = new Dump("JavaThreadStack", this);

	ThreadMXBean tmbean = ManagementFactory.getThreadMXBean();
	boolean contentionSupported = tmbean.isThreadContentionMonitoringSupported()
			&& tmbean.isThreadContentionMonitoringEnabled();
	boolean cputSupported = tmbean.isThreadCpuTimeSupported() && tmbean.isThreadCpuTimeEnabled();
	dump.add("java.thread.contention.supported", contentionSupported);
	dump.add("java.thread.cpu.supported", cputSupported);

	long[] dead = tmbean.findMonitorDeadlockedThreads();
	dump.add("java.thread.deadlock.count", dead == null ? 0 : dead.length);

	long[] tids = tmbean.getAllThreadIds();
	ThreadInfo[] tinfos = tmbean.getThreadInfo(tids, Integer.MAX_VALUE);
	for (ThreadInfo ti : tinfos) {
		dump.add(ti.getThreadName() + "-" + ti.getThreadId(), ti);
	}
	return dump;
}
 
Example 15
Source File: QueryMasterRunner.java    From incubator-tajo with Apache License 2.0 5 votes vote down vote up
public static void printThreadInfo(PrintWriter stream, String title) {
  ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
  final int STACK_DEPTH = 60;
  boolean contention = threadBean.isThreadContentionMonitoringEnabled();
  long[] threadIds = threadBean.getAllThreadIds();
  stream.println("Process Thread Dump: " + title);
  stream.println(threadIds.length + " active threads");
  for (long tid : threadIds) {
    ThreadInfo info = threadBean.getThreadInfo(tid, STACK_DEPTH);
    if (info == null) {
      stream.println("  Inactive");
      continue;
    }
    stream.println("Thread " + getTaskName(info.getThreadId(), info.getThreadName()) + ":");
    Thread.State state = info.getThreadState();
    stream.println("  State: " + state);
    stream.println("  Blocked count: " + info.getBlockedCount());
    stream.println("  Waited count: " + info.getWaitedCount());
    if (contention) {
      stream.println("  Blocked time: " + info.getBlockedTime());
      stream.println("  Waited time: " + info.getWaitedTime());
    }
    if (state == Thread.State.WAITING) {
      stream.println("  Waiting on " + info.getLockName());
    } else if (state == Thread.State.BLOCKED) {
      stream.println("  Blocked on " + info.getLockName());
      stream.println("  Blocked by " + getTaskName(info.getLockOwnerId(), info.getLockOwnerName()));
    }
    stream.println("  Stack:");
    for (StackTraceElement frame : info.getStackTrace()) {
      stream.println("    " + frame.toString());
    }
  }
  stream.flush();
}