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]);