Search in sources :

Example 6 with IActiveJvm

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

the class RuntimeGraphcsComposite method refreshReportField.

private void refreshReportField() {
    long newAddTime = System.currentTimeMillis();
    if (newAddTime - lastAddTime < 10 * 1000) {
        return;
    }
    lastAddTime = newAddTime;
    IActiveJvm jvm = getJvm();
    List<IMonitoredMXBeanGroup> groups = jvm.getMBeanServer().getMonitoredAttributeGroups();
    for (IMonitoredMXBeanGroup group : groups) {
        if (group.getName().equals(MonitorAttributeName.HEAP_MEMORY)) {
            Number useHeapSize = 0;
            Number maxHeapSize = 0;
            Date lastDate = null;
            for (IMonitoredMXBeanAttribute attribute : group.getAttributes()) {
                if (attribute.getAttributeName().equals(MonitorAttributeName.HEAP_MEMORY_USE)) {
                    List<Number> values = attribute.getValues();
                    List<Date> dates = attribute.getDates();
                    if (values.size() > 1) {
                        useHeapSize = values.get(values.size() - 1);
                        lastDate = dates.get(dates.size() - 1);
                    }
                } else if (attribute.getAttributeName().equals(MonitorAttributeName.HEAP_MEMORY_SIZE)) {
                    List<Number> values = attribute.getValues();
                    List<Date> dates = attribute.getDates();
                    if (values.size() > 1) {
                        maxHeapSize = values.get(values.size() - 1);
                        lastDate = dates.get(dates.size() - 1);
                    }
                }
            }
            if (lastDate != null) {
                if (isRightPercentage(maxHeapSize, useHeapSize)) {
                //                    	setNormalReport(lastDate);
                } else {
                    setWarningReport(lastDate);
                }
            }
        }
    }
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) IMonitoredMXBeanAttribute(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute) List(java.util.List) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 7 with IActiveJvm

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

the class NewJvmConnectionWizard method addActiveJvm.

/**
     * Adds the active JVM.
     * 
     * @return The active JVM
     */
private IActiveJvm addActiveJvm() {
    final boolean isHostAndPortSelected = page.isHostAndPortSelected();
    final String hostName = page.getRemoteHost();
    final int port = page.getPort();
    final String userName = page.getUserName();
    final String password = page.getPassword();
    final String jmxUrl = page.getJmxUrl();
    try {
        final IActiveJvm[] result = new IActiveJvm[1];
        IRunnableWithProgress op = new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    int period = Activator.getDefault().getPreferenceStore().getInt(IConstants.UPDATE_PERIOD);
                    if (isHostAndPortSelected) {
                        IHost host = JvmModel.getInstance().addHost(hostName);
                        result[0] = host.addRemoteActiveJvm(port, userName, password, period);
                    } else {
                        result[0] = JvmModel.getInstance().addHostAndJvm(jmxUrl, userName, password, period);
                    }
                } catch (JvmCoreException e) {
                    throw new InvocationTargetException(e);
                }
            }
        };
        new ProgressMonitorDialog(getShell()).run(true, true, op);
        return result[0];
    } catch (InvocationTargetException e) {
        openErrorDialog(e);
        return null;
    } catch (InterruptedException e) {
        return null;
    }
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IHost(org.talend.designer.runtime.visualization.IHost) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 8 with IActiveJvm

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

the class NewJvmConnectionWizard method performFinish.

/*
     * @see Wizard#performFinish()
     */
@Override
public boolean performFinish() {
    // add active JVM
    IActiveJvm jvm = addActiveJvm();
    if (jvm == null) {
        return false;
    }
    // select item on JVM explorer
    viewer.refresh();
    viewer.setSelection(new StructuredSelection(jvm));
    // connect to JVM
    try {
        int period = Activator.getDefault().getPreferenceStore().getInt(IConstants.UPDATE_PERIOD);
        jvm.connect(period);
    } catch (JvmCoreException e) {
        Activator.log(NLS.bind(Messages.connectJvmFailedMsg, jvm.getPid()), e);
    }
    page.storeDialogSettings();
    return true;
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 9 with IActiveJvm

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

the class NewChartAction method run.

/*
     * @see Action#run()
     */
@Override
public void run() {
    IActiveJvm jvm = section.getJvm();
    if (jvm == null) {
        return;
    }
    NewChartDialog dialog = new NewChartDialog(Display.getDefault().getActiveShell(), jvm);
    if (dialog.open() == Window.OK) {
        performNew(dialog.getChartTitle(), dialog.getAxisUnit(), dialog.getAttributes(), jvm);
    }
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm)

Example 10 with IActiveJvm

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

the class TimelineSection method dispose.

/*
     * @see AbstractJvmPropertySection#dispose()
     */
@Override
public void dispose() {
    super.dispose();
    IActiveJvm jvm = getJvm();
    if (jvm != null) {
        IMBeanServer server = jvm.getMBeanServer();
        if (server != null) {
            server.removeServerChangeListener(mBeanServerChangeListener);
        }
    }
}
Also used : IMBeanServer(org.talend.designer.runtime.visualization.MBean.IMBeanServer) IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm)

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