Search in sources :

Example 56 with JvmCoreException

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

the class Tools method invokeAttach.

/**
     * Invokes the attach method of VirtualMachine with reflection.
     * 
     * @param pid The process ID
     * @return The virtual machine
     * @throws JvmCoreException
     */
protected Object invokeAttach(int pid) throws JvmCoreException {
    try {
        Class<?> clazz = Class.forName(VIRTUAL_MACHINE_CLASS);
        Method method = clazz.getDeclaredMethod(ATTACH_METHOD, new Class[] { String.class });
        return method.invoke(null, String.valueOf(pid));
    } catch (Throwable t) {
        throw new JvmCoreException(IStatus.ERROR, t.getCause().getMessage(), t);
    }
}
Also used : Method(java.lang.reflect.Method) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 57 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 58 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 59 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 60 with JvmCoreException

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

the class CpuSection method setProfiledPackages.

/**
     * Sets the profiled packages to CPU profiler.
     */
void setProfiledPackages() {
    IActiveJvm jvm = getJvm();
    if (jvm == null) {
        return;
    }
    Set<String> packages = new LinkedHashSet<String>();
    String packagesString = Activator.getDefault().getDialogSettings(CpuSection.class.getName()).get(IConstants.PACKAGES_KEY);
    if (packagesString != null) {
        if (packagesString.contains(",")) {
            //$NON-NLS-1$
            for (String item : packagesString.split(",")) {
                //$NON-NLS-1$
                packages.add(item);
            }
        } else if (!packagesString.isEmpty()) {
            packages.add(packagesString);
        }
        try {
            jvm.getCpuProfiler().setProfiledPackages(packages);
        } catch (JvmCoreException e) {
            Activator.log(Messages.setProfiledPackagesFailedMsg, e);
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) 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