Search in sources :

Example 1 with ServerRemoteRestAdminCommand

use of com.sun.enterprise.admin.remote.ServerRemoteRestAdminCommand 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;
}
Also used : ParameterMap(org.glassfish.api.admin.ParameterMap) RemoteRestAdminCommand(com.sun.enterprise.admin.remote.RemoteRestAdminCommand) ServerRemoteRestAdminCommand(com.sun.enterprise.admin.remote.ServerRemoteRestAdminCommand) ServerRemoteRestAdminCommand(com.sun.enterprise.admin.remote.ServerRemoteRestAdminCommand) WindowsException(com.sun.enterprise.util.cluster.windows.process.WindowsException) CommandException(org.glassfish.api.admin.CommandException) IOException(java.io.IOException)

Aggregations

RemoteRestAdminCommand (com.sun.enterprise.admin.remote.RemoteRestAdminCommand)1 ServerRemoteRestAdminCommand (com.sun.enterprise.admin.remote.ServerRemoteRestAdminCommand)1 WindowsException (com.sun.enterprise.util.cluster.windows.process.WindowsException)1 IOException (java.io.IOException)1 CommandException (org.glassfish.api.admin.CommandException)1 ParameterMap (org.glassfish.api.admin.ParameterMap)1