if(logger.isInfoEnabled())
logger.info("Starting Zookeeper cluster");
Map<String, String> hostNameCommandLineMap = new HashMap<String, String>();
CommandParameterizer commandLineParameterizer = new CommandParameterizer("SshZkStarterMid", CommandType.COMMAND_ID),
commandLineParameterizer2;
// Generate server.<node_id>=<host_name>:2888:3888 list
StringBuilder builder = new StringBuilder();
if ( hostNames.size() > 1) {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(CommandParameterizer.ZK_CONFIG_PARAM, zkConfigFile);
int nodeId = 1;
for ( String hostName : hostNames) {
parameters.put(CommandParameterizer.ZK_NODE_ID_PARAM, Integer.toString(nodeId));
parameters.put(CommandParameterizer.HOST_NAME_PARAM, hostName);
builder.append(commandLineParameterizer.parameterize(parameters));
nodeId++;
}
}
// Generate commands for every host
int nodeId = 1;
for(String hostName: hostNames) {
commandLineParameterizer = new CommandParameterizer("SshZkStarter.ssh" + (sshPrivateKey != null ? ""
: ".nokey"),
CommandType.COMMAND_ID);
commandLineParameterizer2 = new CommandParameterizer("SshZkStarterEnd", CommandType.COMMAND_ID);
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(CommandParameterizer.HOST_NAME_PARAM, hostName);
parameters.put(CommandParameterizer.HOST_USER_ID_PARAM, hostUserId);
parameters.put(CommandParameterizer.SSH_PRIVATE_KEY_PARAM,
sshPrivateKey != null ? sshPrivateKey.getAbsolutePath() : null);
parameters.put(CommandParameterizer.KAFKA_ROOT_DIRECTORY_PARAM, kafkaRootDirectory);
parameters.put(CommandParameterizer.ZK_CONFIG_PARAM, zkConfigFile);
parameters.put(CommandParameterizer.ZK_PORT_PARAM, Integer.toString(zkPort));
parameters.put(CommandParameterizer.ZK_NODE_ID_PARAM, Integer.toString(nodeId));
parameters.put(CommandParameterizer.ZK_DATA_DIR_PARAM, zkDataDir);
hostNameCommandLineMap.put(hostName, commandLineParameterizer.parameterize(parameters)
+ builder.toString()
+ commandLineParameterizer2.parameterize(parameters));
nodeId++;
}