Package com.sun.faban.common

Examples of com.sun.faban.common.Command


     */
    @Stop public void shutdown() {
        for (int i = 0; i < myServers.length; i++) {
            Integer retVal = 0;
            try {
                Command stopCmd = new Command(asadminCmd, "stop-domain");
              
                // Run the command in the foreground
                CommandHandle ch = RunContext.exec(myServers[i], stopCmd);

                // Check if the server was even running before stop was issued
View Full Code Here


    /*
   * Check if glassfish server is stopped.
   */
    private static Integer checkServerStopped(String hostName)
            throws Exception {
        Command checkCmd = new Command(asadminCmd, "list-domains");
        CommandHandle handle = RunContext.exec(hostName, checkCmd);
        byte[] output = handle.fetchOutput(Command.STDOUT);
        if (output != null) {
            String outStr = new String(output);
            if (outStr.indexOf("domain1 not running") != -1)
View Full Code Here

     * Starts up the Apache web server.
     */
    @Start public void startup() {
        String cmd = apacheCmd + "start";
        logger.fine("Starting Apache Service with command = "+ cmd);
        Command startCmd = new Command(cmd);
        startCmd.setSynchronous(false); // to run in bg
        for (int i = 0; i < myServers.length; i++) {
            String server = myServers[i];
            try {
                // Run the command in the foreground and wait for the start
View Full Code Here

    @Stop public void shutdown() throws IOException, InterruptedException {
        for (int i = 0; i < myServers.length; i++) {
                //Try to Stop it.
                try {
                    String cmd = apacheCmd + "stop";
                    Command stopCmd = new Command(cmd);
                    stopCmd.setLogLevel(Command.STDOUT, Level.FINE);
                    stopCmd.setLogLevel(Command.STDERR, Level.FINE);

                    // Run the command in the foreground
                    CommandHandle ch = RunContext.exec(myServers[i], stopCmd);
                    // Check if the server was running before stop was issued
                    // If not running, apachectl will print that on stdout
View Full Code Here

        toolCmd.add("-p" + mysqlPass);
        toolCmd.add("-B");
        toolCmd.add("-e");
        toolCmd.add("show global status");
        logger.fine("Setting up mysql command: " + toolCmd);
        cmd = new Command(toolCmd);
        logfile = ctx.getOutputFile();
        // We need two intermediate files for the begin/end snapshots
    logfile1 = logfile + "_1";
    logfile2 = logfile + "_2";
        logger.fine(toolName + " Configured with toolCmd " + toolCmd);
View Full Code Here

     * Get final report by diffing the two logfiles.
     */
    @Postprocess public void getReport() {
    String c = "mysql_diff_status.sh " + logfile1 + " " + logfile2 + " " + logfile;
        logger.fine("Calling " + c);
      Command diffCommand = new Command(c);
      try {
          RunContext.exec(diffCommand);
        } catch (IOException e) {
            logger.log(Level.SEVERE, "Error executing mysql_diff_status.sh", e);
        } catch (InterruptedException e) {
View Full Code Here

                "exit\n";

        // Prepare the command
        toolCmd.add(oracleBin);
        toolCmd.add("sqlplus");
        cmd = new Command(toolCmd);
        cmd.setOutputFile(Command.STDOUT, ctx.getOutputFile());
        cmd.setEnvironment(env);
        cmd.setInput(stdin.getBytes());

    }
View Full Code Here

    @StartRun public void start() throws Exception {

        // Spread the drivers to the systems.
        // Start Agents. Other JVM Options like security policy and logging
        // properties are added by CmdAgent when starting the java command.
        Command c = null;

        HashMap<String, Integer> agentIds =
                                new HashMap<String, Integer>(agents.size());

        // Iterate through all the hosts before coming back for the next set
        // of agents for the first host. Once we're though all agent sets
        // for all hosts, the agentStarted flag will be false and we'll exit
        // the loop.
        boolean agentStarted = true;
        for (int i = 0; agentStarted; i++) {
            agentStarted = false;
            for (String hostName : agentHosts) {
                List<String> agentList = hostAgents.get(hostName);
                if (i >= agentList.size())
                    continue;
                String agentType = agentList.get(i);
                Integer oldAgentId = agentIds.get(agentType);
                int agentId;
                if (oldAgentId == null) {
                    agentIds.put(agentType, 0);
                    agentId = 0;
                } else {
                    agentId = oldAgentId.intValue() + 1;
                    agentIds.put(agentType, agentId);
                }
                logger.info("Starting " + agentType + "Agent[" + agentId +
                        "] on host " + hostName + '.');

                String masterIP = getMasterIP(hostName);
                if (masterIP == null) {
                    masterIP = getMasterIP();
                }

                Command agent = new Command("com.sun.faban.driver.engine." +
                        "AgentImpl", agentType, String.valueOf(agentId),
                        masterIP);

                List<String> env = agentEnv.get(agentType);
                if (env != null) {
                    String[] e = new String[env.size()];
                    e = env.toArray(e);
                    agent.setEnvironment(e);
                }

                agent.setSynchronous(false);
                java(hostName, agent);
                agentStarted = true;
                //Wait for the Agents to register
                try {
                    Thread.sleep(500);
                } catch(InterruptedException e) {
                    logger.severe("Exception Sleeping : " + e);
                    logger.log(Level.FINE, "Exception", e);
                }
            }
        }

        //Wait for all the Agents to register
        try {
            Thread.sleep(5000);
        } catch(InterruptedException e) {
            logger.severe("Exception Sleeping : " + e);
            logger.log(Level.FINE, "Exception", e);
        }

        // Start the master
        c = new Command("-Dbenchmark.config=" + getParamFile(),
                "-Dfaban.outputdir.unique=true",
                "com.sun.faban.driver.engine.MasterImpl");
        c.setSynchronous(false);

        masterHandle = java(c);

        // Wait until the master gets to rampup before we give back control.
        // This will ensure the tools start at correct times.
        java(new Command("com.sun.faban.driver.engine.PingMaster", "RAMPUP"));
        logger.info("Ramp up started");
    }
View Full Code Here

            }
        }
        catch (RemoteException re) {
        }
        try {
            Command c = new Command("/bin/chmod", "a+x", ORACLE_SCRIPT);
            CommandHandle h = cmdAgent.execute(c, null);
            int exitValue = h.exitValue();
            if (exitValue != 0) {
                logger.severe("Could not change mode for "+ ORACLE_SCRIPT +
                        ". Exit value for chmod is " + exitValue);
            }
        }
        catch (Exception e) {
            logger.severe("Could not change mode of " + ORACLE_SCRIPT  + " : " +
                    e.toString());
        }

        logger.fine("Executing command " + sqlCmd);

        Command c = new Command(ORACLE_SCRIPT);
        CommandHandle h = cmdAgent.execute(c, null);
        int exitValue = h.exitValue();
        boolean retVal;
        if (exitValue == 0) {
            logger.fine("Command executed successfully");
View Full Code Here

            logger.severe("Could not write to " + ORACLE_SCRIPT + " " + re);
            logger.log(Level.FINE, "RemoteException", re);
        }

        try {
            Command c = new Command("/bin/chmod", "a+x", ORACLE_SCRIPT);
            CommandHandle h = cmdAgent.execute(c, null);
            int exitValue = h.exitValue();
            if (exitValue != 0) {
                logger.severe("Could not change mode for "+ ORACLE_SCRIPT +
                        ". Exit value for chmod is " + exitValue);
            }
        }
        catch (Exception e) {
            logger.severe("Could not change mode of " + ORACLE_SCRIPT + " : " + e);
            logger.log(Level.FINE, "Exception", e);
        }

        logger.fine("Executing command " + cmd);

        Command c = new Command(ORACLE_SCRIPT);
        CommandHandle h = cmdAgent.execute(c, null);
        int exitValue = h.exitValue();
        boolean retVal;
        if (exitValue == 0) {
            logger.info("Listener started.");
View Full Code Here

TOP

Related Classes of com.sun.faban.common.Command

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.