Search in sources :

Example 1 with IHost

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

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

the class DeleteAction method run.

/*
     * @see Action#run()
     */
@Override
public void run() {
    if (!confirm()) {
        return;
    }
    // delete JVMs
    deleteJvms();
    // delete remote hosts
    for (IHost host : remoteHosts) {
        jvms = host.getTerminatedJvms();
        deleteJvms();
    }
    for (IHost host : remoteHosts) {
        JvmModel.getInstance().removeHost(host);
    }
    // delete snapshots
    for (ISnapshot snapshot : snapshots) {
        closeEditor(snapshot.getFileStore());
        snapshot.getJvm().deleteSnapshot(snapshot);
    }
    treeViewer.refresh();
}
Also used : ISnapshot(org.talend.designer.runtime.visualization.ISnapshot) IHost(org.talend.designer.runtime.visualization.IHost)

Example 3 with IHost

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

the class JvmTreeViewer method updateStatusLine.

/**
     * Updates the status line.
     * 
     * @param selection the selection
     */
void updateStatusLine(final IStructuredSelection selection) {
    RefreshJob refreshJob = new RefreshJob(Messages.refreshStatusLineJobLabel, JvmTreeViewer.class.getName()) {

        private ProfilerState state;

        private Object element;

        @Override
        protected void refreshModel(IProgressMonitor monitor) {
            element = selection.getFirstElement();
            if (element instanceof IActiveJvm) {
                IActiveJvm activeJvm = (IActiveJvm) element;
                state = activeJvm.getCpuProfiler().getState();
            }
        }

        @Override
        protected void refreshUI() {
            StringBuffer text = new StringBuffer();
            StringBuffer errorText = new StringBuffer();
            errorImage = null;
            if (element instanceof IActiveJvm) {
                IActiveJvm activeJvm = (IActiveJvm) element;
                if (activeJvm.isConnected()) {
                    text.append(Messages.connectedMsg);
                    if (state == ProfilerState.RUNNING) {
                        //$NON-NLS-1$
                        text.append(" ").append(Messages.cpuProfilerRunningMsg);
                    }
                } else if (!activeJvm.isConnectionSupported()) {
                    String errorMessage = activeJvm.getErrorStateMessage();
                    if (errorMessage != null) {
                        errorText.append(errorMessage);
                    }
                } else {
                    text.append(Messages.disconnectedMsg);
                }
            } else if (element instanceof IHost) {
                IHost host = (IHost) element;
                if (host.getName().equals(IHost.LOCALHOST)) {
                    if (!JvmModel.getInstance().hasValidJdk()) {
                        errorText.append(Messages.invalidJdkLocationMsg);
                        errorImage = getErrorImage();
                    } else if (host.getActiveJvms().isEmpty()) {
                        errorText.append(Messages.cannnotDetectJvmMsg);
                        errorImage = getErrorImage();
                    }
                }
            }
            statusLineManager.setErrorMessage(errorImage, errorText.toString());
            statusLineItem.setText(text.toString());
        }
    };
    refreshJob.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) IHost(org.talend.designer.runtime.visualization.IHost) ProfilerState(org.talend.designer.runtime.visualization.internal.core.cpu.ICpuProfiler.ProfilerState)

Example 4 with IHost

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

the class NewJvmConnectionWizardPage method createHostAndPortPanel.

/**
     * Creates the host and port panel.
     * 
     * @param parent The parent composite
     */
private void createHostAndPortPanel(Composite parent) {
    hostAndPortButton = new Button(parent, SWT.RADIO);
    GridData layoutData = new GridData();
    layoutData.horizontalSpan = 2;
    hostAndPortButton.setLayoutData(layoutData);
    hostAndPortButton.setText(Messages.connectWithHostAndPort);
    hostAndPortButton.setSelection(true);
    hostAndPortButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (!hostAndPortButton.getSelection()) {
                return;
            }
            urlText.setEnabled(false);
            remoteHostText.setEnabled(true);
            remoteHostText.setFocus();
            portText.setEnabled(true);
            validate();
        }
    });
    remoteHostText = addComboTextField(parent, Messages.remoteHostTextLabel, REMOTE_HOST_HISTORY_KEY);
    List<IHost> hosts = JvmModel.getInstance().getHosts();
    for (IHost host : hosts) {
        String hostName = host.getName();
        if (!hostName.equals(IHost.LOCALHOST) && remoteHostText.indexOf(hostName) == -1) {
            remoteHostText.add(hostName);
        }
    }
    remoteHostText.setFocus();
    String hostName = getSelectedHost();
    if (hostName != null && !IHost.LOCALHOST.equals(hostName)) {
        remoteHostText.setText(hostName);
    }
    portText = addComboTextField(parent, Messages.portTextLabel, PORT_HISTORY_KEY);
}
Also used : Button(org.eclipse.swt.widgets.Button) IHost(org.talend.designer.runtime.visualization.IHost) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 5 with IHost

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

the class MBeanServer method connectToMBeanServer.

/**
     * Connects to the MBean server in the given VM.
     * 
     * @param url The JMX service URL
     * @return The MBean server connection
     * @throws JvmCoreException
     */
private MBeanServerConnection connectToMBeanServer(JMXServiceURL url) throws JvmCoreException {
    JMXConnector jmxc;
    try {
        if (jvm.getUserName() != null && jvm.getPassword() != null) {
            Map<String, String[]> env = new HashMap<String, String[]>();
            env.put(JMXConnector.CREDENTIALS, new String[] { jvm.getUserName(), jvm.getPassword() });
            jmxc = JMXConnectorFactory.connect(url, env);
        } else {
            jmxc = JMXConnectorFactory.connect(url);
        }
        return jmxc.getMBeanServerConnection();
    } catch (IOException e) {
        IHost host = jvm.getHost();
        if (host != null && host.getActiveJvms().contains(jvm)) {
            host.removeJvm(jvm.getPid());
        }
        throw new JvmCoreException(IStatus.INFO, Messages.connectToMBeanServerFailedMsg, e);
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) JMXConnector(javax.management.remote.JMXConnector) IHost(org.talend.designer.runtime.visualization.IHost) IOException(java.io.IOException) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Aggregations

IHost (org.talend.designer.runtime.visualization.IHost)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IActiveJvm (org.talend.designer.runtime.visualization.IActiveJvm)2 JvmCoreException (org.talend.designer.runtime.visualization.JvmCoreException)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 JMXConnector (javax.management.remote.JMXConnector)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 Button (org.eclipse.swt.widgets.Button)1 ISnapshot (org.talend.designer.runtime.visualization.ISnapshot)1 ProfilerState (org.talend.designer.runtime.visualization.internal.core.cpu.ICpuProfiler.ProfilerState)1 RefreshJob (org.talend.designer.runtime.visualization.internal.ui.RefreshJob)1