Package com.sun.faban.common

Examples of com.sun.faban.common.Command


    /**
     * Starts the tool.
     */
    protected void start() {
        try {
            Command cmd = new Command(toolCmd);
            cmd.setSynchronous(false);
            cmd.setStreamHandling(Command.STDOUT, Command.CAPTURE);
            cmd.setOutputFile(Command.STDOUT, logfile);
            tool = cmdAgent.execute(cmd, null);
        } catch (IOException e) {
            logger.log(Level.SEVERE, "Cannot start tool " + toolName, e);
            finish();
            return;
View Full Code Here


     * @return boolean true if start succeeded on all machines, else false
     */
    public boolean startServers() {

        String cmd = apachectlCmd + "start";
        Command startCmd = new Command(cmd);
        startCmd.setLogLevel(Command.STDOUT, Level.FINE);
        startCmd.setLogLevel(Command.STDERR, Level.FINE);

        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

        boolean success = true;
        for (int i = 0; i < myServers.length; i++) {
            Integer retVal = 0;
            try {
                String cmd = apachectlCmd + "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 even running before stop was issued
View Full Code Here

        // Prepare the command
        String cmd = "sqlplus";
        if (oracleHome != null)
            cmd = oracleHome + File.separator + "bin" + File.separator +
                    "sqlplus";
        sqlplus = new Command(cmd);
        sqlplus.setEnvironment(env);
        sqlplus.setInput(stdin.getBytes());

    }
View Full Code Here

        /*****
                Command parseCommand = new Command("apache_trunc_errorlog.sh \"" +
                        beginDate + "\"" + " \"" + endDate + "\" " +
                        outFile);
        ****/
                Command parseCommand = new Command("apache_trunc_errorlog.sh " +
                        beginDate + " " + endDate + " " + outFile);
                RunContext.exec(parseCommand);

            } catch (Exception e) {

View Full Code Here

    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

     * @return boolean true if start succeeded, else false
     */
    public boolean startServer() {
        Integer success = 0;

        Command startCmd = new Command(mysqlCmd);
        logger.fine("Starting mysql with: " + mysqlCmd);
        startCmd.setSynchronous(false); // to run in bg
        try {
            // Run the command in the background
            CommandHandle ch = RunContext.exec(myServer, startCmd);
            /*
             * Make sure the server has started.
View Full Code Here

        // First check if server is up
        success = RunContext.isFile(myServer, pidFile);
        if (success) {
            try {
                // First kill mysqld_safe
                Command stopCmd = new Command("pkill mysqld_safe");
                CommandHandle ch = RunContext.exec(myServer, stopCmd);

                // Get the pid from the pidFile
                ByteArrayOutputStream bs = new ByteArrayOutputStream(10);
                RunContext.writeFileToStream(myServer, pidFile, bs);
                pidString = bs.toString();

                stopCmd = new Command("kill " + pidString);
                logger.fine("Attempting to kill mysqld pid " + pidString);
                ch = RunContext.exec(myServer, stopCmd);

            } catch (Exception ie) {
                logger.warning("Kill mysqld failed with " + ie.toString());
View Full Code Here

            /*****
            Command parseCommand = new Command("apache_trunc_errorlog.sh \"" +
            beginDate + "\"" + " \"" + endDate + "\" " +
            outFile);
             ****/
            Command parseCommand = new Command("mysql_trunc_err.sh " +
                    beginDate + " " + endDate + " " + outFile);
            CommandHandle ch = RunContext.exec(parseCommand);

        } catch (Exception e) {

View Full Code Here

                        continue;

                    // Get system info
                    PrintStream syslog =
                                    new PrintStream(new FileOutputStream(f));
                    Command sysinfo = new Command("sysinfo");
                    sysinfo.setStreamHandling(Command.STDOUT, Command.CAPTURE);
                    CommandHandle handle = cmds.execute(host, sysinfo, null);
                    byte[] info = handle.fetchOutput(Command.STDOUT);

                    // Write header and info to file.
                    syslog.println("<html><head><title>System Info for Server "
                            + machineName + "</title></head><body>");

                    syslog.write(info);

                    // Get User Commands output if specified
                    if (hostConfig.userCommands != null &&
                            hostConfig.userCommands.trim().length() > 0) {
                        String[] cmdStrings = hostConfig.userCommands.
                                                            split(";");
                        for (String cmdString : cmdStrings) {
                            Command c = new Command(cmdString);
                            c.setStreamHandling(Command.STDOUT,Command.CAPTURE);
                            logger.info("Executing '" + cmdString + "'");
                            handle = cmds.execute(host, c, null);
                            info = handle.fetchOutput(Command.STDOUT);
                            if (info != null) {
                                syslog.println(linesep);
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.