Search in sources :

Example 11 with IActiveJvm

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

the class TimelineSection method jvmModelChanged.

/*
     * @see AbstractJvmPropertySection#jvmModelChanged(JvmModelEvent)
     */
@Override
public void jvmModelChanged(JvmModelEvent event) {
    super.jvmModelChanged(event);
    if (event.state == State.JvmConnected && !chartsPage.isDisposed()) {
        final IActiveJvm newJvm = (IActiveJvm) event.jvm;
        Display.getDefault().asyncExec(new Runnable() {

            @Override
            public void run() {
                reconstructCharts(newJvm, true);
            }
        });
        newJvm.getMBeanServer().addServerChangeListener(mBeanServerChangeListener);
    }
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm)

Example 12 with IActiveJvm

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

the class TimelineSection method refreshReportField.

/**
     * Refreshes the report field.
     */
private void refreshReportField() {
    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 {
                    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);
                }
            }
        // Number diff = getDiff(maxHeapSize, useHeapSize);
        // if (diff instanceof Integer) {
        // int value = diff.intValue();
        // if (value <= 200) {
        // setWarningReport(lastDate);
        // } else {
        // setNormalReport(lastDate);
        // }
        // } else if (diff instanceof Long) {
        // long value = diff.longValue();
        // if (value <= 200) {
        // setWarningReport(lastDate);
        // } else {
        // setNormalReport(lastDate);
        // }
        // } else if (diff instanceof Double) {
        // double value = diff.doubleValue();
        // if (value <= 200) {
        // setWarningReport(lastDate);
        // } else {
        // setNormalReport(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) Date(java.util.Date)

Example 13 with IActiveJvm

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

the class MemoryRuntimeComposite method initMonitoringModel.

private void initMonitoringModel() {
    final List<IActiveJvm> contructSelections = new ArrayList<IActiveJvm>();
    contructSelections.add(currentJvm);
    if (currentJvm != null) {
        viewPart.getSite().setSelectionProvider(new ProcessViewSelectionProvider(new StructuredSelection(contructSelections)));
    }
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) ProcessViewSelectionProvider(org.talend.designer.runprocess.ui.views.ProcessViewSelectionProvider) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Example 14 with IActiveJvm

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

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

the class MBeansSection method refresh.

/*
     * @see AbstractPropertySection#refresh()
     */
@Override
public void refresh() {
    if (!isSectionActivated) {
        return;
    }
    IActiveJvm jvm = getJvm();
    boolean isConnected = jvm != null && jvm.isConnected();
    refreshAction.setEnabled(isConnected);
    if (sashForm != null && !sashForm.isDisposed()) {
        refreshBackground(sashForm.getChildren(), isConnected);
        sashForm.refresh();
    }
}
Also used : 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