use of com.sun.enterprise.admin.util.InstanceCommandExecutor in project Payara by payara.
the class InstanceInfo method getFutureResult.
private void getFutureResult() {
try {
InstanceCommandResult r = future.get(timeoutInMsec, TimeUnit.MILLISECONDS);
InstanceCommandExecutor res = (InstanceCommandExecutor) r.getInstanceCommand();
String instanceLocation = res.getCommandOutput();
// Remove the pesky \n out
instanceLocation = (instanceLocation == null) ? "" : instanceLocation.trim();
if ((!instanceLocation.endsWith(res.getServer().getName())) || (res.getReport().getActionExitCode() != ActionReport.ExitCode.SUCCESS)) {
uptime = -1;
state = NOT_RUNNING;
running = false;
pid = -1;
ssState = stateService.setState(name, InstanceState.StateType.NOT_RUNNING, false);
} else {
Properties props = res.getReport().getTopMessagePart().getProps();
String uptimeStr = props.getProperty("Uptime");
String pidstr = props.getProperty("Pid");
String restartstr = props.getProperty("Restart-Required");
try {
pid = Integer.parseInt(pidstr);
} catch (Exception e) {
// no I don't want to use the enclosing catch...
pid = -1;
}
ssState = stateService.setState(name, Boolean.parseBoolean(restartstr) ? InstanceState.StateType.RESTART_REQUIRED : InstanceState.StateType.RUNNING, false);
uptime = Long.parseLong(uptimeStr);
state = formatTime(uptime);
running = true;
}
} catch (Exception e) {
uptime = -1;
state = NOT_RUNNING;
ssState = stateService.setState(name, InstanceState.StateType.NOT_RUNNING, false);
running = false;
pid = -1;
}
}
use of com.sun.enterprise.admin.util.InstanceCommandExecutor in project Payara by payara.
the class InstanceInfo method pingInstance.
// TODO what about security????
private Future<InstanceCommandResult> pingInstance() {
try {
ActionReport aReport = report.addSubActionsReport();
InstanceCommandResult aResult = new InstanceCommandResult();
ParameterMap map = new ParameterMap();
map.set("type", "terse");
InstanceCommandExecutor ice = new InstanceCommandExecutor(habitat, "__locations", FailurePolicy.Error, FailurePolicy.Error, svr, host, port, logger, map, aReport, aResult);
return stateService.submitJob(svr, ice, aResult);
/*
String ret = rac.executeCommand(map).trim();
if (ret == null || (!ret.endsWith("/" + name)))
return -1;
running = true;
String uptimeStr = rac.getAttributes().get("Uptime_value");
return Long.parseLong(uptimeStr);
*/
} catch (CommandException ex) {
running = false;
return null;
}
}
Aggregations