本文整理了Java中java.lang.management.ThreadMXBean.isThreadCpuTimeEnabled()
方法的一些代码示例,展示了ThreadMXBean.isThreadCpuTimeEnabled()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadMXBean.isThreadCpuTimeEnabled()
方法的具体详情如下:
包路径:java.lang.management.ThreadMXBean
类名称:ThreadMXBean
方法名:isThreadCpuTimeEnabled
暂无
代码示例来源:origin: org.scala-lang/scala-compiler
@Override
public boolean isThreadCpuTimeEnabled() {
return underlying.isThreadCpuTimeEnabled();
}
代码示例来源:origin: apache/incubator-druid
public static boolean isThreadCpuTimeEnabled()
{
return THREAD_MX_BEAN.isThreadCpuTimeSupported() && THREAD_MX_BEAN.isThreadCpuTimeEnabled();
}
代码示例来源:origin: apache/hive
public static ThreadMXBean initThreadMxBean() {
ThreadMXBean mxBean = ManagementFactory.getThreadMXBean();
if (mxBean != null) {
if (!mxBean.isCurrentThreadCpuTimeSupported()) {
LOG.warn("Thread CPU monitoring is not supported");
return null;
} else if (!mxBean.isThreadCpuTimeEnabled()) {
LOG.warn("Thread CPU monitoring is not enabled");
return null;
}
}
return mxBean;
}
代码示例来源:origin: neo4j/neo4j
@Override
public long cpuTimeNanos( long threadId )
{
if ( !threadMXBean.isThreadCpuTimeSupported() )
{
return -1;
}
if ( !threadMXBean.isThreadCpuTimeEnabled() )
{
threadMXBean.setThreadCpuTimeEnabled( true );
}
return threadMXBean.getThreadCpuTime( threadId );
}
};
代码示例来源:origin: Netflix/servo
if (bean.isThreadCpuTimeEnabled()) {
代码示例来源:origin: javamelody/javamelody
&& threadBean.isThreadCpuTimeEnabled();
final long[] deadlockedThreads = getDeadlockedThreads(threadBean);
final List<ThreadInformations> threadInfosList = new ArrayList<ThreadInformations>(
代码示例来源:origin: apache/hive
private void updateThreadMetrics(MetricsRecordBuilder rb) {
if (threadMXBean.isThreadCpuTimeSupported() && threadMXBean.isThreadCpuTimeEnabled()) {
final long[] ids = threadMXBean.getAllThreadIds();
final ThreadInfo[] infos = threadMXBean.getThreadInfo(ids);
for (int i = 0; i < ids.length; i++) {
ThreadInfo threadInfo = infos[i];
if (threadInfo == null) {
continue;
}
String threadName = threadInfo.getThreadName();
long threadId = ids[i];
Integer id = executorNames.get(threadName);
if (id != null) {
executorThreadCpuTime[id].set(threadMXBean.getThreadCpuTime(threadId));
executorThreadUserTime[id].set(threadMXBean.getThreadUserTime(threadId));
}
}
for (int i=0; i<numExecutors; i++) {
rb.addGauge(cpuMetricsInfoMap.get(i), executorThreadCpuTime[i].value());
rb.addGauge(userMetricsInfoMap.get(i), executorThreadUserTime[i].value());
}
}
}
代码示例来源:origin: mpusher/mpush
public static void jstack(OutputStream stream) throws Exception {
PrintStream out = new PrintStream(stream);
boolean cpuTimeEnabled = threadMXBean.isThreadCpuTimeSupported() && threadMXBean.isThreadCpuTimeEnabled();
Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces();
代码示例来源:origin: apache/geode
s.setLong(thread_waitedTimeId, ti.getWaitedTime());
if (threadBean.isThreadCpuTimeSupported() && threadBean.isThreadCpuTimeEnabled()) {
s.setLong(thread_cpuTimeId, threadBean.getThreadCpuTime(id));
s.setLong(thread_userTimeId, threadBean.getThreadUserTime(id));
代码示例来源:origin: codefollower/Tomcat-Research
/**
* Check whether thread cpu time measurement is enabled.
*
* @return true if thread cpu time measurement is enabled
*/
public static boolean isThreadCpuTimeEnabled() {
return threadMXBean.isThreadCpuTimeEnabled();
}
代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core
/**
* Check whether thread cpu time measurement is enabled.
*
* @return true if thread cpu time measurement is enabled
*/
public static boolean isThreadCpuTimeEnabled() {
return threadMXBean.isThreadCpuTimeEnabled();
}
代码示例来源:origin: glowroot/glowroot
private static Availability getThreadCpuTimeAvailability() {
ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
if (!threadMXBean.isThreadCpuTimeSupported()) {
return Availability.newBuilder()
.setAvailable(false)
.setReason("java.lang.management.ThreadMXBean"
+ ".isThreadCpuTimeSupported() returned false")
.build();
}
if (!threadMXBean.isThreadCpuTimeEnabled()) {
return Availability.newBuilder()
.setAvailable(false)
.setReason("java.lang.management.ThreadMXBean"
+ ".isThreadCpuTimeEnabled() returned false")
.build();
}
return Availability.newBuilder().setAvailable(true).build();
}
代码示例来源:origin: com.atlassian.jira/jira-core
public boolean isThreadCpuTimeEnabled()
{
return ManagementFactory.getThreadMXBean().isThreadCpuTimeEnabled();
}
}
代码示例来源:origin: matsim-org/matsim
/**
* @param thread
* @return cpu time for the given thread in seconds, <code>-1</code> if cpu time is not measured.
*/
public static final double getThreadCpuTime(final Thread thread) {
if (tbe.isThreadCpuTimeEnabled()) {
return tbe.getThreadCpuTime(thread.getId()) / 1.0e9;
}
return -1;
}
代码示例来源:origin: matsim-org/matsim
/**
* Prints the cpu time for the given thread, i.e. the time the thread was effectively active on the CPU.
*
* @param thread
*/
public static final void printThreadCpuTime(final Thread thread) {
if (tbe.isThreadCpuTimeEnabled()) {
log.info("Thread performance: Thread=" + thread.getName() + " cpu-time=" + getThreadCpuTime(thread) + "sec");
}
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
public ThreadCpuTimer() {
active = threadMXBean.isThreadCpuTimeSupported()
&& threadMXBean.isThreadCpuTimeEnabled()
&& LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.DETAIL);
}
代码示例来源:origin: org.teiid/teiid-engine
public ThreadCpuTimer() {
active = threadMXBean.isThreadCpuTimeSupported()
&& threadMXBean.isThreadCpuTimeEnabled()
&& LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.DETAIL);
}
代码示例来源:origin: teiid/teiid
public ThreadCpuTimer() {
active = threadMXBean.isThreadCpuTimeSupported()
&& threadMXBean.isThreadCpuTimeEnabled()
&& LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.DETAIL);
}
代码示例来源:origin: inspectIT/inspectIT
@BeforeMethod
public void initTestClass() {
Map<String, Object> settings = new HashMap<String, Object>();
when(threadMXBean.isThreadCpuTimeEnabled()).thenReturn(true);
when(threadMXBean.isThreadCpuTimeSupported()).thenReturn(true);
timerHook = new TimerHook(timer, platformManager, propertyAccessor, settings, threadMXBean);
}
代码示例来源:origin: inspectIT/inspectIT
@BeforeMethod
public void initTestClass() {
Map<String, String> settings = new HashMap<String, String>();
settings.put("sessioncapture", "false");
when(threadMXBean.isThreadCpuTimeEnabled()).thenReturn(true);
when(threadMXBean.isThreadCpuTimeSupported()).thenReturn(true);
Map<String, Object> map = new HashMap<String, Object>();
MapUtils.putAll(map, new String[][] { { "sessioncapture", "true" }, { "attributescapture", "true" }, { "parameterscapture", "true" } });
httpHook = new HttpHook(timer, platformManager, map, threadMXBean);
}
内容来源于网络,如有侵权,请联系作者删除!