Search in sources :

Example 1 with IMonitoredMXBeanAttribute

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;
}
Also used : ArrayList(java.util.ArrayList) IMonitoredMXBeanAttribute(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute) RGB(org.eclipse.swt.graphics.RGB) ObjectName(javax.management.ObjectName)

Example 2 with IMonitoredMXBeanAttribute

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();
}
Also used : IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) IMonitoredMXBeanAttribute(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute) RGB(org.eclipse.swt.graphics.RGB) ObjectName(javax.management.ObjectName) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 3 with IMonitoredMXBeanAttribute

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;
}
Also used : ArrayList(java.util.ArrayList) IMonitoredMXBeanAttribute(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute) RGB(org.eclipse.swt.graphics.RGB) ObjectName(javax.management.ObjectName)

Example 4 with IMonitoredMXBeanAttribute

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

Example 5 with IMonitoredMXBeanAttribute

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);
                }
            }
        }
    }
}
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) List(java.util.List) ArrayList(java.util.ArrayList) Date(java.util.Date)

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