Java Code Examples for java.lang.management.ThreadMXBean#resetPeakThreadCount()
The following examples show how to use
java.lang.management.ThreadMXBean#resetPeakThreadCount() .
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: ThreadSensor.java From swage with Apache License 2.0 | 6 votes |
@Override public void sense(final MetricContext metricContext) { ThreadMXBean mxBean = ManagementFactory.getThreadMXBean(); int current = mxBean.getThreadCount(); int peak = mxBean.getPeakThreadCount(); if (peak > historicalPeak) { historicalPeak = peak; } metricContext.record(THREADS, current, Unit.NONE); metricContext.record(PERIODIC_PEAK_THREADS, peak, Unit.NONE); metricContext.record(PEAK_THREADS, historicalPeak, Unit.NONE); mxBean.resetPeakThreadCount(); }
Example 2
Source File: ThreadDumperTest.java From cougar with Apache License 2.0 | 5 votes |
public void testGeneralResponse() { ThreadMXBean mx = ManagementFactory.getThreadMXBean(); mx.resetPeakThreadCount(); Map<String, String> params = new HashMap<String, String>(); String value = new ThreadDumper().process(params); assertTrue(value.contains("All threads:")); assertTrue(value.contains("Live thread count:")); assertTrue(value.contains("Report generated at ")); }
Example 3
Source File: MXBeanInteropTest1.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
private final int doThreadMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- ThreadMXBean") ; try { ObjectName threadName = new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME) ; MBeanInfo mbInfo = mbsc.getMBeanInfo(threadName); errorCount += checkNonEmpty(mbInfo); System.out.println("getMBeanInfo\t\t" + mbInfo); ThreadMXBean thread = null ; thread = JMX.newMXBeanProxy(mbsc, threadName, ThreadMXBean.class) ; System.out.println("findMonitorDeadlockedThreads\t\t" + thread.findMonitorDeadlockedThreads()); long[] threadIDs = thread.getAllThreadIds() ; System.out.println("getAllThreadIds\t\t" + threadIDs); for ( long threadID : threadIDs ) { System.out.println("getThreadInfo long\t\t" + thread.getThreadInfo(threadID)); System.out.println("getThreadInfo long, int\t\t" + thread.getThreadInfo(threadID, 2)); } System.out.println("getThreadInfo long[]\t\t" + thread.getThreadInfo(threadIDs)); System.out.println("getThreadInfo long[], int\t\t" + thread.getThreadInfo(threadIDs, 2)); System.out.println("getDaemonThreadCount\t\t" + thread.getDaemonThreadCount()); System.out.println("getPeakThreadCount\t\t" + thread.getPeakThreadCount()); System.out.println("getThreadCount\t\t" + thread.getThreadCount()); System.out.println("getTotalStartedThreadCount\t\t" + thread.getTotalStartedThreadCount()); boolean supported = thread.isThreadContentionMonitoringSupported() ; System.out.println("isThreadContentionMonitoringSupported\t\t" + supported); if ( supported ) { System.out.println("isThreadContentionMonitoringEnabled\t\t" + thread.isThreadContentionMonitoringEnabled()); } supported = thread.isThreadCpuTimeSupported() ; System.out.println("isThreadCpuTimeSupported\t\t" + supported); if ( supported ) { System.out.println("isThreadCpuTimeEnabled\t\t" + thread.isThreadCpuTimeEnabled()); for (long id : threadIDs) { System.out.println("getThreadCpuTime(" + id + ")\t\t" + thread.getThreadCpuTime(id)); System.out.println("getThreadUserTime(" + id + ")\t\t" + thread.getThreadUserTime(id)); } } supported = thread.isCurrentThreadCpuTimeSupported() ; System.out.println("isCurrentThreadCpuTimeSupported\t\t" + supported); if ( supported ) { System.out.println("getCurrentThreadCpuTime\t\t" + thread.getCurrentThreadCpuTime()); System.out.println("getCurrentThreadUserTime\t\t" + thread.getCurrentThreadUserTime()); } thread.resetPeakThreadCount() ; System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }
Example 4
Source File: MXBeanInteropTest1.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private final int doThreadMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- ThreadMXBean") ; try { ObjectName threadName = new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME) ; MBeanInfo mbInfo = mbsc.getMBeanInfo(threadName); errorCount += checkNonEmpty(mbInfo); System.out.println("getMBeanInfo\t\t" + mbInfo); ThreadMXBean thread = null ; thread = JMX.newMXBeanProxy(mbsc, threadName, ThreadMXBean.class) ; System.out.println("findMonitorDeadlockedThreads\t\t" + thread.findMonitorDeadlockedThreads()); long[] threadIDs = thread.getAllThreadIds() ; System.out.println("getAllThreadIds\t\t" + threadIDs); for ( long threadID : threadIDs ) { System.out.println("getThreadInfo long\t\t" + thread.getThreadInfo(threadID)); System.out.println("getThreadInfo long, int\t\t" + thread.getThreadInfo(threadID, 2)); } System.out.println("getThreadInfo long[]\t\t" + thread.getThreadInfo(threadIDs)); System.out.println("getThreadInfo long[], int\t\t" + thread.getThreadInfo(threadIDs, 2)); System.out.println("getDaemonThreadCount\t\t" + thread.getDaemonThreadCount()); System.out.println("getPeakThreadCount\t\t" + thread.getPeakThreadCount()); System.out.println("getThreadCount\t\t" + thread.getThreadCount()); System.out.println("getTotalStartedThreadCount\t\t" + thread.getTotalStartedThreadCount()); boolean supported = thread.isThreadContentionMonitoringSupported() ; System.out.println("isThreadContentionMonitoringSupported\t\t" + supported); if ( supported ) { System.out.println("isThreadContentionMonitoringEnabled\t\t" + thread.isThreadContentionMonitoringEnabled()); } supported = thread.isThreadCpuTimeSupported() ; System.out.println("isThreadCpuTimeSupported\t\t" + supported); if ( supported ) { System.out.println("isThreadCpuTimeEnabled\t\t" + thread.isThreadCpuTimeEnabled()); for (long id : threadIDs) { System.out.println("getThreadCpuTime(" + id + ")\t\t" + thread.getThreadCpuTime(id)); System.out.println("getThreadUserTime(" + id + ")\t\t" + thread.getThreadUserTime(id)); } } supported = thread.isCurrentThreadCpuTimeSupported() ; System.out.println("isCurrentThreadCpuTimeSupported\t\t" + supported); if ( supported ) { System.out.println("getCurrentThreadCpuTime\t\t" + thread.getCurrentThreadCpuTime()); System.out.println("getCurrentThreadUserTime\t\t" + thread.getCurrentThreadUserTime()); } thread.resetPeakThreadCount() ; System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }
Example 5
Source File: MXBeanInteropTest1.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private final int doThreadMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- ThreadMXBean") ; try { ObjectName threadName = new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME) ; MBeanInfo mbInfo = mbsc.getMBeanInfo(threadName); errorCount += checkNonEmpty(mbInfo); System.out.println("getMBeanInfo\t\t" + mbInfo); ThreadMXBean thread = null ; thread = JMX.newMXBeanProxy(mbsc, threadName, ThreadMXBean.class) ; System.out.println("findMonitorDeadlockedThreads\t\t" + thread.findMonitorDeadlockedThreads()); long[] threadIDs = thread.getAllThreadIds() ; System.out.println("getAllThreadIds\t\t" + threadIDs); for ( long threadID : threadIDs ) { System.out.println("getThreadInfo long\t\t" + thread.getThreadInfo(threadID)); System.out.println("getThreadInfo long, int\t\t" + thread.getThreadInfo(threadID, 2)); } System.out.println("getThreadInfo long[]\t\t" + thread.getThreadInfo(threadIDs)); System.out.println("getThreadInfo long[], int\t\t" + thread.getThreadInfo(threadIDs, 2)); System.out.println("getDaemonThreadCount\t\t" + thread.getDaemonThreadCount()); System.out.println("getPeakThreadCount\t\t" + thread.getPeakThreadCount()); System.out.println("getThreadCount\t\t" + thread.getThreadCount()); System.out.println("getTotalStartedThreadCount\t\t" + thread.getTotalStartedThreadCount()); boolean supported = thread.isThreadContentionMonitoringSupported() ; System.out.println("isThreadContentionMonitoringSupported\t\t" + supported); if ( supported ) { System.out.println("isThreadContentionMonitoringEnabled\t\t" + thread.isThreadContentionMonitoringEnabled()); } supported = thread.isThreadCpuTimeSupported() ; System.out.println("isThreadCpuTimeSupported\t\t" + supported); if ( supported ) { System.out.println("isThreadCpuTimeEnabled\t\t" + thread.isThreadCpuTimeEnabled()); for (long id : threadIDs) { System.out.println("getThreadCpuTime(" + id + ")\t\t" + thread.getThreadCpuTime(id)); System.out.println("getThreadUserTime(" + id + ")\t\t" + thread.getThreadUserTime(id)); } } supported = thread.isCurrentThreadCpuTimeSupported() ; System.out.println("isCurrentThreadCpuTimeSupported\t\t" + supported); if ( supported ) { System.out.println("getCurrentThreadCpuTime\t\t" + thread.getCurrentThreadCpuTime()); System.out.println("getCurrentThreadUserTime\t\t" + thread.getCurrentThreadUserTime()); } thread.resetPeakThreadCount() ; System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }
Example 6
Source File: MXBeanInteropTest1.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private final int doThreadMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- ThreadMXBean") ; try { ObjectName threadName = new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME) ; MBeanInfo mbInfo = mbsc.getMBeanInfo(threadName); errorCount += checkNonEmpty(mbInfo); System.out.println("getMBeanInfo\t\t" + mbInfo); ThreadMXBean thread = null ; thread = JMX.newMXBeanProxy(mbsc, threadName, ThreadMXBean.class) ; System.out.println("findMonitorDeadlockedThreads\t\t" + thread.findMonitorDeadlockedThreads()); long[] threadIDs = thread.getAllThreadIds() ; System.out.println("getAllThreadIds\t\t" + threadIDs); for ( long threadID : threadIDs ) { System.out.println("getThreadInfo long\t\t" + thread.getThreadInfo(threadID)); System.out.println("getThreadInfo long, int\t\t" + thread.getThreadInfo(threadID, 2)); } System.out.println("getThreadInfo long[]\t\t" + thread.getThreadInfo(threadIDs)); System.out.println("getThreadInfo long[], int\t\t" + thread.getThreadInfo(threadIDs, 2)); System.out.println("getDaemonThreadCount\t\t" + thread.getDaemonThreadCount()); System.out.println("getPeakThreadCount\t\t" + thread.getPeakThreadCount()); System.out.println("getThreadCount\t\t" + thread.getThreadCount()); System.out.println("getTotalStartedThreadCount\t\t" + thread.getTotalStartedThreadCount()); boolean supported = thread.isThreadContentionMonitoringSupported() ; System.out.println("isThreadContentionMonitoringSupported\t\t" + supported); if ( supported ) { System.out.println("isThreadContentionMonitoringEnabled\t\t" + thread.isThreadContentionMonitoringEnabled()); } supported = thread.isThreadCpuTimeSupported() ; System.out.println("isThreadCpuTimeSupported\t\t" + supported); if ( supported ) { System.out.println("isThreadCpuTimeEnabled\t\t" + thread.isThreadCpuTimeEnabled()); for (long id : threadIDs) { System.out.println("getThreadCpuTime(" + id + ")\t\t" + thread.getThreadCpuTime(id)); System.out.println("getThreadUserTime(" + id + ")\t\t" + thread.getThreadUserTime(id)); } } supported = thread.isCurrentThreadCpuTimeSupported() ; System.out.println("isCurrentThreadCpuTimeSupported\t\t" + supported); if ( supported ) { System.out.println("getCurrentThreadCpuTime\t\t" + thread.getCurrentThreadCpuTime()); System.out.println("getCurrentThreadUserTime\t\t" + thread.getCurrentThreadUserTime()); } thread.resetPeakThreadCount() ; System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }
Example 7
Source File: MXBeanInteropTest1.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private final int doThreadMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- ThreadMXBean") ; try { ObjectName threadName = new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME) ; MBeanInfo mbInfo = mbsc.getMBeanInfo(threadName); errorCount += checkNonEmpty(mbInfo); System.out.println("getMBeanInfo\t\t" + mbInfo); ThreadMXBean thread = null ; thread = JMX.newMXBeanProxy(mbsc, threadName, ThreadMXBean.class) ; System.out.println("findMonitorDeadlockedThreads\t\t" + thread.findMonitorDeadlockedThreads()); long[] threadIDs = thread.getAllThreadIds() ; System.out.println("getAllThreadIds\t\t" + threadIDs); for ( long threadID : threadIDs ) { System.out.println("getThreadInfo long\t\t" + thread.getThreadInfo(threadID)); System.out.println("getThreadInfo long, int\t\t" + thread.getThreadInfo(threadID, 2)); } System.out.println("getThreadInfo long[]\t\t" + thread.getThreadInfo(threadIDs)); System.out.println("getThreadInfo long[], int\t\t" + thread.getThreadInfo(threadIDs, 2)); System.out.println("getDaemonThreadCount\t\t" + thread.getDaemonThreadCount()); System.out.println("getPeakThreadCount\t\t" + thread.getPeakThreadCount()); System.out.println("getThreadCount\t\t" + thread.getThreadCount()); System.out.println("getTotalStartedThreadCount\t\t" + thread.getTotalStartedThreadCount()); boolean supported = thread.isThreadContentionMonitoringSupported() ; System.out.println("isThreadContentionMonitoringSupported\t\t" + supported); if ( supported ) { System.out.println("isThreadContentionMonitoringEnabled\t\t" + thread.isThreadContentionMonitoringEnabled()); } supported = thread.isThreadCpuTimeSupported() ; System.out.println("isThreadCpuTimeSupported\t\t" + supported); if ( supported ) { System.out.println("isThreadCpuTimeEnabled\t\t" + thread.isThreadCpuTimeEnabled()); for (long id : threadIDs) { System.out.println("getThreadCpuTime(" + id + ")\t\t" + thread.getThreadCpuTime(id)); System.out.println("getThreadUserTime(" + id + ")\t\t" + thread.getThreadUserTime(id)); } } supported = thread.isCurrentThreadCpuTimeSupported() ; System.out.println("isCurrentThreadCpuTimeSupported\t\t" + supported); if ( supported ) { System.out.println("getCurrentThreadCpuTime\t\t" + thread.getCurrentThreadCpuTime()); System.out.println("getCurrentThreadUserTime\t\t" + thread.getCurrentThreadUserTime()); } thread.resetPeakThreadCount() ; System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }
Example 8
Source File: MXBeanInteropTest1.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private final int doThreadMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- ThreadMXBean") ; try { ObjectName threadName = new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME) ; MBeanInfo mbInfo = mbsc.getMBeanInfo(threadName); errorCount += checkNonEmpty(mbInfo); System.out.println("getMBeanInfo\t\t" + mbInfo); ThreadMXBean thread = null ; thread = JMX.newMXBeanProxy(mbsc, threadName, ThreadMXBean.class) ; System.out.println("findMonitorDeadlockedThreads\t\t" + thread.findMonitorDeadlockedThreads()); long[] threadIDs = thread.getAllThreadIds() ; System.out.println("getAllThreadIds\t\t" + threadIDs); for ( long threadID : threadIDs ) { System.out.println("getThreadInfo long\t\t" + thread.getThreadInfo(threadID)); System.out.println("getThreadInfo long, int\t\t" + thread.getThreadInfo(threadID, 2)); } System.out.println("getThreadInfo long[]\t\t" + thread.getThreadInfo(threadIDs)); System.out.println("getThreadInfo long[], int\t\t" + thread.getThreadInfo(threadIDs, 2)); System.out.println("getDaemonThreadCount\t\t" + thread.getDaemonThreadCount()); System.out.println("getPeakThreadCount\t\t" + thread.getPeakThreadCount()); System.out.println("getThreadCount\t\t" + thread.getThreadCount()); System.out.println("getTotalStartedThreadCount\t\t" + thread.getTotalStartedThreadCount()); boolean supported = thread.isThreadContentionMonitoringSupported() ; System.out.println("isThreadContentionMonitoringSupported\t\t" + supported); if ( supported ) { System.out.println("isThreadContentionMonitoringEnabled\t\t" + thread.isThreadContentionMonitoringEnabled()); } supported = thread.isThreadCpuTimeSupported() ; System.out.println("isThreadCpuTimeSupported\t\t" + supported); if ( supported ) { System.out.println("isThreadCpuTimeEnabled\t\t" + thread.isThreadCpuTimeEnabled()); for (long id : threadIDs) { System.out.println("getThreadCpuTime(" + id + ")\t\t" + thread.getThreadCpuTime(id)); System.out.println("getThreadUserTime(" + id + ")\t\t" + thread.getThreadUserTime(id)); } } supported = thread.isCurrentThreadCpuTimeSupported() ; System.out.println("isCurrentThreadCpuTimeSupported\t\t" + supported); if ( supported ) { System.out.println("getCurrentThreadCpuTime\t\t" + thread.getCurrentThreadCpuTime()); System.out.println("getCurrentThreadUserTime\t\t" + thread.getCurrentThreadUserTime()); } thread.resetPeakThreadCount() ; System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }
Example 9
Source File: MXBeanInteropTest1.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
private final int doThreadMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- ThreadMXBean") ; try { ObjectName threadName = new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME) ; MBeanInfo mbInfo = mbsc.getMBeanInfo(threadName); errorCount += checkNonEmpty(mbInfo); System.out.println("getMBeanInfo\t\t" + mbInfo); ThreadMXBean thread = null ; thread = JMX.newMXBeanProxy(mbsc, threadName, ThreadMXBean.class) ; System.out.println("findMonitorDeadlockedThreads\t\t" + thread.findMonitorDeadlockedThreads()); long[] threadIDs = thread.getAllThreadIds() ; System.out.println("getAllThreadIds\t\t" + threadIDs); for ( long threadID : threadIDs ) { System.out.println("getThreadInfo long\t\t" + thread.getThreadInfo(threadID)); System.out.println("getThreadInfo long, int\t\t" + thread.getThreadInfo(threadID, 2)); } System.out.println("getThreadInfo long[]\t\t" + thread.getThreadInfo(threadIDs)); System.out.println("getThreadInfo long[], int\t\t" + thread.getThreadInfo(threadIDs, 2)); System.out.println("getDaemonThreadCount\t\t" + thread.getDaemonThreadCount()); System.out.println("getPeakThreadCount\t\t" + thread.getPeakThreadCount()); System.out.println("getThreadCount\t\t" + thread.getThreadCount()); System.out.println("getTotalStartedThreadCount\t\t" + thread.getTotalStartedThreadCount()); boolean supported = thread.isThreadContentionMonitoringSupported() ; System.out.println("isThreadContentionMonitoringSupported\t\t" + supported); if ( supported ) { System.out.println("isThreadContentionMonitoringEnabled\t\t" + thread.isThreadContentionMonitoringEnabled()); } supported = thread.isThreadCpuTimeSupported() ; System.out.println("isThreadCpuTimeSupported\t\t" + supported); if ( supported ) { System.out.println("isThreadCpuTimeEnabled\t\t" + thread.isThreadCpuTimeEnabled()); for (long id : threadIDs) { System.out.println("getThreadCpuTime(" + id + ")\t\t" + thread.getThreadCpuTime(id)); System.out.println("getThreadUserTime(" + id + ")\t\t" + thread.getThreadUserTime(id)); } } supported = thread.isCurrentThreadCpuTimeSupported() ; System.out.println("isCurrentThreadCpuTimeSupported\t\t" + supported); if ( supported ) { System.out.println("getCurrentThreadCpuTime\t\t" + thread.getCurrentThreadCpuTime()); System.out.println("getCurrentThreadUserTime\t\t" + thread.getCurrentThreadUserTime()); } thread.resetPeakThreadCount() ; System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }