Search in sources :

Example 36 with JvmCoreException

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

Example 37 with JvmCoreException

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

the class TimelineSection method createMessagePage.

/**
     * Creates the message page.
     * 
     * @return The message page
     */
private Composite createMessagePage() {
    messagePage = new Composite(timelinePageBook, SWT.NONE);
    messagePage.setLayout(new GridLayout(3, false));
    messagePage.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    FormToolkit toolkit = new FormToolkit(Display.getDefault());
    Hyperlink hyperlink = toolkit.createHyperlink(messagePage, Messages.loadDefaultChartSetLabel, SWT.NONE);
    hyperlink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent event) {
            try {
                new LoadChartSetAction(TimelineSection.this).loadDefaultChartSet();
            } catch (JvmCoreException e) {
                Activator.log(Messages.loadChartSetFailedMsg, e);
            }
        }
    });
    return messagePage;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 38 with JvmCoreException

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

the class MemoryRuntimeComposite method doScheduledGc.

protected void doScheduledGc(int interval) {
    timer.cancel();
    if (interval == 0) {
        return;
    }
    timer = null;
    timer = new Timer();
    TimerTask gcTask = new TimerTask() {

        @Override
        public void run() {
            if (processContext != null && processContext.isRunning()) {
                if (currentJvm != null) {
                    try {
                        currentJvm.getMBeanServer().runGarbageCollector();
                        //$NON-NLS-1$ //$NON-NLS-2$
                        System.out.println("GC executed at " + TalendDate.getDate("HH:mm:ss"));
                    } catch (JvmCoreException e) {
                    //do nothing.
                    }
                }
            } else {
                timer.cancel();
                //$NON-NLS-1$ //$NON-NLS-2$
                System.out.println("timer cancelled at " + TalendDate.getDate("HH:mm:ss"));
            }
        }
    };
    timer.schedule(gcTask, interval * 1000, interval * 1000);
}
Also used : Timer(java.util.Timer) TimerTask(java.util.TimerTask) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 39 with JvmCoreException

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

the class NewChartAction method performNew.

/**
     * Performs creating a new chart.
     * 
     * @param chartTitle The chart title
     * @param axisUnit The axis unit
     * @param attributes The attributes
     * @param jvm The jvm
     */
private static void performNew(String chartTitle, AxisUnit axisUnit, List<MBeanAttribute> attributes, IActiveJvm jvm) {
    IMonitoredMXBeanGroup group = jvm.getMBeanServer().addMonitoredAttributeGroup(chartTitle, axisUnit);
    for (MBeanAttribute attribute : attributes) {
        ObjectName objectName = attribute.getObjectName();
        String attributeName = attribute.getAttributeName();
        RGB rgb = attribute.getRgb();
        try {
            group.addAttribute(objectName.getCanonicalName(), attributeName, new int[] { rgb.red, rgb.green, rgb.blue });
        } catch (JvmCoreException e) {
            Activator.log(Messages.addAttributeFailedMsg, e);
        }
    }
}
Also used : IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) RGB(org.eclipse.swt.graphics.RGB) ObjectName(javax.management.ObjectName) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 40 with JvmCoreException

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

the class Host method saveHostProperties.

/**
     * Saves the properties.
     */
private void saveHostProperties() {
    Properties props = new Properties();
    IPath hostDir;
    try {
        hostDir = getHostDir();
    } catch (JvmCoreException e) {
        Activator.log(IStatus.ERROR, Messages.savePropertiesFileFailedMsg, e);
        return;
    }
    IFileStore fileStore = Util.getFileStore(Host.PROPERTIES_FILE, hostDir);
    OutputStream os = null;
    try {
        os = fileStore.openOutputStream(EFS.NONE, null);
        props.setProperty(Host.HOST_PROP_KEY, hostName);
        //$NON-NLS-1$
        props.storeToXML(os, "Host Properties");
    } catch (CoreException e) {
        Activator.log(IStatus.ERROR, NLS.bind(Messages.openOutputStreamFailedMsg, fileStore.toURI().getPath()), e);
    } catch (IOException e) {
        try {
            fileStore.delete(EFS.NONE, null);
        } catch (CoreException e1) {
        // do nothing
        }
        Activator.log(IStatus.ERROR, NLS.bind(Messages.writePropertiesFileFailedMsg, fileStore.toURI().getPath()), e);
    } finally {
        if (os != null) {
            try {
                os.close();
            } catch (IOException e) {
            // do nothing
            }
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException) OutputStream(java.io.OutputStream) IFileStore(org.eclipse.core.filesystem.IFileStore) IOException(java.io.IOException) Properties(java.util.Properties) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Aggregations

JvmCoreException (org.talend.designer.runtime.visualization.JvmCoreException)64 IOException (java.io.IOException)16 IActiveJvm (org.talend.designer.runtime.visualization.IActiveJvm)14 Method (java.lang.reflect.Method)11 ObjectName (javax.management.ObjectName)10 IFileStore (org.eclipse.core.filesystem.IFileStore)6 CoreException (org.eclipse.core.runtime.CoreException)6 IMonitoredMXBeanGroup (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup)6 File (java.io.File)5 Properties (java.util.Properties)5 IPath (org.eclipse.core.runtime.IPath)5 OutputStream (java.io.OutputStream)4 JMException (javax.management.JMException)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IHost (org.talend.designer.runtime.visualization.IHost)4 JvmModelEvent (org.talend.designer.runtime.visualization.JvmModelEvent)4 Date (java.util.Date)3 Timer (java.util.Timer)3 TimerTask (java.util.TimerTask)3 RGB (org.eclipse.swt.graphics.RGB)3