Search in sources :

Example 16 with JvmCoreException

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

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

the class LoadChartAction method loadChartSet.

/**
     * Loads the given chart set.
     * 
     * @param chartSet The chart set
     * @throws JvmCoreException
     */
private void loadChartSet(String chartSet) throws JvmCoreException {
    loadPredefinedChartSet(chartSet);
    IMemento chartSetsMemento;
    try {
        chartSetsMemento = getChartSetsMemento();
    } catch (WorkbenchException e) {
        throw new JvmCoreException(IStatus.ERROR, Messages.loadChartSetFailedMsg, e);
    } catch (IOException e) {
        throw new JvmCoreException(IStatus.ERROR, Messages.loadChartSetFailedMsg, e);
    }
    if (chartSetsMemento == null) {
        return;
    }
    IMemento[] mementos = chartSetsMemento.getChildren(CHART_SET);
    for (IMemento memento : mementos) {
        if (chartSet.equals(memento.getID())) {
            loadChartSet(memento);
            return;
        }
    }
}
Also used : IOException(java.io.IOException) WorkbenchException(org.eclipse.ui.WorkbenchException) IMemento(org.eclipse.ui.IMemento) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 18 with JvmCoreException

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

the class LoadChartSetAction method loadChartSet.

/**
     * Loads the given chart set.
     * 
     * @param chartSet The chart set
     * @throws JvmCoreException
     */
private void loadChartSet(String chartSet) throws JvmCoreException {
    loadPredefinedChartSet(chartSet);
    IMemento chartSetsMemento;
    try {
        chartSetsMemento = getChartSetsMemento();
    } catch (WorkbenchException e) {
        throw new JvmCoreException(IStatus.ERROR, Messages.loadChartSetFailedMsg, e);
    } catch (IOException e) {
        throw new JvmCoreException(IStatus.ERROR, Messages.loadChartSetFailedMsg, e);
    }
    if (chartSetsMemento == null) {
        return;
    }
    IMemento[] mementos = chartSetsMemento.getChildren(CHART_SET);
    for (IMemento memento : mementos) {
        if (chartSet.equals(memento.getID())) {
            loadChartSet(memento);
            return;
        }
    }
}
Also used : IOException(java.io.IOException) WorkbenchException(org.eclipse.ui.WorkbenchException) IMemento(org.eclipse.ui.IMemento) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 19 with JvmCoreException

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

the class MemoryRuntimeComposite method initCurrentActiveJobJvm.

private boolean initCurrentActiveJobJvm() {
    boolean isJvmFound = false;
    JvmModel jvmModel = JvmModel.getInstance();
    if (isRemoteRun) {
        if (isRemoteMonitoring && remotePort != -1) {
            try {
                if (currentJvm == null) {
                    currentJvm = jvmModel.addRemoteHostAndJvm(remoteHost, remotePort);
                    return true;
                }
                if (remotePort == currentJvm.getPort() && currentJvm.isConnected()) {
                    return true;
                }
                if (currentJvm.isConnected()) {
                    currentJvm.disconnect();
                }
                currentJvm = jvmModel.addRemoteHostAndJvm(remoteHost, remotePort);
                return true;
            } catch (JvmCoreException e) {
                ExceptionHandler.process(e);
                return false;
            }
        }
    } else {
        String jobClassName = JavaResourcesHelper.getJobClassName(processContext.getProcess());
        List<IActiveJvm> activateJvms = jvmModel.getHost(IHost.LOCALHOST).getActiveJvms();
        for (IActiveJvm jvm : activateJvms) {
            String activeJvmClassName = jvm.getMainClass();
            //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            System.out.println("target:[" + jobClassName + "],loop item[" + activeJvmClassName + "]");
            if (activeJvmClassName != null) {
                activeJvmClassName = activeJvmClassName.trim();
            }
            if (activeJvmClassName.equals(jobClassName)) {
                currentJvm = jvm;
                isJvmFound = true;
                break;
            }
        }
    }
    return isJvmFound;
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) JvmModel(org.talend.designer.runtime.visualization.JvmModel) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 20 with JvmCoreException

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

the class ConfigureCpuProfilerAction method run.

/*
     * @see Action#run()
     */
@Override
public void run() {
    // get the profiled packages
    final Job getProfiledPackagesJob = new Job(Messages.getProfiledPackagesJobLabel) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            IActiveJvm jvm = cpuSection.getJvm();
            if (jvm == null) {
                return Status.CANCEL_STATUS;
            }
            try {
                packages = jvm.getCpuProfiler().getProfiledPackages();
            } catch (JvmCoreException e) {
                Activator.log(Messages.getProfiledPackagesFailedMsg, e);
            }
            return Status.OK_STATUS;
        }
    };
    getProfiledPackagesJob.schedule();
    // open CPU profiler configuration dialog
    Job openDialogJob = new Job(Messages.openDialogJobLabel) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                getProfiledPackagesJob.join();
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        openDialog();
                    }
                });
            } catch (InterruptedException e) {
                return Status.CANCEL_STATUS;
            }
            return Status.OK_STATUS;
        }
    };
    openDialogJob.schedule();
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Job(org.eclipse.core.runtime.jobs.Job) 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