use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute in project tdi-studio-se by Talend.
the class TimelineSection method createSection.
/**
* Creates the section.
*
* @param parent The parent composite
* @param group The attribute group
*/
private void createSection(Composite parent, IMonitoredMXBeanGroup group) {
if (parent.isDisposed()) {
return;
}
ExpandableComposite section = getWidgetFactory().createSection(parent, ExpandableComposite.TITLE_BAR);
section.setText(group.getName());
section.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite flatFormComposite = getWidgetFactory().createFlatFormComposite(section);
FormLayout formLayout = new FormLayout();
formLayout.marginHeight = 0;
formLayout.marginWidth = 0;
flatFormComposite.setLayout(formLayout);
TimelineChart chart = new TimelineChart(flatFormComposite, section, group, SWT.NONE, toString() + getJvm().getPid());
charts.add(chart);
FormData data;
data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(0, 0);
data.bottom = new FormAttachment(100, 0);
chart.setLayoutData(data);
section.setClient(flatFormComposite);
List<Action> actions = new ArrayList<Action>();
for (IMonitoredMXBeanAttribute attribute : group.getAttributes()) {
if (attribute.getAttributeName().startsWith("HeapMemoryUsage")) {
//$NON-NLS-1$
actions.add(garbageCollectorAction);
break;
}
}
actions.add(new ConfigureChartAction(chart, this));
addSectionActions(section, actions);
}
use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute in project tdi-studio-se by Talend.
the class TimelineChart method deleteMonitoredSeries.
/**
* Delete series if not monitored any longer.
*/
private void deleteMonitoredSeries() {
ISeriesSet seriesSet = getSeriesSet();
List<IMonitoredMXBeanAttribute> attributes = attributeGroup.getAttributes();
for (ISeries series : seriesSet.getSeries()) {
String seriesId = series.getId();
boolean found = false;
for (IMonitoredMXBeanAttribute attribute : attributes) {
if (series.getId().equals(getSeriesId(attribute))) {
found = true;
}
}
if (!found) {
seriesSet.deleteSeries(seriesId);
}
}
}
use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute 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.IMonitoredMXBeanAttribute 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.IMonitoredMXBeanAttribute in project tdi-studio-se by Talend.
the class MonitoredMXBeanGroup method removeAttribute.
/*
* @see IMonitoredMXBeanGroup#removeAttribute(String, String)
*/
@Override
public void removeAttribute(String objectName, String attributeName) {
IMonitoredMXBeanAttribute targetAttribute = null;
for (IMonitoredMXBeanAttribute attribute : attributes) {
if (attribute.getObjectName().getCanonicalName().equals(objectName) && attribute.getAttributeName().equals(attributeName)) {
targetAttribute = attribute;
break;
}
}
if (targetAttribute != null) {
attributes.remove(targetAttribute);
mBeanServer.fireMBeanServerChangeEvent(new MBeanServerEvent(MBeanServerState.MonitoredAttributeRemoved, targetAttribute));
}
}
Aggregations