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