@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");
}