use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup in project tdi-studio-se by Talend.
the class TimelineSection method refreshReportField.
/**
* Refreshes the report field.
*/
private void refreshReportField() {
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 {
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);
}
}
// Number diff = getDiff(maxHeapSize, useHeapSize);
// if (diff instanceof Integer) {
// int value = diff.intValue();
// if (value <= 200) {
// setWarningReport(lastDate);
// } else {
// setNormalReport(lastDate);
// }
// } else if (diff instanceof Long) {
// long value = diff.longValue();
// if (value <= 200) {
// setWarningReport(lastDate);
// } else {
// setNormalReport(lastDate);
// }
// } else if (diff instanceof Double) {
// double value = diff.doubleValue();
// if (value <= 200) {
// setWarningReport(lastDate);
// } else {
// setNormalReport(lastDate);
// }
// }
}
}
}
use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup in project tdi-studio-se by Talend.
the class NewChartAction method performNew.
/**
* Performs creating a new chart.
*
* @param chartTitle The chart title
* @param axisUnit The axis unit
* @param attributes The attributes
* @param jvm The jvm
*/
private static void performNew(String chartTitle, AxisUnit axisUnit, List<MBeanAttribute> attributes, IActiveJvm jvm) {
IMonitoredMXBeanGroup group = jvm.getMBeanServer().addMonitoredAttributeGroup(chartTitle, axisUnit);
for (MBeanAttribute attribute : attributes) {
ObjectName objectName = attribute.getObjectName();
String attributeName = attribute.getAttributeName();
RGB rgb = attribute.getRgb();
try {
group.addAttribute(objectName.getCanonicalName(), attributeName, new int[] { rgb.red, rgb.green, rgb.blue });
} catch (JvmCoreException e) {
Activator.log(Messages.addAttributeFailedMsg, e);
}
}
}
use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup in project tdi-studio-se by Talend.
the class SaveChartSetAsAction method addNewChartSet.
/**
* Adds the new chart set to the given memento.
*
* @param memento The memento
* @param chartSet The new chart set
*/
private void addNewChartSet(XMLMemento memento, String chartSet) {
IMemento chartSetMemento = memento.createChild(CHART_SET, chartSet);
for (IMonitoredMXBeanGroup group : section.getJvm().getMBeanServer().getMonitoredAttributeGroups()) {
IMemento groupMemento = chartSetMemento.createChild(GROUP, group.getName());
groupMemento.putString(UNIT, group.getAxisUnit().name());
for (IMonitoredMXBeanAttribute attribute : group.getAttributes()) {
IMemento attributeMemento = groupMemento.createChild(ATTRIBUTE, attribute.getAttributeName());
attributeMemento.putString(OBJECT_NAME, attribute.getObjectName().getCanonicalName());
attributeMemento.putString(COLOR, getRGBString(attribute.getRGB()));
}
}
}
use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup in project tdi-studio-se by Talend.
the class LoadChartAction method loadOverviewChartSet.
/**
* Loads the overview chart set.
*
* @throws JvmCoreException
*/
private void loadOverviewChartSet() throws JvmCoreException {
final int[] blue = new int[] { 0, 0, 255 };
final int[] red = new int[] { 255, 0, 0 };
final int[] green = new int[] { 0, 255, 0 };
final int[] orange = new int[] { 255, 128, 0 };
IMBeanServer server = graphComposite.getJvm().getMBeanServer();
server.getMonitoredAttributeGroups().clear();
//$NON-NLS-1$
IMonitoredMXBeanGroup group = server.addMonitoredAttributeGroup("Used Heap Memory", AxisUnit.MBytes);
//$NON-NLS-1$
group.addAttribute(ManagementFactory.MEMORY_MXBEAN_NAME, "HeapMemoryUsage.used", blue);
//$NON-NLS-1$
group.addAttribute(ManagementFactory.MEMORY_MXBEAN_NAME, "HeapMemoryUsage.maxsize", red);
// group = server.addMonitoredAttributeGroup("Loaded Class Count", AxisUnit.Count); //$NON-NLS-1$
// group.addAttribute(ManagementFactory.CLASS_LOADING_MXBEAN_NAME, "LoadedClassCount", blue); //$NON-NLS-1$
// group = server.addMonitoredAttributeGroup("Thread Count", AxisUnit.Count); //$NON-NLS-1$
// group.addAttribute(ManagementFactory.THREAD_MXBEAN_NAME, "ThreadCount", //$NON-NLS-1$
// orange);
//$NON-NLS-1$
group = server.addMonitoredAttributeGroup("CPU Usage", AxisUnit.Percent);
//$NON-NLS-1$
group.addAttribute(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, "ProcessCpuTime", green);
}
use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup in project tdi-studio-se by Talend.
the class LoadChartAction method loadChartSet.
/**
* Loads the given memento of chart set.
*
* @param memento The memento
* @throws JvmCoreException
*/
private void loadChartSet(IMemento memento) throws JvmCoreException {
IMBeanServer server = graphComposite.getJvm().getMBeanServer();
server.getMonitoredAttributeGroups().clear();
StringBuffer buffer = new StringBuffer();
for (IMemento groupMemento : memento.getChildren(GROUP)) {
IMonitoredMXBeanGroup group = server.addMonitoredAttributeGroup(groupMemento.getID(), AxisUnit.valueOf(groupMemento.getString(UNIT)));
for (IMemento attributeMemento : groupMemento.getChildren(ATTRIBUTE)) {
String objectName = attributeMemento.getString(OBJECT_NAME);
String attributeName = attributeMemento.getID();
if (attributeExist(objectName, attributeName)) {
group.addAttribute(objectName, attributeName, getRGB(attributeMemento.getString(COLOR)));
} else {
buffer.append('\n');
buffer.append(objectName + ':' + attributeName);
}
}
}
if (buffer.length() > 0) {
MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.errorDialogTitle, NLS.bind(Messages.attributeNotSupportedMsg, buffer.toString()));
}
}
Aggregations