Search in sources :

Example 61 with JvmCoreException

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

the class Tools method invokeHeapHisto.

/**
     * Invokes the heapHisto method of HotSpotVirtualMachine with reflection.
     * 
     * @param virtualMachine The virtual machine
     * @param isLive True to dump only live objects
     * @return The input stream of heap histo
     * @throws JvmCoreException
     */
protected InputStream invokeHeapHisto(Object virtualMachine, boolean isLive) throws JvmCoreException {
    try {
        Class<?> clazz = Class.forName(HOT_SPOT_VIRTUAL_MACHINE_CLASS);
        Method method = clazz.getDeclaredMethod(HEAP_HISTO_METHOD, new Class[] { Object[].class });
        Object[] arg = new Object[] { isLive ? HEAP_HISTO_LIVE_OPTION : HEAP_HISTO_ALL_OPTION };
        return (InputStream) method.invoke(virtualMachine, (Object) arg);
    } catch (Throwable t) {
        throw new JvmCoreException(IStatus.ERROR, t.getMessage(), t);
    }
}
Also used : InputStream(java.io.InputStream) Method(java.lang.reflect.Method) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 62 with JvmCoreException

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

the class SWTResourcesPage method refresh.

/**
     * Refreshes the appearance.
     * 
     * @param force <tt>true</tt> to force refresh
     */
protected void refresh(final boolean force) {
    final boolean isVisible = isVisible();
    new RefreshJob(NLS.bind(Messages.refreshMemorySectionJobLabel, section.getJvm().getPid()), toString()) {

        @Override
        protected void refreshModel(IProgressMonitor monitor) {
            try {
                IActiveJvm jvm = section.getJvm();
                if (isVisible && jvm != null && jvm.isConnected() && (!section.isRefreshSuspended() || force) && jvm.getSWTResourceMonitor().isSupported()) {
                    jvm.getSWTResourceMonitor().refreshResourcesCache();
                }
            } catch (JvmCoreException e) {
                Activator.log(Messages.refreshHeapDataFailedMsg, e);
            }
        }

        @Override
        protected void refreshUI() {
            IActiveJvm jvm = section.getJvm();
            boolean isConnected = jvm != null && jvm.isConnected();
            if (!isDisposed()) {
                refreshBackground();
            }
            refreshAction.setEnabled(isConnected);
            clearSWTResourceAction.setEnabled(isConnected);
            if (!force && section.isRefreshSuspended() || !isVisible) {
                return;
            }
            TreeViewer resourceViewer = resourceFilteredTree.getViewer();
            if (!resourceViewer.getControl().isDisposed()) {
                resourceViewer.refresh();
                if (jvm != null) {
                    resourceFilteredTree.updateStatusLine(jvm.getSWTResourceMonitor().getResources());
                }
                // select the first item if no item is selected
                if (resourceViewer.getSelection().isEmpty()) {
                    TreeItem[] items = resourceViewer.getTree().getItems();
                    if (items != null && items.length > 0) {
                        resourceViewer.getTree().select(items[0]);
                        stackTraceViewer.setInput(resourceViewer.getSelection());
                    } else {
                        stackTraceViewer.setInput(null);
                    }
                }
            }
            if (!stackTraceViewer.getControl().isDisposed()) {
                stackTraceViewer.refresh();
            }
        }
    }.schedule();
}
Also used : RefreshJob(org.talend.designer.runtime.visualization.internal.ui.RefreshJob) IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TreeViewer(org.eclipse.jface.viewers.TreeViewer) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 63 with JvmCoreException

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

the class ConfigureChartAction 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 64 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)

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