Package org.jfx4ee.adm4ee.business.util

Examples of org.jfx4ee.adm4ee.business.util.CommandResult


        if (domainName == null) {
            throw new IllegalArgumentException("No domain name specified!");
        }
        int timeoutMsec = 8000;
        boolean destroyAfterTimeout = false;
        CommandResult result = SystemCommandExecutor.execute(Arrays.asList(standaloneCommand), 1024, timeoutMsec, destroyAfterTimeout);
        if (result.isOk()) {
            // It is OK if the process is still running
            // Poll until server is really up
            for (int i = 0; i < 10; i++) {
                CommandResult r = pingManagementResource();
                if (r.isOk()) {
                    break;
                }
                try {
                    Thread.sleep(1200);
                } catch (InterruptedException ex) {
View Full Code Here


        return result;
    }

    @Override
    public CommandResult stopDomain() {
        CommandResult result = restManager.stopServer();
        if (result.isOk()) {
            // Poll until server is really down
            for (int i = 0; i < 10; i++) {
                CommandResult r = pingManagementResource();
                if (CommandResult.EXIT_CODE_UNKNOWN == r.getExitCode()) {
                    break;
                }
                try {
                    Thread.sleep(1200);
                } catch (InterruptedException ex) {
View Full Code Here

        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public CommandResult pingManagementResource() {
        CommandResult result;
        try {
            result = restManager.ping();
        } catch (Exception ex) {
            // Could not fetch requested information
            logger.log(Level.FINE, "Could not ping management URL using {0}: {1}", new Object[]{restManager.getManagementUrl(), ex});
            result = new CommandResult(ex);
        }
        return result;
    }
View Full Code Here

        return result;
    }

    @Override
    public CommandResult getLogFileContent(long characters) {
        CommandResult result;
        if (standaloneCommand != null) {
            try {
                result = new CommandResult(readBytesFromFileEnd(getDomainPath().resolve(LOG_PATH).resolve(LOG_FILE_NAME).toString(), characters));
            } catch (Exception ex1) {
                result = new CommandResult(ex1);
            }
        } else {
            result = new CommandResult(new Exception("Domain not configured"));
        }
        return result;
    }
View Full Code Here

        }
        super.close();
    }

    protected void updateJvmVersion() {
        CommandResult result = restManager.getJvmVersion();
        if (result.isOk()) {
            Matcher jdkVersionMatcher = PATTERN_JDK_VERSION.matcher(result.getResult());
            if (jdkVersionMatcher.find()) {
                localJdkVersion = jdkVersionMatcher.group(1);
            }
        }
    }
View Full Code Here

    /**
     * Initialize local version from asadmin command
     */
    protected void initLocalVersions() {
        CommandResult commandResult = SystemCommandExecutor.execute(Arrays.asList(standaloneCommand, "--version"));
        // Tbe return code here is always 1
        if (commandResult.getExitCode() == 1) {
            String output = commandResult.getResult();
            Matcher versionMatcher = PATTERN_VERSION_LOCAL.matcher(output);
            // Get the last match
            while (versionMatcher.find()) {
                localVersion = versionMatcher.group(1);
            }

            CommandResult jdkVersionCommand = SystemCommandExecutor.execute(Arrays.asList(adminCommand, "version"));
            if (jdkVersionCommand.isOk()) {
                String adminOutput = jdkVersionCommand.getResult();
                Matcher jdkVersionMatcher = PATTERN_JDK_VERSION_LOCAL.matcher(adminOutput);
                if (jdkVersionMatcher.find()) {
                    localJdkVersion = jdkVersionMatcher.group(1);
                }
            } else {
                logger.log(Level.SEVERE, "Could not initialize local version information from admin command: {0}: {1}", new Object[]{jdkVersionCommand.getResult(), jdkVersionCommand.getThrowable()});
            }
        } else {
            logger.log(Level.SEVERE, "Could not initialize local version information from admin command: {0}: {1}", new Object[]{commandResult.getResult(), commandResult.getThrowable()});
        }
    }
View Full Code Here

                .request(MediaType.APPLICATION_JSON)
                .delete(Response.class);
    }
   
    protected CommandResult handleJsonResponse(Response response) {
        CommandResult result = new CommandResult();
        if (response != null) {
            // Check HTTP Status
            if (response.getStatus() != Response.Status.OK.getStatusCode()) {
                result.setExitCode(response.getStatus());
                result.setExitCodeInfo(response.getStatusInfo().toString());
            }
            try {
                JsonObject json = response.readEntity(JsonObject.class);
                JsonString message = json.getJsonString(JSON_OBJECT_MESSAGE);
                if (message != null) {
                    result.setResult(message.toString());
                }
                JsonString exitCode = json.getJsonString("exit_code");
                if (exitCode != null) {
                    if ("SUCCESS".equals(exitCode.getString())) {
                        result.setExitCodeOk();
                    }
                }
            } catch (Exception ex) {
                result.setResult("Could not read result from server.");
                result.setThrowable(ex);
            }
        }
        return result;
    }
View Full Code Here

    }

    @Test
    public void testPing() {
        System.out.println("testPing(): ");
        CommandResult result = manager.ping();
        System.out.println(result.getResult());
    }
View Full Code Here

        } else if (commandLine.hasOption("start")) {
            Domain domain = getDomain(commandLine.getOptionValue("start"));
            ServerHandler serverHandler = ServerHandler.getInstance(domain);
            Server server = serverHandler.getServer();
            server.initLocalServer();
            CommandResult result = server.startDomain(domain.getDomainName());
            System.exit(result.getExitCode());

        } else if (commandLine.hasOption("stop")) {
            Domain domain = getDomain(commandLine.getOptionValue("stop"));
            ServerHandler serverHandler = ServerHandler.getInstance(domain);
            Server server = serverHandler.getServer();
            server.initLocalServer();
            server.initLocalDomain();
            CommandResult result = server.stopDomain();
            System.exit(result.getExitCode());

        } else if (commandLine.hasOption("watchdog")) {
            watchdog();

        } else if (commandLine.hasOption("ping")) {
View Full Code Here

        Domain domain = getDomain(commandLine.getOptionValue("ping"));
        ServerHandler serverHandler = ServerHandler.getInstance(domain);
        Server server = serverHandler.getServer();
        server.initLocalServer();
        server.initLocalDomain();
        CommandResult result = server.pingManagementResource();
        if (result.isOk()) {
            System.out.println("SUCCESS");
        } else {
            System.out.println("FAILURE");
        }
        System.exit(result.getExitCode());
    }
View Full Code Here

TOP

Related Classes of org.jfx4ee.adm4ee.business.util.CommandResult

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.