use of com.sun.enterprise.admin.cli.remote.RemoteCLICommand in project Payara by payara.
the class DeleteLocalInstanceCommand method doRemote.
/**
* Ask DAS to wipe it out from domain.xml
* If DAS isn't running -- ERROR -- return right away with a thrown Exception
* If DAS is running, and instance not registered on DAS, do not unregister instance -- OK
* If DAS is running, and instance is registered on DAS, then unregister instance -- OK
* - If _unregister-instance is successful - OK
* - If _unregister-instance fails - ERROR - Exception thrown
*/
private void doRemote() throws CommandException {
if (!isDASRunning()) {
String newString = Strings.get("DeleteInstance.remoteError", programOpts.getHost(), "" + programOpts.getPort());
throw new CommandException(newString);
}
if (isRegisteredToDas()) {
RemoteCLICommand rc = new RemoteCLICommand("_unregister-instance", programOpts, env);
rc.execute("_unregister-instance", getServerDirs().getServerName());
}
}
use of com.sun.enterprise.admin.cli.remote.RemoteCLICommand in project Payara by payara.
the class ImportSyncBundleCommand method setRendezvousOccurred.
private void setRendezvousOccurred(String rendezVal) {
String dottedName = RENDEZVOUS_DOTTED_NAME + "=" + rendezVal;
try {
RemoteCLICommand rc = new RemoteCLICommand("set", this.programOpts, this.env);
rc.executeAndReturnOutput("set", dottedName);
} catch (CommandException ex) {
logger.warning(Strings.get("import.sync.bundle.completeRegistrationFailed", dottedName));
}
}
use of com.sun.enterprise.admin.cli.remote.RemoteCLICommand in project Payara by payara.
the class LocalInstanceCommand method getNodeInstallDir.
protected String getNodeInstallDir() throws CommandException {
String installDir = null;
try {
RemoteCLICommand rc = new RemoteCLICommand("get", this.programOpts, this.env);
String s = rc.executeAndReturnOutput("get", "nodes.node." + node + ".install-dir");
if (s != null) {
installDir = s.substring(s.indexOf('=') + 1);
}
} catch (CommandException ce) {
// ignore
}
return installDir;
}
use of com.sun.enterprise.admin.cli.remote.RemoteCLICommand in project Payara by payara.
the class RestartLocalInstanceCommand method doRemoteCommand.
protected final int doRemoteCommand() throws CommandException {
// see StopLocalInstance for comments. These 2 lines can be refactored.
setLocalPassword();
programOpts.setInteractive(false);
if (!isRestartable()) {
throw new CommandException(Strings.get("restart.notRestartable"));
}
// might be < 0
int oldServerPid = getServerPid();
// run the remote restart-domain command and throw away the output
RemoteCLICommand cmd = new RemoteCLICommand("_restart-instance", programOpts, env);
if (debug != null) {
cmd.executeAndReturnOutput("_restart-instance", "--debug", debug.toString());
} else {
cmd.executeAndReturnOutput("_restart-instance");
}
waitForRestart(oldServerPid);
return 0;
}
use of com.sun.enterprise.admin.cli.remote.RemoteCLICommand in project Payara by payara.
the class StopLocalInstanceCommand method runRemoteStop.
/**
* run the remote stop-domain command and throw away the output
* the calling code has already verified the server is running.
* Careful changing this code, starting and stopping can be an intricate dance.
* Note how we are catching *ALL* Exceptions. This is because the ReST code
* does NOT catch unchecked exceptions. The key idea here is that:
* 1. we first verify the server is indeed running
* 2. we tell the server to stop. This is a special case. IO streams might be
* broken, all sorts of things that are 'bad' for normal commands can happen.
* But we don't care! We only care that the server is now dead:
* 3. Verify the server is NOT running any longer.
* When this method is called , (1) is already true. We do (2) here and ignore
* all errors. Then we return to the caller which will do (3)
*
* @return Exception in case the server didn't stop we can log the exception...
*/
private Exception runRemoteStop() {
// 2 catch blocks just to make things crystal clear.
try {
RemoteCLICommand cmd = new RemoteCLICommand("_stop-instance", programOpts, env);
cmd.executeAndReturnOutput("_stop-instance", "--force", force.toString());
return null;
} catch (CommandException e) {
// is NOT an error.
return e;
} catch (Exception e) {
// We don't care. See the huge javadoc comment above...
return e;
}
}
Aggregations