private void waitForRestart() { if (isError()) return; long deadline = System.currentTimeMillis() + WAIT_TIME_MS; while (System.currentTimeMillis() < deadline) { try { String newpid = getPid(); // when the next statement is true -- the server has restarted. if (StringUtils.ok(newpid) && !newpid.equals(oldPid)) { if (logger.isLoggable(Level.FINE)) logger.fine("Restarted instance pid = " + newpid); return; } } catch (Exception e) { // ignore. This is normal! } } setError(Strings.get("restart.instance.timeout", instanceName)); }
private void waitForRestart() { if (isError()) return; long deadline = System.currentTimeMillis() + WAIT_TIME_MS; while (System.currentTimeMillis() < deadline) { try { String newpid = getPid(); // when the next statement is true -- the server has restarted. if (StringUtils.ok(newpid) && !newpid.equals(oldPid)) { logger.fine("Restarted instance pid = " + newpid); return; } } catch (Exception e) { // ignore. This is normal! } } setError(Strings.get("restart.instance.timeout", instanceName)); }
private boolean isInstanceRestartable() throws InstanceNotRunningException { if (isError()) return false; String cmdName = "_get-runtime-info"; RemoteAdminCommand rac; try { rac = createRac(cmdName); rac.executeCommand(new ParameterMap()); } catch (CommandException ex) { // there is only one reason that _get-runtime-info would have a problem // namely if the instance isn't running. throw new InstanceNotRunningException(); } Map<String, String> atts = rac.getAttributes(); if (atts != null) { String val = atts.get("restartable_value"); if (val != null && val.equals("false")) return false; } return true; }
private void setOldPid() throws CommandException { if (isError()) return; oldPid = getPid(); if (!StringUtils.ok(oldPid)) setError(Strings.get("restart.instance.nopid", instanceName)); }
private void setOldPid() throws CommandException { if (isError()) return; oldPid = getPid(); if (!StringUtils.ok(oldPid)) setError(Strings.get("restart.instance.nopid", instanceName)); }
/** * return null if all went OK... * */ private void callInstance() throws CommandException { if (isError()) return; String cmdName = "_restart-instance"; RemoteAdminCommand rac = createRac(cmdName); // notice how we do NOT send in the instance's name as an operand!! ParameterMap map = new ParameterMap(); if (debug != null) map.add("debug", debug); rac.executeCommand(map); }
private boolean isInstanceRestartable() throws InstanceNotRunningException { if (isError()) return false; String cmdName = "_get-runtime-info"; RemoteRestAdminCommand rac; try { rac = createRac(cmdName); rac.executeCommand(new ParameterMap()); } catch (CommandException ex) { // there is only one reason that _get-runtime-info would have a problem // namely if the instance isn't running. throw new InstanceNotRunningException(); } String val = rac.findPropertyInReport("restartable"); if (val != null && val.equals("false")) { return false; } return true; }
/** * return null if all went OK... * */ private void callInstance() throws CommandException { if (isError()) return; String cmdName = "_restart-instance"; RemoteRestAdminCommand rac = createRac(cmdName); // notice how we do NOT send in the instance's name as an operand!! ParameterMap map = new ParameterMap(); if (debug != null) map.add("debug", debug); rac.executeCommand(map); }
private void start() { // be VERY careful -- we are being called from within a catch block... Exception exception = null; try { StartInstanceCommand sic = new StartInstanceCommand(habitat, instanceName, Boolean.parseBoolean(debug), env); sic.execute(ctx); } catch (Exception e) { // this is NOT normal! start-instance communicates errors via the // reporter. This catch should never happen. It is here for robustness. // and especially for programmer/regression errors. exception = e; // Perhaps a NPE or something **after** the report was set to success??? report.setActionExitCode(ActionReport.ExitCode.FAILURE); } // save start-instance's message String messageFromStartCommand = report.getMessage(); String exceptionMessage = ""; if (exception != null) exceptionMessage = Strings.get("restart.instance.exception", exception); if (isError()) setError(Strings.get("restart.instance.startFailed", exceptionMessage, messageFromStartCommand)); else setSuccess(Strings.get("restart.instance.startSucceeded", messageFromStartCommand)); }
private void start() { // be VERY careful -- we are being called from within a catch block... Exception exception = null; try { StartInstanceCommand sic = new StartInstanceCommand(habitat, instanceName, Boolean.parseBoolean(debug), env); sic.execute(ctx); } catch (Exception e) { // this is NOT normal! start-instance communicates errors via the // reporter. This catch should never happen. It is here for robustness. // and especially for programmer/regression errors. exception = e; // Perhaps a NPE or something **after** the report was set to success??? report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(e); } // save start-instance's message String messageFromStartCommand = report.getMessage(); if (isError()) { setError(Strings.get("restart.instance.startFailed", messageFromStartCommand)); } else { setSuccess(Strings.get("restart.instance.startSucceeded", messageFromStartCommand)); } }
waitForRestart(); if (!isError()) { String msg = Strings.get("restart.instance.success", instanceName); logger.info(msg);
private void prepare() throws InstanceNotRunningException { if (isError()) return; if (!StringUtils.ok(instanceName)) { setError(Strings.get("stop.instance.noInstanceName")); return; } instance = helper.getServer(instanceName); if (instance == null) { setError(Strings.get("stop.instance.noSuchInstance", instanceName)); return; } host = instance.getAdminHost(); if (host == null) { setError(Strings.get("stop.instance.noHost", instanceName)); return; } port = helper.getAdminPort(instance); if (port < 0) { setError(Strings.get("stop.instance.noPort", instanceName)); return; } if (!isInstanceRestartable()) setError(Strings.get("restart.notRestartable", instanceName)); if (logger.isLoggable(Level.FINER)) logger.finer(ObjectAnalyzer.toString(this)); }
waitForRestart(); if (!isError()) { String msg = Strings.get("restart.instance.success", instanceName); logger.info(msg);
private void prepare() throws InstanceNotRunningException { if (isError()) return; if (!StringUtils.ok(instanceName)) { setError(Strings.get("stop.instance.noInstanceName")); return; } instance = helper.getServer(instanceName); if (instance == null) { setError(Strings.get("stop.instance.noSuchInstance", instanceName)); return; } host = instance.getAdminHost(); if (host == null) { setError(Strings.get("stop.instance.noHost", instanceName)); return; } port = helper.getAdminPort(instance); if (port < 0) { setError(Strings.get("stop.instance.noPort", instanceName)); return; } if (!isInstanceRestartable()) setError(Strings.get("restart.notRestartable", instanceName)); logger.finer(ObjectAnalyzer.toString(this)); }