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;
}
}
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();
}
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();
}
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);
}
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);
}
}
Aggregations