protected Object doExecute() throws Exception { String cmdStr = ""; if (command != null) { StringBuilder sb = new StringBuilder(); for (String cmd : command) { if (sb.length() > 0) { sb.append(' '); } sb.append(cmd); } cmdStr = "'" + sb.toString().replaceAll("'", "\\'") + "'"; } int port = getExistingInstance(instance).getSshPort(); if (username != null) { if (password == null) { session.execute("ssh -l " + username + " -p " + port + " localhost " + cmdStr); } else { session.execute("ssh -l " + username + " -P " + password + " -p " + port + " localhost " + cmdStr); } } else { session.execute("ssh -p " + port + " localhost " + cmdStr); } return null; } }
StringBuilder sb = new StringBuilder(); sb.append('['); String s = Integer.toString(instance.getSshPort()); for (int i = s.length(); i < 8; i++) { sb.append(' ');
public JmxInstance(Instance instance) { try { String[] itemNames = AdminServiceMBean.INSTANCE; Object[] itemValues = new Object[itemNames.length]; itemValues[0] = instance.getPid(); itemValues[1] = instance.getName(); itemValues[2] = instance.isRoot(); itemValues[3] = instance.getSshPort(); itemValues[4] = instance.getRmiRegistryPort(); itemValues[5] = instance.getRmiServerPort(); try { itemValues[6] = instance.getState(); } catch (Exception e) { itemValues[6] = "Error"; } itemValues[7] = instance.getLocation(); itemValues[8] = instance.getJavaOpts(); data = new CompositeDataSupport(INSTANCE, itemNames, itemValues); } catch (OpenDataException e) { throw new IllegalStateException("Cannot create instance open data", e); } }
jw.value(instance.getName()); jw.key("sshPort"); jw.value(instance.getSshPort()); jw.key("rmiRegistryPort"); jw.value(instance.getRmiRegistryPort());