Package org.glassfish.api.admin

Examples of org.glassfish.api.admin.CommandException


            logger.finer("RemoteCommand.prepare throws " + cex);
            throw cex;
        }
        catch (Exception e) {
            logger.finer("RemoteCommand.prepare throws " + e);
            throw new CommandException(e.getMessage());
        }
    }
View Full Code Here


    }

    ParameterMap getParameters(String command, String[] args) throws CommandException {
        CommandModel commandModel = commandRunner.getModel(command, logger);
        if (commandModel == null) {
            throw new CommandException("Command lookup failed for command " + command);
        }

        // Filter out the global options.
        // We are interested only in --passwordfile option. No other options are relevant when GlassFish is running in embedded mode.
        Parser parser = new Parser(args, 0, ProgramOptions.getValidOptions(), true);
View Full Code Here

        } catch (CommandException cex) {
            logger.finer("RemoteCommand.prepare throws " + cex);
            throw cex;
        } catch (Exception e) {
            logger.finer("RemoteCommand.prepare throws " + e);
            throw new CommandException(e.getMessage());
        }
    }
View Full Code Here

            List<HostAndPort> addrSet = parser.getAdminAddresses();

            if (addrSet.size() > 0)
                return addrSet.get(0);
            else
                throw new CommandException(strings.get("NoAdminPort"));
        }
        catch (MiniXmlParserException ex) {
            throw new CommandException(strings.get("NoAdminPortEx", ex), ex);
        }
    }
View Full Code Here

            catch (Exception e) {
                // continue
            }
        }
        // if we get here -- we timed out
        throw new CommandException(strings.get("restartDomain.noGFStart"));
    }
View Full Code Here

        // we are using local-password for authentication to the local server.  We need
        // to use the NEW password that will be soon generated.  After that we can
        // do Uptime calls to make sure V3 is ready to receive commands

        if (!usingLocalPassword())
            throw new CommandException("Internal Error - waitForRestartLocal should "
                    + "not be called unless using local password authentication.");

        long end = CLIConstants.WAIT_FOR_DAS_TIME_MS
                + now();

        while (now() < end) {
            // when the server has restarted the passwordfile will be different
            // don't waste time reading the file again and again, just look
            // for the time stamp to change.
            // Careful -- there is a slice of time where the file does not exist!
            try {
                long newTimeStamp = pwFile.lastModified(); // could be 0L
                logger.log(Level.FINER,"Checking timestamp of local-password. old: {0}, new: {1}",
                        new Object[]{oldTimeStamp, newTimeStamp});

                if (newTimeStamp > oldTimeStamp) {
                    // Server has restarted but may not be quite ready to handle commands
                    // automated tests would have issues if we returned right here...
                    resetLocalPassword();
                    // use the maximum old uptime because we know that the server has already restarted
                    //waitForRestartRemote(Long.MAX_VALUE);
                    deprecatedWaitForRestartRemote(0);
                    return;
                }
                Thread.sleep(CLIConstants.RESTART_CHECK_INTERVAL_MSEC);
            }
            catch (Exception e) {
                // continue
            }
        }
        // if we get here -- we timed out
        throw new CommandException(strings.get("restartDomain.noGFStart"));
    }
View Full Code Here

            catch (Exception e) {
                // continue
            }
        }
        // if we get here -- we timed out
        throw new CommandException(strings.get("restartDomain.noGFStart"));
    }
View Full Code Here

        RemoteCLICommand cmd = new RemoteCLICommand("uptime", programOpts, env);
        String up = cmd.executeAndReturnOutput("uptime", "--milliseconds").trim();
        long up_ms = parseUptime(up);

        if (up_ms <= 0) {
            throw new CommandException(strings.get("restart.dasNotRunning"));
        }

        logger.log(Level.FINER, "server uptime: {0}", up_ms);
        return up_ms;
    }
View Full Code Here

        for (int i = 0; i < times; i++) {
            // XXX - I18N
            String prompt = strings.get("mp.prompt", (times - i));
            mpv = super.readPassword(prompt);
            if (mpv == null)
                throw new CommandException(strings.get("no.console"));
            // ignore retries :)
            if (verifyMasterPassword(mpv))
                return mpv;
            if (i < (times - 1))
                logger.info(strings.get("retry.mp"));
            // make them pay for typos?
            //Thread.currentThread().sleep((i+1)*10000);
        }
        throw new CommandException(strings.get("mp.giveup", times));
    }
View Full Code Here

                    sname = "instance " + info.getInstanceName();

                ProcessStreamDrainer psd = launcher.getProcessStreamDrainer();
                String output = psd.getOutErrString();
                if (ok(output))
                    throw new CommandException(strings.get("serverDiedOutput",
                            sname, exitCode, output));
                else
                    throw new CommandException(strings.get("serverDied",
                            sname, exitCode));
            }
            catch (GFLauncherException ex) {
                // should never happen
            }
            catch (IllegalThreadStateException ex) {
                // process is still alive
            }

            // wait before checking again
            try {
                Thread.sleep(100);
                if (!terse && count++ % 10 == 0)
                    System.out.print(".");
            }
            catch (InterruptedException ex) {
                // don't care
            }
        }

        if (!terse)
            System.out.println();

        if (!alive) {
            String msg;
            String time = "" + (WAIT_FOR_DAS_TIME_MS / 1000);
            if (info.isDomain())
                msg = strings.get("serverNoStart", strings.get("DAS"),
                        info.getDomainName(), time);
            else
                msg = strings.get("serverNoStart", strings.get("INSTANCE"),
                        info.getInstanceName(), time);

            throw new CommandException(msg);
        }
    }
View Full Code Here

TOP

Related Classes of org.glassfish.api.admin.CommandException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.