Search in sources :

Example 16 with IActiveJvm

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

the class MBeanLabelProvider method getStyledText.

/*
     * @see DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText( Object)
     */
@Override
public StyledString getStyledText(Object element) {
    StyledString text = new StyledString();
    boolean appendSuffix = false;
    ObjectName objectName = null;
    IActiveJvm jvm = null;
    if (element instanceof IMBeanNode) {
        text.append(((IMBeanNode) element).getName());
        if (element instanceof MBean && ((MBean) element).isNotificationSubsctibed()) {
            appendSuffix = true;
            jvm = ((MBean) element).getJvm();
        }
    }
    if (appendSuffix && jvm != null) {
        int notificationCount = jvm.getMBeanServer().getMBeanNotification().getNotifications(objectName).length;
        //$NON-NLS-1$ //$NON-NLS-2$
        String suffix = " [notifications: " + notificationCount + "]";
        int offset = text.length();
        text.append(suffix);
        text.setStyle(offset, suffix.length(), StyledString.DECORATIONS_STYLER);
    }
    return text;
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) ObjectName(javax.management.ObjectName)

Example 17 with IActiveJvm

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

Example 18 with IActiveJvm

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

the class ConfigureCpuProfilerAction method openDialog.

/**
     * Opens the dialog.
     */
void openDialog() {
    IActiveJvm jvm = cpuSection.getJvm();
    if (jvm == null) {
        return;
    }
    final ConfigurationDialog dialog = new ConfigurationDialog(cpuSection.getPart().getSite().getShell(), jvm.getCpuProfiler().getProfilerType(), jvm.getCpuProfiler().getSamplingPeriod(), jvm.getCpuProfiler().getState(ProfilerType.BCI), packages);
    if (dialog.open() != Window.OK) {
        return;
    }
    new Job(Messages.configureProfilerJobLabel) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            return doConfigure(monitor, dialog);
        }
    }.schedule();
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) Job(org.eclipse.core.runtime.jobs.Job)

Example 19 with IActiveJvm

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

the class ConfigureCpuProfilerAction method setPackages.

/**
     * Sets the packages.
     * 
     * @param packages The packages
     * @param monitor The progress monitor
     * @return The packages string with delimiter ','
     */
String setPackages(Set<String> packages, IProgressMonitor monitor) {
    IActiveJvm jvm = cpuSection.getJvm();
    if (jvm != null) {
        try {
            jvm.getCpuProfiler().setProfiledPackages(packages);
            if (jvm.getCpuProfiler().getProfilerType() == ProfilerType.BCI && jvm.getCpuProfiler().getState() == ProfilerState.RUNNING) {
                jvm.getCpuProfiler().transformClasses(monitor);
            }
        } catch (JvmCoreException e) {
            Activator.log(Messages.setProfiledPackagesFailedMsg, e);
        } catch (InterruptedException e) {
        // do nothing
        }
    }
    StringBuffer buffer = new StringBuffer();
    for (String item : packages) {
        if (buffer.length() > 0) {
            buffer.append(',');
        }
        buffer.append(item);
    }
    return buffer.toString();
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 20 with IActiveJvm

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

the class ConfigureCpuProfilerAction method doConfigure.

/**
     * Configures the profiler.
     * 
     * @param monitor The progress monitor
     * @param dialog The configuration dialog
     * @return The status
     */
IStatus doConfigure(IProgressMonitor monitor, ConfigurationDialog dialog) {
    IActiveJvm jvm = cpuSection.getJvm();
    if (jvm == null) {
        return Status.CANCEL_STATUS;
    }
    IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings(CpuSection.class.getName());
    ProfilerType type = dialog.getProfilerType();
    if (jvm.getCpuProfiler().getProfilerType() != type) {
        if (jvm.getCpuProfiler().getState() == ProfilerState.RUNNING) {
            new SuspendCpuProfilingAction(cpuSection).run();
        }
        new ClearCpuProfilingDataAction(cpuSection).run();
        jvm.getCpuProfiler().setProfilerType(type);
    }
    if (type == ProfilerType.SAMPLING) {
        int samplingPeriod = dialog.getSamplingPeriod();
        jvm.getCpuProfiler().setSamplingPeriod(samplingPeriod);
        dialogSettings.put(IConstants.PROFILER_SAMPLING_PERIOD_KEY, samplingPeriod);
    }
    String packageString = setPackages(dialog.getPackages(), monitor);
    dialogSettings.put(IConstants.PACKAGES_KEY, packageString);
    dialogSettings.put(IConstants.PROFILER_TYPE_KEY, type.name());
    return Status.OK_STATUS;
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) CpuSection(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.CpuSection) ProfilerType(org.talend.designer.runtime.visualization.internal.core.cpu.ICpuProfiler.ProfilerType)

Aggregations

IActiveJvm (org.talend.designer.runtime.visualization.IActiveJvm)54 JvmCoreException (org.talend.designer.runtime.visualization.JvmCoreException)14 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)7 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)6 RefreshJob (org.talend.designer.runtime.visualization.internal.ui.RefreshJob)6 IMonitoredMXBeanGroup (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup)5 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 ObjectName (javax.management.ObjectName)2 Job (org.eclipse.core.runtime.jobs.Job)2 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Composite (org.eclipse.swt.widgets.Composite)2 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)2 IHost (org.talend.designer.runtime.visualization.IHost)2 JvmModelEvent (org.talend.designer.runtime.visualization.JvmModelEvent)2 IMBeanServerChangeListener (org.talend.designer.runtime.visualization.MBean.IMBeanServerChangeListener)2 IMonitoredMXBeanAttribute (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute)2 AxisUnit (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup.AxisUnit)2 MBeanServerEvent (org.talend.designer.runtime.visualization.MBean.MBeanServerEvent)2