Search in sources :

Example 6 with RemoteCLICommand

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());
    }
}
Also used : RemoteCLICommand(com.sun.enterprise.admin.cli.remote.RemoteCLICommand)

Example 7 with RemoteCLICommand

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));
    }
}
Also used : RemoteCLICommand(com.sun.enterprise.admin.cli.remote.RemoteCLICommand)

Example 8 with RemoteCLICommand

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;
}
Also used : RemoteCLICommand(com.sun.enterprise.admin.cli.remote.RemoteCLICommand)

Example 9 with RemoteCLICommand

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;
}
Also used : RemoteCLICommand(com.sun.enterprise.admin.cli.remote.RemoteCLICommand)

Example 10 with RemoteCLICommand

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;
    }
}
Also used : RemoteCLICommand(com.sun.enterprise.admin.cli.remote.RemoteCLICommand)

Aggregations

RemoteCLICommand (com.sun.enterprise.admin.cli.remote.RemoteCLICommand)26 CommandException (org.glassfish.api.admin.CommandException)8 ActionReport (org.glassfish.api.ActionReport)4 ArrayList (java.util.ArrayList)3 DomainException (com.sun.enterprise.admin.servermgmt.DomainException)2 BackupException (com.sun.enterprise.backup.BackupException)2 BackupWarningException (com.sun.enterprise.backup.BackupWarningException)2 IOException (java.io.IOException)2 RemoteCommand (com.sun.enterprise.admin.cli.remote.RemoteCommand)1 SmartFile (com.sun.enterprise.universal.io.SmartFile)1 MiniXmlParserException (com.sun.enterprise.universal.xml.MiniXmlParserException)1 SyncRequest (com.sun.enterprise.util.cluster.SyncRequest)1 File (java.io.File)1 ConnectException (java.net.ConnectException)1 Singleton (javax.inject.Singleton)1 MessagePart (org.glassfish.api.ActionReport.MessagePart)1 ParamModel (org.glassfish.api.admin.CommandModel.ParamModel)1 CommandValidationException (org.glassfish.api.admin.CommandValidationException)1