private boolean destroyInstance(String name) { try { Instance instance = instanceService.getInstance(name); if (instance != null) { instance.destroy(); return true; } } catch (Exception ex) { Logger.getLogger(InstancePlugin.class.getName()).log(Level.SEVERE, null, ex); } return false; }
private static CompositeDataSupport mapInstance(Instance instance, CompositeType comp) throws OpenDataException { String state; try { state = instance.getState(); } catch (Exception e) { state = "Error"; } Object[] itemValues = new Object[] {instance.getPid(), instance.getName(), instance.isRoot(), instance.getSshPort(), instance.getSshHost(), instance.getRmiRegistryPort(), instance.getRmiRegistryHost(), instance.getRmiServerPort(), instance.getRmiServerHost(), state, instance.getLocation(), instance.getJavaOpts()}; return new CompositeDataSupport(comp, InstancesMBean.INSTANCE, itemValues); }
String options = opts; if (options == null) { options = child.getJavaOpts(); String state = child.getState(); if (Instance.STOPPED.equals(state)) { child.start(opts); state = child.getState(); } while (Instance.STARTING.equals(state)); child.start(opts);
private String getRightColumnValue(Instance instance) { if (javaOpts) { return instance.getJavaOpts(); } else if (location) { return instance.getLocation(); } else { return instance.getName(); } }
private void instanceInfo(JSONWriter jw, Instance instance) throws Exception { jw.object(); jw.key("pid"); jw.value(instance.getPid()); jw.key("name"); jw.value(instance.getName()); jw.key("sshPort"); jw.value(instance.getSshPort()); jw.key("rmiRegistryPort"); jw.value(instance.getRmiRegistryPort()); jw.key("rmiServerPort"); jw.value(instance.getRmiServerPort()); jw.key("state"); jw.value(instance.getState()); jw.key("location"); jw.value(instance.getJavaOpts() != null ? instance.getJavaOpts() : ""); jw.key("javaopts"); jw.value(instance.getLocation()); jw.key("actions"); jw.array(); action(jw, "destroy", "Destroy", "delete"); if (instance.getState().equals(Instance.STARTED)) { action(jw, "stop", "Stop", "stop"); } else if (instance.getState().equals(Instance.STARTING)) { action(jw, "stop", "Stop", "stop"); } else if (instance.getState().equals(Instance.STOPPED)) { action(jw, "start", "Start", "start");
protected Object doExecute() throws Exception { Instance[] instances = getInstanceService().getInstances(); ShellTable table = new ShellTable(); table.column("SSH Port").alignRight(); table.column("SSH Host").alignRight(); table.column("RMI Registry").alignRight(); table.column("RMI Registry Host").alignRight(); table.column("RMI Server").alignRight(); table.column("RMI Server Host").alignRight(); table.column("State"); table.column("PID"); table.column(getRightColumnHeader()); for (Instance instance : instances) { table.addRow().addContent( instance.getSshPort(), instance.getSshHost(), instance.getRmiRegistryPort(), instance.getRmiRegistryHost(), instance.getRmiServerPort(), instance.getRmiServerHost(), instance.getState(), instance.getPid(), getRightColumnValue(instance)); } table.print(System.out, !noFormat); return null; }
String opts = javaOpts; if (opts == null) { opts = instance.getJavaOpts(); opts += DEBUG_OPTS; instance.restart(opts); } catch (Exception e) { exception.addException(e); boolean allStarted = true; for (Instance child : toWaitFor) { allStarted &= Instance.STARTED.equals(child.getState());
protected boolean acceptsInstance(Instance instance) { try { return instance.getState().equals(Instance.STOPPED); } catch (Exception e) { return false; } }
private boolean startInstance(String name, String javaOpts) { try { Instance instance = instanceService.getInstance(name); if (instance != null) { instance.start(javaOpts); return true; } } catch (Exception ex) { Logger.getLogger(InstancePlugin.class.getName()).log(Level.SEVERE, null, ex); } return false; }
protected List<Instance> getMatchingInstances(List<String> patterns) { List<Instance> instances = new ArrayList<>(); Instance[] allInstances = instanceService.getInstances(); for (Instance instance : allInstances) { if (match(instance.getName(), patterns)) { instances.add(instance); } } if (instances.isEmpty()) { throw new IllegalArgumentException("No matching instances"); } return instances; }
public int createInstance(String name, int sshPort, int rmiRegistryPort, int rmiServerPort, String location, String javaOpts, String features, String featureURLs, String address) throws MBeanException { try { if ("".equals(location)) { location = null; } if ("".equals(javaOpts)) { javaOpts = null; } InstanceSettings settings = new InstanceSettings(sshPort, rmiRegistryPort, rmiServerPort, location, javaOpts, parseStringList(featureURLs), parseStringList(features), address); Instance inst = instanceService.createInstance(name, settings, false); if (inst != null) { return inst.getPid(); } else { return -1; } } catch (Exception e) { throw new MBeanException(null, e.toString()); } }
int port = getExistingInstance(instance).getSshPort(); if (username != null) { if (password == null) {
protected Object doExecute() throws Exception { Instance[] instances = getInstanceService().getInstances(); ShellTable table = new ShellTable(); table.column("SSH Port").alignRight(); table.column("SSH Host").alignRight(); table.column("RMI Registry").alignRight(); table.column("RMI Registry Host").alignRight(); table.column("RMI Server").alignRight(); table.column("RMI Server Host").alignRight(); table.column("State"); table.column("PID"); table.column(getRightColumnHeader()); for (Instance instance : instances) { table.addRow().addContent( instance.getSshPort(), instance.getSshHost(), instance.getRmiRegistryPort(), instance.getRmiRegistryHost(), instance.getRmiServerPort(), instance.getRmiServerHost(), instance.getState(), instance.getPid(), getRightColumnValue(instance)); } table.print(System.out, !noFormat); return null; }
private String getRightColumnValue(Instance instance) { if (javaOpts) { return instance.getJavaOpts(); } else if (location) { return instance.getLocation(); } else { return instance.getName(); } }
String opts = javaOpts; if (opts == null) { opts = instance.getJavaOpts(); opts += DEBUG_OPTS; instance.restart(opts); } catch (Exception e) { exception.addException(e); boolean allStarted = true; for (Instance child : toWaitFor) { allStarted &= Instance.STARTED.equals(child.getState());
protected boolean acceptsInstance(Instance instance) { try { return instance.getState().equals(Instance.STARTED); } catch (Exception e) { return false; } } }
public void startInstance(String name) throws MBeanException { try { getExistingInstance(name).start(null); } catch (Exception e) { throw new MBeanException(null, e.toString()); } }
protected List<Instance> getMatchingInstances(List<String> patterns) { List<Instance> instances = new ArrayList<>(); Instance[] allInstances = instanceService.getInstances(); for (Instance instance : allInstances) { if (match(instance.getName(), patterns)) { instances.add(instance); } } if (instances.isEmpty()) { throw new IllegalArgumentException("No matching instances"); } return instances; }
public int createInstance(String name, int sshPort, int rmiRegistryPort, int rmiServerPort, String location, String javaOpts, String features, String featureURLs, String address) throws MBeanException { try { if ("".equals(location)) { location = null; } if ("".equals(javaOpts)) { javaOpts = null; } InstanceSettings settings = new InstanceSettings(sshPort, rmiRegistryPort, rmiServerPort, location, javaOpts, parseStringList(featureURLs), parseStringList(features), address); Instance inst = instanceService.createInstance(name, settings, false); if (inst != null) { return inst.getPid(); } else { return -1; } } catch (Exception e) { throw new MBeanException(null, e.toString()); } }
int port = getExistingInstance(instance).getSshPort(); if (username != null) { if (password == null) {