use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup in project tdi-studio-se by Talend.
the class MBeanServer method refresh.
/**
* Refreshes the MBean model.
*
* @throws JvmCoreException
*/
protected void refresh() throws JvmCoreException {
if (!checkReachability()) {
return;
}
for (IMonitoredMXBeanGroup group : monitoredAttributeGroups) {
for (IMonitoredMXBeanAttribute attribute : group.getAttributes()) {
String attributeName = attribute.getAttributeName();
Object attributeObject = getAttribute(attribute.getObjectName(), attributeName);
Number value = getAttributeValue(attributeObject, attributeName);
if (value == null) {
continue;
}
// exceptional handling for process CPU time
if (MonitorAttributeName.CPU_TIME.equals(attribute.getAttributeName())) {
if (previousProcessCpuTime == 0) {
previousProcessCpuTime = (Long) value;
continue;
}
Double percent = ((Long) value - previousProcessCpuTime) / 1000000000d;
previousProcessCpuTime = (Long) value;
value = percent > 1 ? 1 : percent;
}
((MonitoredMXBeanAttribute) attribute).add(value, new Date());
}
}
JvmModel.getInstance().fireJvmModelChangeEvent(new JvmModelEvent(State.JvmModified, jvm));
}
use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup in project tdi-studio-se by Talend.
the class RuntimeGraphcsComposite method loadOverviewChartSet.
private void loadOverviewChartSet(IActiveJvm activeJvm) throws JvmCoreException {
final int[] blue = new int[] { 0, 255, 255 };
final int[] red = new int[] { 255, 0, 0 };
final int[] green = new int[] { 0, 255, 0 };
final int[] lightgeen = new int[] { 128, 255, 0 };
final int[] darkRed = new int[] { 255, 0, 128 };
final int[] orange = new int[] { 255, 255, 0 };
IMBeanServer server = activeJvm.getMBeanServer();
server.getMonitoredAttributeGroups().clear();
IMonitoredMXBeanGroup group = server.addMonitoredAttributeGroup(MonitorAttributeName.HEAP_MEMORY, AxisUnit.MBytes);
group.addAttribute(ManagementFactory.MEMORY_MXBEAN_NAME, MonitorAttributeName.HEAP_MEMORY_USE, green);
group.addAttribute(ManagementFactory.MEMORY_MXBEAN_NAME, MonitorAttributeName.HEAP_MEMORY_SIZE, darkRed);
group.addAttribute(ManagementFactory.MEMORY_MXBEAN_NAME, MonitorAttributeName.HEAP_MEMORY_NINTY, blue);
group.addAttribute(ManagementFactory.MEMORY_MXBEAN_NAME, MonitorAttributeName.HEAP_MEMORY_THREE_QUARTER, orange);
group = server.addMonitoredAttributeGroup(MonitorAttributeName.CPU_USE, AxisUnit.Percent);
group.addAttribute(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, MonitorAttributeName.CPU_TIME, lightgeen);
}
use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup in project tdi-studio-se by Talend.
the class RuntimeGraphcsComposite method reconstructCharts.
void reconstructCharts(IActiveJvm activeJvm, boolean connected) {
if (chartsPage.isDisposed()) {
return;
}
if (connected) {
try {
loadOverviewChartSet(activeJvm);
} catch (JvmCoreException e) {
Activator.log(Messages.configureMonitoredAttributesFailedMsg, e);
}
}
List<IMonitoredMXBeanGroup> groups = activeJvm.getMBeanServer().getMonitoredAttributeGroups();
if (groups.size() == 0) {
return;
}
for (TimelineChart chart : charts) {
chart.dispose();
}
charts.clear();
if (chartComposite != null && !chartComposite.isDisposed()) {
chartComposite.dispose();
}
chartComposite = new Composite(chartsPage, SWT.NONE);
FormLayout chartLayout = new FormLayout();
chartLayout.marginHeight = 0;
chartLayout.marginWidth = 0;
chartComposite.setLayout(chartLayout);
FormData chartComData = new FormData();
chartComData.top = new FormAttachment(0, 0);
chartComData.bottom = new FormAttachment(100, 0);
chartComData.left = new FormAttachment(0, 0);
chartComData.right = new FormAttachment(100, 0);
chartComposite.setLayoutData(chartComData);
for (IMonitoredMXBeanGroup group : groups) {
createSection(chartComposite, group);
}
createReportField(chartComposite);
// createInfoField(chartComposite);
chartsPage.layout();
chartsPage.setVisible(true);
refresh();
}
use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup in project tdi-studio-se by Talend.
the class RuntimeGraphcsComposite method refreshReportField.
private void refreshReportField() {
long newAddTime = System.currentTimeMillis();
if (newAddTime - lastAddTime < 10 * 1000) {
return;
}
lastAddTime = newAddTime;
IActiveJvm jvm = getJvm();
List<IMonitoredMXBeanGroup> groups = jvm.getMBeanServer().getMonitoredAttributeGroups();
for (IMonitoredMXBeanGroup group : groups) {
if (group.getName().equals(MonitorAttributeName.HEAP_MEMORY)) {
Number useHeapSize = 0;
Number maxHeapSize = 0;
Date lastDate = null;
for (IMonitoredMXBeanAttribute attribute : group.getAttributes()) {
if (attribute.getAttributeName().equals(MonitorAttributeName.HEAP_MEMORY_USE)) {
List<Number> values = attribute.getValues();
List<Date> dates = attribute.getDates();
if (values.size() > 1) {
useHeapSize = values.get(values.size() - 1);
lastDate = dates.get(dates.size() - 1);
}
} else if (attribute.getAttributeName().equals(MonitorAttributeName.HEAP_MEMORY_SIZE)) {
List<Number> values = attribute.getValues();
List<Date> dates = attribute.getDates();
if (values.size() > 1) {
maxHeapSize = values.get(values.size() - 1);
lastDate = dates.get(dates.size() - 1);
}
}
}
if (lastDate != null) {
if (isRightPercentage(maxHeapSize, useHeapSize)) {
// setNormalReport(lastDate);
} else {
setWarningReport(lastDate);
}
}
}
}
}
use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup in project tdi-studio-se by Talend.
the class TimelineSection method reconstructCharts.
/**
* Reconstructs charts.
* <p>
* When JVM gets connected (e.g. opening Properties view or on already opened Properties view), the default chart
* set will be loaded and applied.
* <p>
* When target JVM is already connected (e.g. opening new Properties view, another JVM gets selected, or monitored
* attributes gets changed), chart configuration will be adapted to the monitored attributes stored in the target
* JVM.
*
* @param activeJvm The JVM
* @param connected True if JVM gets connected
*/
void reconstructCharts(IActiveJvm activeJvm, boolean connected) {
if (chartsPage.isDisposed()) {
return;
}
if (connected) {
try {
loadChartSetAction.loadDefaultChartSet();
} catch (JvmCoreException e) {
Activator.log(Messages.configureMonitoredAttributesFailedMsg, e);
}
}
List<IMonitoredMXBeanGroup> groups = activeJvm.getMBeanServer().getMonitoredAttributeGroups();
if (groups.size() == 0) {
timelinePageBook.showPage(messagePage);
return;
}
timelinePageBook.showPage(chartsPage);
chartsPage.setVisible(false);
for (TimelineChart chart : charts) {
chart.dispose();
}
charts.clear();
if (reportComposite != null && !reportComposite.isDisposed()) {
reportComposite.dispose();
}
GridLayout layout = (GridLayout) chartsPage.getLayout();
layout.numColumns = (groups.size() > 1) ? 2 : 1;
chartsPage.setLayout(layout);
for (IMonitoredMXBeanGroup group : groups) {
if (group.getName().equals(MonitorAttributeName.HEAP_MEMORY)) {
createSection(chartsPage, group);
break;
}
}
createReportField();
for (IMonitoredMXBeanGroup group : groups) {
if (!group.getName().equals(MonitorAttributeName.HEAP_MEMORY)) {
createSection(chartsPage, group);
}
}
chartsPage.layout();
chartsPage.setVisible(true);
refresh();
}
Aggregations