Search in sources :

Example 6 with IMonitoredMXBeanAttribute

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);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) GarbageCollectorAction(org.talend.designer.runtime.visualization.internal.ui.properties.memory.GarbageCollectorAction) Action(org.eclipse.jface.action.Action) RefreshAction(org.talend.designer.runtime.visualization.internal.actions.RefreshAction) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) GridData(org.eclipse.swt.layout.GridData) ArrayList(java.util.ArrayList) IMonitoredMXBeanAttribute(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 7 with IMonitoredMXBeanAttribute

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);
        }
    }
}
Also used : ISeriesSet(org.swtchart.ISeriesSet) IMonitoredMXBeanAttribute(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute) ISeries(org.swtchart.ISeries)

Example 8 with IMonitoredMXBeanAttribute

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);
        // }
        // }
        }
    }
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) IMonitoredMXBeanAttribute(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute) Date(java.util.Date)

Example 9 with IMonitoredMXBeanAttribute

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()));
        }
    }
}
Also used : IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) IMonitoredMXBeanAttribute(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute) IMemento(org.eclipse.ui.IMemento)

Example 10 with IMonitoredMXBeanAttribute

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));
    }
}
Also used : IMonitoredMXBeanAttribute(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute) MBeanServerEvent(org.talend.designer.runtime.visualization.MBean.MBeanServerEvent)

Aggregations

IMonitoredMXBeanAttribute (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute)12 IMonitoredMXBeanGroup (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 ObjectName (javax.management.ObjectName)4 RGB (org.eclipse.swt.graphics.RGB)4 ISeries (org.swtchart.ISeries)2 IActiveJvm (org.talend.designer.runtime.visualization.IActiveJvm)2 JvmCoreException (org.talend.designer.runtime.visualization.JvmCoreException)2 DecimalFormat (java.text.DecimalFormat)1 List (java.util.List)1 Action (org.eclipse.jface.action.Action)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 GridData (org.eclipse.swt.layout.GridData)1 Composite (org.eclipse.swt.widgets.Composite)1 IMemento (org.eclipse.ui.IMemento)1 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)1 ISeriesSet (org.swtchart.ISeriesSet)1