use of org.talend.designer.runtime.visualization.internal.core.cpu.MethodNode in project tdi-studio-se by Talend.
the class MBeanServer method sampleProfilingData.
/**
* Samples the profiling data.
*
* @throws JvmCoreException
*/
void sampleProfilingData() throws JvmCoreException {
if (!checkReachability()) {
return;
}
ThreadMXBean threadMXBean;
try {
threadMXBean = (ThreadMXBean) getMXBean(ThreadMXBean.class, ManagementFactory.THREAD_MXBEAN_NAME);
} catch (IOException e) {
throw new JvmCoreException(IStatus.ERROR, NLS.bind(Messages.getMBeanFailedMsg, ManagementFactory.THREAD_MXBEAN_NAME), e);
}
if (threadMXBean == null) {
throw new JvmCoreException(IStatus.ERROR, NLS.bind(Messages.getMBeanFailedMsg, ManagementFactory.THREAD_MXBEAN_NAME), null);
}
CpuModel cpuModel = (CpuModel) jvm.getCpuProfiler().getCpuModel();
long samplingTime = System.currentTimeMillis();
long actualSamplingPeriodInMilliSeconds;
if (previousSamplingTime == 0) {
actualSamplingPeriodInMilliSeconds = samplingPeriod;
} else {
actualSamplingPeriodInMilliSeconds = samplingTime - previousSamplingTime;
}
Set<String> profiledPackages = jvm.getCpuProfiler().getProfiledPackages();
for (ThreadInfo threadInfo : threadMXBean.dumpAllThreads(true, false)) {
StackTraceElement[] stackTrace = threadInfo.getStackTrace();
String threadName = threadInfo.getThreadName();
if (//$NON-NLS-1$
stackTrace.length > 0 && !threadName.startsWith("JMX ") && !threadName.startsWith("RMI ")) {
//$NON-NLS-1$
ThreadNode<CallTreeNode> callTreeThreadNode = cpuModel.getCallTreeThread(threadName);
ThreadNode<MethodNode> hotSpotThreadNode = cpuModel.getHotSpotThread(threadName);
if (callTreeThreadNode == null) {
callTreeThreadNode = new ThreadNode<CallTreeNode>(threadName);
}
if (hotSpotThreadNode == null) {
hotSpotThreadNode = new ThreadNode<MethodNode>(threadName);
}
updateCpuModel(callTreeThreadNode, hotSpotThreadNode, profiledPackages, invertStackTrace(stackTrace), actualSamplingPeriodInMilliSeconds);
if (callTreeThreadNode.hasChildren()) {
cpuModel.addCallTreeThread(callTreeThreadNode);
}
if (hotSpotThreadNode.hasChildren()) {
cpuModel.addHotSpotThread(hotSpotThreadNode);
}
}
}
previousSamplingTime = samplingTime;
}
use of org.talend.designer.runtime.visualization.internal.core.cpu.MethodNode in project tdi-studio-se by Talend.
the class MBeanServer method updateMethodNode.
/**
* Updates the method node.
*
* @param hotSpotThreadNode The hot spot thread node
* @param methodName The method name
* @param isNewStack True if the given method is a new stack
* @param period The sampling period
*/
private void updateMethodNode(ThreadNode<MethodNode> hotSpotThreadNode, String methodName, boolean isNewStack, long period) {
MethodNode methodNode = (MethodNode) hotSpotThreadNode.getChild(methodName);
if (methodNode == null) {
methodNode = new MethodNode(jvm.getCpuProfiler().getCpuModel(), methodName, hotSpotThreadNode);
hotSpotThreadNode.addChild(methodNode);
}
if (isNewStack) {
methodNode.incrementCount(1);
}
methodNode.incrementTime(period);
}
Aggregations