use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute in project tdi-studio-se by Talend.
the class ConfigChartAction method getAttributes.
/**
* Gets the attributes.
*
* @return The attributes
*/
private List<MBeanAttribute> getAttributes() {
List<MBeanAttribute> attributes = new ArrayList<MBeanAttribute>();
for (IMonitoredMXBeanAttribute attribute : chart.getAttributeGroup().getAttributes()) {
ObjectName objectName = attribute.getObjectName();
String attributeName = attribute.getAttributeName();
int[] rgb = attribute.getRGB();
attributes.add(new MBeanAttribute(objectName, attributeName, new RGB(rgb[0], rgb[1], rgb[2])));
}
return attributes;
}
use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute in project tdi-studio-se by Talend.
the class ConfigChartAction method performConfiguration.
/**
* Performs the configuration.
*
* @param chartTitle The chart title
* @param axisUnit The axis unit
* @param attributes The attributes
* @param removedAttributes The removed attributes
*/
private void performConfiguration(String chartTitle, AxisUnit axisUnit, List<MBeanAttribute> attributes, List<MBeanAttribute> removedAttributes) {
IMonitoredMXBeanGroup group = chart.getAttributeGroup();
group.setName(chartTitle);
group.setAxisUnit(axisUnit);
for (MBeanAttribute attribute : attributes) {
ObjectName objectName = attribute.getObjectName();
String attributeName = attribute.getAttributeName();
IMonitoredMXBeanAttribute monitoredAttribute = group.getAttribute(objectName, attributeName);
RGB rgb = attribute.getRgb();
if (monitoredAttribute == null) {
try {
group.addAttribute(objectName.getCanonicalName(), attributeName, new int[] { rgb.red, rgb.green, rgb.blue });
} catch (JvmCoreException e) {
Activator.log(Messages.addAttributeFailedMsg, e);
}
} else {
monitoredAttribute.setRGB(rgb.red, rgb.green, rgb.blue);
}
}
for (MBeanAttribute removedAttribute : removedAttributes) {
group.removeAttribute(removedAttribute.getObjectName().getCanonicalName(), removedAttribute.getAttributeName());
}
chart.refresh();
}
use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute in project tdi-studio-se by Talend.
the class ConfigureChartAction method getAttributes.
/**
* Gets the attributes.
*
* @return The attributes
*/
private List<MBeanAttribute> getAttributes() {
List<MBeanAttribute> attributes = new ArrayList<MBeanAttribute>();
for (IMonitoredMXBeanAttribute attribute : chart.getAttributeGroup().getAttributes()) {
ObjectName objectName = attribute.getObjectName();
String attributeName = attribute.getAttributeName();
int[] rgb = attribute.getRGB();
attributes.add(new MBeanAttribute(objectName, attributeName, new RGB(rgb[0], rgb[1], rgb[2])));
}
return attributes;
}
use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute 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.IMonitoredMXBeanAttribute 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);
}
}
}
}
}
Aggregations