use of com.sun.enterprise.admin.remote.RemoteRestAdminCommand in project Payara by payara.
the class ChangeAdminPasswordCommand method executeCommand.
/**
* Execute the remote command using the parameters we've collected.
*/
@Override
protected int executeCommand() throws CommandException {
if (ok(domainDirParam) || ok(userArgDomainName)) {
// If domaindir or domain arguments are provided,
// do not attempt remote connection. Change password locally
String domainDir = (ok(domainDirParam)) ? domainDirParam : getDomainsDir().getPath();
String domainName = (ok(userArgDomainName)) ? userArgDomainName : getDomainName();
return changeAdminPasswordLocally(domainDir, domainName);
} else {
try {
RemoteRestAdminCommand rac = new RemoteRestAdminCommand(name, programOpts.getHost(), programOpts.getPort(), programOpts.isSecure(), programOpts.getUser(), programOpts.getPassword(), logger, false);
rac.executeCommand(params);
return SUCCESS;
} catch (CommandException ce) {
if (ce.getCause() instanceof ConnectException) {
// domaindir and domain name,if the --host option is not provided.
if (!isLocalHost(programOpts.getHost())) {
throw ce;
}
return changeAdminPasswordLocally(getDomainsDir().getPath(), getDomainName());
} else {
throw ce;
}
}
}
}
use of com.sun.enterprise.admin.remote.RemoteRestAdminCommand in project Payara by payara.
the class RestartInstanceCommand method getPid.
private String getPid() throws CommandException {
String cmdName = "_get-runtime-info";
RemoteRestAdminCommand rac = createRac(cmdName);
rac.executeCommand(new ParameterMap());
return rac.findPropertyInReport("pid");
}
use of com.sun.enterprise.admin.remote.RemoteRestAdminCommand in project Payara by payara.
the class RestartInstanceCommand method callInstance.
/**
* 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);
}
use of com.sun.enterprise.admin.remote.RemoteRestAdminCommand in project Payara by payara.
the class RestartInstanceCommand method isInstanceRestartable.
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) {
// 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;
}
use of com.sun.enterprise.admin.remote.RemoteRestAdminCommand in project Payara by payara.
the class StopInstanceCommand method callInstance.
/**
* return null if all went OK...
*/
private String callInstance() {
String msg = initializeInstance();
if (msg != null)
return msg;
String host = instance.getAdminHost();
if (host == null)
return Strings.get("stop.instance.noHost", instanceName);
int port = helper.getAdminPort(instance);
if (port < 0)
return Strings.get("stop.instance.noPort", instanceName);
if (!instance.isRunning())
return null;
try {
logger.info(Strings.get("stop.instance.init", instanceName));
RemoteRestAdminCommand rac = new ServerRemoteRestAdminCommand(habitat, "_stop-instance", host, port, false, "admin", null, logger);
// notice how we do NOT send in the instance's name as an operand!!
ParameterMap map = new ParameterMap();
map.add("force", Boolean.toString(force));
rac.executeCommand(map);
} catch (Exception e) {
// The instance server may have died so fast we didn't have time to
// get the (always successful!!) return data. This is NOT AN ERROR!
// see: http://java.net/jira/browse/GLASSFISH-19672
// also see StopDomainCommand which does the same thing.
}
return null;
}
Aggregations