Package com.sun.faban.common

Examples of com.sun.faban.common.Command


                    continue;

                try {
                    // We first turn on all cpus, then turn off enough of them
                    // to get the required number
                    Command cmd = new Command(Config.BIN_DIR + "fastsu",
                            "/usr/sbin/psradm", "-a", "-n");
                    logger.config("Turning on all cpus on " + hosts[j]);
                    cmds.execute(hosts[j], cmd, null);

                    cmd = new Command("/usr/sbin/psrinfo");
                    cmd.setStreamHandling(Command.STDOUT, Command.CAPTURE);
                    logger.fine("Getting cpus");
                    CommandHandle handle = cmds.execute(hosts[j], cmd, null);
                    byte[] buffer = handle.fetchOutput(Command.STDOUT);

                    if (buffer != null) {
                        StringTokenizer t =
                                new StringTokenizer(new String(buffer), "\n");

                        ArrayList<Integer> cpuList = new ArrayList<Integer>();
                        boolean isMultiCore = false;

                        while (t.hasMoreTokens()) {
                            String line = t.nextToken();
                            // build list of cpus
                            Integer cpuId = Integer.valueOf((
                                    new StringTokenizer(line)).nextToken().
                                    trim());
                            if((isMultiCore == false) &&
                                    (cpuId.intValue() > 511))
                                isMultiCore = true;
                            cpuList.add(cpuId);
                        }
                        logger.info("Total number of CPUs is " +
                                cpuList.size()/(isMultiCore ? 2 : 1));

                        // The index gets changed when you remove elements
                        // Remove number of CPUs configured to be used for this
                        // server
                        for(int k = 0; k < numCPUs; k++) {
                            if(isMultiCore) {
                                Integer cpuId = new Integer(
                                        (cpuList.get(0)).intValue() + 512);
                                cpuList.remove(cpuId);
                            }
                            cpuList.remove(0);
                        }

                        logger.info("Number of CPUs turned off is " +
                                cpuList.size()/(isMultiCore ? 2 : 1));

                        // The remaining CPUs in the list have to be turned off.

                        if (cpuList.size() > 0) {
                            ArrayList<String> offlineCmd = new ArrayList<String>();
                            offlineCmd.add(Config.BIN_DIR + "fastsu");
                            offlineCmd.add("/usr/sbin/psradm");
                            offlineCmd.add("-f");

                            for(int k = 0; k < cpuList.size(); k++)
                                offlineCmd.add(cpuList.get(k).toString());

                            logger.info("Off-lining CPUs with command: " +
                                    offlineCmd);
                            cmd = new Command(offlineCmd);
                            cmds.execute(hosts[j], cmd, null);
                        }
                    } else {
                        logger.severe("Could not set CPUs on server " +
                                hosts[j]);
View Full Code Here


                + " Day = " + endDay + " Time = " + etime);

        // Now, get /var/adm/messages and look for messages between
        // start and end
        CommandHandle handle;
        Command c = new Command("messages", "\"" +
                startMon + " " + startDay + " " + stime + "\"",
                "\""  + endMon + " " + endDay + " " + etime + "\"");
        c.setStreamHandling(Command.STDOUT, Command.CAPTURE);
        logger.fine("Getting system messages");

        for (ParamRepository.HostConfig hostConfig : hostConfigs) {
            for(String host : hostConfig.hosts) {
                String machineName = cmds.getHostName(host);
View Full Code Here

            c.add("-p" + mysqlPass);
        c.add("-B");
        c.add("-e");
        c.add("show global status;");
        logger.log(Level.FINE, "Setting up mysql command: " + c);
        mysql = new Command(c);
    /***
        mysql.setEnvironment(env);
        mysql.setInput(stdin.getBytes());
        ***/
    }
View Full Code Here

     */
    protected void getReport(String log1, String log2,
                                               String outFile) {
    String c = "mysql_diff_status.sh " + log1 + " " + log2 + " " + outFile;
        logger.log(Level.FINE, "Calling " + c);
      Command diffCommand = new Command(c);
      try {
          cmdAgent.execute(diffCommand, null);
        } catch (IOException e) {
            logger.log(Level.SEVERE, "Error executing mysql_diff_status.sh", e);
        } catch (InterruptedException e) {
View Full Code Here

    protected void stop(boolean warn) {

        logger.fine("Stopping statit");
        if (toolStatus == STARTED) {
            Command c = new Command("statit -y");
            c.setStreamHandling(Command.STDOUT, Command.CAPTURE);
            c.setOutputFile(Command.STDOUT, logfile);
            try {
                // Replace tool so that super.stop gets the output from -y instead.
                tool = cmdAgent.execute(c, null);
                // saveToolLogs(tool.getInputStream(), tool.getErrorStream());
                toolStatus = STOPPED;
View Full Code Here

        toolArgs = ctx.getToolArgs();
        toolCmd = new ArrayList<String>();
        toolCmd.add(toolName);
        if (toolArgs != null)
            toolCmd.addAll(toolArgs);
        cmd = new Command(toolCmd);
        cmd.setSynchronous(false);
        logger.fine(toolName + " Configured with toolCmd " + toolCmd);

    }
View Full Code Here

            ctx.setOutputFile("xan", postFile);
            logger.finer("postCmd = " + postCmd + ", postFile = " + postFile);
            long sleepTime = stopTime + 500 - System.currentTimeMillis();
            if (sleepTime > 0)
                Thread.sleep(sleepTime);
            cmd = new Command(postCmd);
            cmd.setStreamHandling(Command.STDOUT, Command.CAPTURE);
            cmd.setOutputFile(Command.STDOUT, postFile);
            ctx.exec(cmd, false);

            // We want both the raw output and xan output files
View Full Code Here

        String postFile = rawFile.replace(".raw.", ".xan.");
        ctx.setOutputFile(postFile);
        long sleepTime = stopTime + 500 - System.currentTimeMillis();
        if (sleepTime > 0)
            Thread.sleep(sleepTime);
        cmd = new Command("cpustat-post");
        ctx.exec(cmd, true);
    }
View Full Code Here

    /**
     * Start all glassfish servers on configured hosts.
     */
    @Start public void startup() {
        Command startCmd = new Command(asadminCmd, "start-domain");      

        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

    /*
   * Check if Glassfish server is started.
   */
    private static boolean checkServerStarted(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 running") != -1)
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.