Package com.sun.faban.common

Examples of com.sun.faban.common.Command


            names = null;
            host = null;
        }

      
        Command tarCommand = new Command("tar -cf "+hadoopLogDir+"/userlogs.tar "+hadoopLogDir+"/userlogs");
        Command renameCommand;
        try
        {
            for(int i = 0; i < hostList.size();i++)
            {
                logger.info("Host to get logs from = "+nodeList[i]);
                RunContext.exec(nodeList[i],tarCommand);
            }
           
        }catch(InterruptedException ie)
        {
            logger.warning("InterruptedException while running tar command on "+ ie.getMessage());
           
        }catch(IOException ioe)
        {
            logger.warning("IOException while running tar command on "+ ioe.getMessage());
        }

        //now lets copy these into the run directory
        String currentNode;
        for(int i = 0; i < hostList.size();i++)
        {
            currentNode = hostList.get(i);           
            if(RunContext.getFile(currentNode, hadoopLogDir+"/userlogs.tar", RunContext.getOutDir()+"userlogs-"+currentNode+".tar") != true)
            {
                logger.warning("Logs not retrieved from "+currentNode);
            }

            //now uncompress the directories and rename them
            tarCommand = new Command("tar -xf "+RunContext.getOutDir()+"userlogs-"+currentNode+".tar");
            renameCommand = new Command("mv "+hadoopLogDir+"/userlogs "+RunContext.getOutDir()+"userlogs-"+currentNode);
            try
            {
                RunContext.exec(tarCommand);
                RunContext.exec(renameCommand);
View Full Code Here


                ddCmd.add(classpath);
                ddCmd.add("-Dbenchmark.config=" + configFile);
                ddCmd.add("-Dbenchmark.ddfile=faban.xml");
                ddCmd.add("com.sun.faban.driver.util.DDGenerator");

                Command cmd = new Command(ddCmd);
                cmd.setWorkingDirectory(metaInf);
                cmd.setStreamHandling(Command.STDOUT, Command.CAPTURE);
                cmd.setStreamHandling(Command.STDERR, Command.CAPTURE);
                CommandHandle p = cmd.execute();
                if (p.exitValue() != 0) {
                    StringBuilder b = new StringBuilder();
                    b.append("Error generating faban driver deployment " +
                             "descriptor for " + dir + ".\n");
View Full Code Here

        argList.add(2, "-v");
        jvmCmd.add(path);
        jvmCmd.add(tool);
        jvmCmd.addAll(argList);
        ArrayList<String> pids = new ArrayList<String>();
        Command c = new Command(jvmCmd);
        c.setStreamHandling(Command.STDOUT, Command.CAPTURE);
        String result = null;
        processRef = RunContext.exec(c);
       
        int startIdx = 0;
        int endIdx = result.indexOf('\n');
View Full Code Here

    /**
     * Start all memcached servers on configured hosts.
     * @return boolean true if start succeeded on all machines, else false
     */
    public boolean startServers() {
        Command startCmd;

        memcacheHandles = new CommandHandle[myServers.length];
        for (int i = 0; i < myServers.length; i++) {
            String server = myServers[i];
            startCmd = new Command(memcachedctlCmd + " -p " + myPorts[i]);
            startCmd.setSynchronous(false);
            startCmd.setLogLevel(Command.STDOUT, Level.INFO);
            startCmd.setLogLevel(Command.STDERR, Level.INFO);
            try {
                // Run the command in the background
                logger.fine("Starting memcached on " + server + " with: " + startCmd);
                memcacheHandles[i] = RunContext.exec(server, startCmd);
            } catch (Exception e) {
View Full Code Here

        sbinDir = new File(binDir, Config.ARCH_DIR);
        emptyList = addExecMap(sbinDir, binMap, chmod) && emptyList;
        if (!emptyList)
            try {
                logger.fine("Changing mode for bin directories.");
                Command cmd = new Command(chmod);
                CommandHandle handle = cmd.execute();
                int exitValue = handle.exitValue();
                if (exitValue != 0)
                    logger.severe("Failed to chmod bin files. Exit value is " +
                                                                    exitValue);
            } catch (IOException e) {
View Full Code Here

     * @throws IOException Error starting the collector
     * @throws InterruptedException Interrupted waiting for commands
     */
    public void start() throws IOException, InterruptedException {
        // Locate the process with collector, starting with user processes.
        cmd = new Command("/usr/bin/ps", "-u", System.getProperty("user.name"));
        cmd.setStreamHandling(Command.STDOUT, Command.CAPTURE);
        String result = null;
        try {
            processRef = cmd.execute();
            result = new String(processRef.fetchOutput(Command.STDOUT));
        } catch (IOException e) {
            logger.log(Level.WARNING, "Error executing ps", e);
            return;
        } catch (InterruptedException e) {
            logger.log(Level.WARNING, "Interrupted executing ps", e);
            return;
        }

        int startIdx = 0;
        int endIdx = result.indexOf('\n');
        while (endIdx > 0) {
            String line = result.substring(startIdx, endIdx).trim();
            startIdx = endIdx + 1;
            endIdx = result.indexOf('\n', startIdx);
            if (line == null || line.length() == 0)
                continue;
            if (line.startsWith("PID ")) // skip header
                continue;
            String pid = line.substring(0, line.indexOf(' '));
            cmd = new Command("/usr/bin/pldd", pid);
            cmd.setStreamHandling(Command.STDOUT, Command.CAPTURE);

            // Check for process that started with collector.
            try {
                processRef = cmd.execute();
View Full Code Here

     * @throws IOException Error stopping the collector
     */
    public void stop() throws InterruptedException, IOException {
        // We use the same command to start and stop the collection
        // So there is no need to reconstruct the command strings.
        cmd = new Command(toolCmd);
        try {
            processRef = cmd.execute();
        } catch (IOException e) {
            logger.log(Level.WARNING, "Error stopping collector", e);

View Full Code Here

     * Start all apache servers on configured hosts.
     * @return boolean true if start succeeded on all machines, else false
     */
    public boolean startServers() {

        Command startCmd = new Command(lightyCmd, "-f", confFile);
        startCmd.setSynchronous(false);
        startCmd.setLogLevel(Command.STDOUT, Level.FINE);
        startCmd.setLogLevel(Command.STDERR, Level.FINE);
        ch = new CommandHandle[myServers.length];
        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

                    success = false;
                }
                if (pid <= 0)
                    continue;
                // Now kill the server
                Command cmd = new Command("kill", String.valueOf(pid));
                try {
                    RunContext.exec(hostName, cmd);
                    // Check if the server truly stopped
                    int attempts = 60;
                    boolean b = false;
View Full Code Here

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

            } catch (Exception e) {

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.