Package org.glassfish.api.admin

Examples of org.glassfish.api.admin.CommandException


            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

            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

        // 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
                + System.currentTimeMillis();

        while (System.currentTimeMillis() < 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...
                    resetServerDirs();
                    programOpts.setPassword(getServerDirs().getLocalPassword(), ProgramOptions.PasswordLocation.LOCAL_PASSWORD);
                    waitForRestartRemote(uptimeOldServer);
                    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

            manager.validateDomain(config, false);
            verifyPortBase();
        }
        catch (DomainException e) {
            logger.fine(e.getLocalizedMessage());
            throw new CommandException(
                    strings.get("CouldNotCreateDomain", domainName), e);
        }

        /*
         * The admin user is specified with the --user program option. If not
         * specified (because the user hit Enter at the prompt), we use the
         * default, which allows unauthenticated login.
         */
        adminUser = programOpts.getUser();
        if (!ok(adminUser)) {
            adminUser = SystemPropertyConstants.DEFAULT_ADMIN_USER;
            adminPassword = SystemPropertyConstants.DEFAULT_ADMIN_PASSWORD;
        }
        else if (noPassword) {
            adminPassword = SystemPropertyConstants.DEFAULT_ADMIN_PASSWORD;
        }
        else {
            adminPassword = getAdminPassword();
            boolean haveAdminPwd = true;
        }

        if (saveMasterPassword)
            useMasterPassword = true;

        if (masterPassword == null)
            masterPassword = DEFAULT_MASTER_PASSWORD;

        try {
            // verify admin port is valid if specified on command line
            if (adminPort != null) {
                verifyPortIsValid(adminPort);
            }
            // instance option is entered then verify instance port is valid
            if (instancePort != null) {
                verifyPortIsValid(instancePort);
            }

            // saving the login information happens inside this method
            createTheDomain(domainDir, domainProperties);
        }
        catch (CommandException ce) {
            logger.info(ce.getLocalizedMessage());
            throw new CommandException(
                    strings.get("CouldNotCreateDomain", domainName), ce);
        }
        catch (Exception e) {
            logger.fine(e.getLocalizedMessage());
            throw new CommandException(
                    strings.get("CouldNotCreateDomain", domainName), e);
        }
        return 0;
    }
View Full Code Here

            throws CommandException, CommandValidationException {

        final int portToVerify = convertPortStr(portNum);

        if (!NetUtils.isPortValid(portToVerify))
            throw new CommandException(strings.get("InvalidPortRange", portNum));

        if (checkPorts == false) {
            // do NOT make any network calls!
            logger.log(Level.FINER, "Port ={0}", portToVerify);
            return;
        }

        NetUtils.PortAvailability avail = NetUtils.checkPort(portToVerify);

        switch (avail) {
            case illegalNumber:
                throw new CommandException(
                        strings.get("InvalidPortRange", portNum));

            case inUse:
                throw new CommandException(
                        strings.get("PortInUseError", domainName, portNum));

            case noPermission:
                throw new CommandException(
                        strings.get("NoPermissionForPortError",
                        portNum, domainName));

            case unknown:
                throw new CommandException(strings.get("UnknownPortMsg", portNum));

            case OK:
                logger.log(Level.FINER, "Port ={0}", portToVerify);
                break;
            default:
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.