Search in sources :

Example 6 with IMonitoredMXBeanGroup

use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup 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 7 with IMonitoredMXBeanGroup

use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup in project tdi-studio-se by Talend.

the class RuntimeGraphcsComposite method loadOverviewChartSet.

private void loadOverviewChartSet(IActiveJvm activeJvm) throws JvmCoreException {
    final int[] blue = new int[] { 0, 255, 255 };
    final int[] red = new int[] { 255, 0, 0 };
    final int[] green = new int[] { 0, 255, 0 };
    final int[] lightgeen = new int[] { 128, 255, 0 };
    final int[] darkRed = new int[] { 255, 0, 128 };
    final int[] orange = new int[] { 255, 255, 0 };
    IMBeanServer server = activeJvm.getMBeanServer();
    server.getMonitoredAttributeGroups().clear();
    IMonitoredMXBeanGroup group = server.addMonitoredAttributeGroup(MonitorAttributeName.HEAP_MEMORY, AxisUnit.MBytes);
    group.addAttribute(ManagementFactory.MEMORY_MXBEAN_NAME, MonitorAttributeName.HEAP_MEMORY_USE, green);
    group.addAttribute(ManagementFactory.MEMORY_MXBEAN_NAME, MonitorAttributeName.HEAP_MEMORY_SIZE, darkRed);
    group.addAttribute(ManagementFactory.MEMORY_MXBEAN_NAME, MonitorAttributeName.HEAP_MEMORY_NINTY, blue);
    group.addAttribute(ManagementFactory.MEMORY_MXBEAN_NAME, MonitorAttributeName.HEAP_MEMORY_THREE_QUARTER, orange);
    group = server.addMonitoredAttributeGroup(MonitorAttributeName.CPU_USE, AxisUnit.Percent);
    group.addAttribute(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, MonitorAttributeName.CPU_TIME, lightgeen);
}
Also used : IMBeanServer(org.talend.designer.runtime.visualization.MBean.IMBeanServer) IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup)

Example 8 with IMonitoredMXBeanGroup

use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup in project tdi-studio-se by Talend.

the class RuntimeGraphcsComposite method reconstructCharts.

void reconstructCharts(IActiveJvm activeJvm, boolean connected) {
    if (chartsPage.isDisposed()) {
        return;
    }
    if (connected) {
        try {
            loadOverviewChartSet(activeJvm);
        } catch (JvmCoreException e) {
            Activator.log(Messages.configureMonitoredAttributesFailedMsg, e);
        }
    }
    List<IMonitoredMXBeanGroup> groups = activeJvm.getMBeanServer().getMonitoredAttributeGroups();
    if (groups.size() == 0) {
        return;
    }
    for (TimelineChart chart : charts) {
        chart.dispose();
    }
    charts.clear();
    if (chartComposite != null && !chartComposite.isDisposed()) {
        chartComposite.dispose();
    }
    chartComposite = new Composite(chartsPage, SWT.NONE);
    FormLayout chartLayout = new FormLayout();
    chartLayout.marginHeight = 0;
    chartLayout.marginWidth = 0;
    chartComposite.setLayout(chartLayout);
    FormData chartComData = new FormData();
    chartComData.top = new FormAttachment(0, 0);
    chartComData.bottom = new FormAttachment(100, 0);
    chartComData.left = new FormAttachment(0, 0);
    chartComData.right = new FormAttachment(100, 0);
    chartComposite.setLayoutData(chartComData);
    for (IMonitoredMXBeanGroup group : groups) {
        createSection(chartComposite, group);
    }
    createReportField(chartComposite);
    //      createInfoField(chartComposite);
    chartsPage.layout();
    chartsPage.setVisible(true);
    refresh();
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) TimelineChart(org.talend.designer.runtime.visualization.internal.ui.properties.timeline.TimelineChart) FormAttachment(org.eclipse.swt.layout.FormAttachment) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 9 with IMonitoredMXBeanGroup

use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup 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)

Example 10 with IMonitoredMXBeanGroup

use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup in project tdi-studio-se by Talend.

the class TimelineSection method reconstructCharts.

/**
     * Reconstructs charts.
     * <p>
     * When JVM gets connected (e.g. opening Properties view or on already opened Properties view), the default chart
     * set will be loaded and applied.
     * <p>
     * When target JVM is already connected (e.g. opening new Properties view, another JVM gets selected, or monitored
     * attributes gets changed), chart configuration will be adapted to the monitored attributes stored in the target
     * JVM.
     * 
     * @param activeJvm The JVM
     * @param connected True if JVM gets connected
     */
void reconstructCharts(IActiveJvm activeJvm, boolean connected) {
    if (chartsPage.isDisposed()) {
        return;
    }
    if (connected) {
        try {
            loadChartSetAction.loadDefaultChartSet();
        } catch (JvmCoreException e) {
            Activator.log(Messages.configureMonitoredAttributesFailedMsg, e);
        }
    }
    List<IMonitoredMXBeanGroup> groups = activeJvm.getMBeanServer().getMonitoredAttributeGroups();
    if (groups.size() == 0) {
        timelinePageBook.showPage(messagePage);
        return;
    }
    timelinePageBook.showPage(chartsPage);
    chartsPage.setVisible(false);
    for (TimelineChart chart : charts) {
        chart.dispose();
    }
    charts.clear();
    if (reportComposite != null && !reportComposite.isDisposed()) {
        reportComposite.dispose();
    }
    GridLayout layout = (GridLayout) chartsPage.getLayout();
    layout.numColumns = (groups.size() > 1) ? 2 : 1;
    chartsPage.setLayout(layout);
    for (IMonitoredMXBeanGroup group : groups) {
        if (group.getName().equals(MonitorAttributeName.HEAP_MEMORY)) {
            createSection(chartsPage, group);
            break;
        }
    }
    createReportField();
    for (IMonitoredMXBeanGroup group : groups) {
        if (!group.getName().equals(MonitorAttributeName.HEAP_MEMORY)) {
            createSection(chartsPage, group);
        }
    }
    chartsPage.layout();
    chartsPage.setVisible(true);
    refresh();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Aggregations

IMonitoredMXBeanGroup (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup)22 IMBeanServer (org.talend.designer.runtime.visualization.MBean.IMBeanServer)7 JvmCoreException (org.talend.designer.runtime.visualization.JvmCoreException)6 IMonitoredMXBeanAttribute (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute)6 IActiveJvm (org.talend.designer.runtime.visualization.IActiveJvm)5 ObjectName (javax.management.ObjectName)4 RGB (org.eclipse.swt.graphics.RGB)4 Date (java.util.Date)3 IMemento (org.eclipse.ui.IMemento)3 AxisUnit (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup.AxisUnit)2 MBeanServerEvent (org.talend.designer.runtime.visualization.MBean.MBeanServerEvent)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)1