}
private void startOne(int hostId, boolean clearLocalDataDirectories, ReplicationRole replicaMode, StartAction startAction)
{
PipeToFile ptf = null;
CommandLine cmdln = (templateCmdLine.makeCopy());
cmdln.setJavaProperty(clusterHostIdProperty, String.valueOf(hostId));
if (this.m_additionalProcessEnv != null) {
for (String name : this.m_additionalProcessEnv.keySet()) {
cmdln.setJavaProperty(name, this.m_additionalProcessEnv.get(name));
}
}
try {
cmdln.internalPort(portGenerator.nextInternalPort());
// set the dragent port. it uses the start value and
// the next two sequential port numbers - so burn those two.
cmdln.drAgentStartPort(portGenerator.nextReplicationPort());
portGenerator.next();
portGenerator.next();
// add the ipc ports
if (m_target == BackendTarget.NATIVE_EE_IPC) {
// set 1 port for the EE process
cmdln.ipcPort(portGenerator.next());
}
if (m_target == BackendTarget.NATIVE_EE_VALGRIND_IPC) {
EEProcess proc = m_eeProcs.get(hostId);
assert(proc != null);
cmdln.m_ipcPort = proc.port();
}
cmdln.port(portGenerator.nextClient());
cmdln.adminPort(portGenerator.nextAdmin());
cmdln.httpPort(portGenerator.nextHttp());
cmdln.replicaMode(replicaMode);
cmdln.timestampSalt(getRandomTimestampSalt());
if (m_debug) {
cmdln.debugPort(portGenerator.next());
}
cmdln.zkport(portGenerator.nextZkPort());
if (startAction == StartAction.JOIN) {
cmdln.startCommand(startAction);
int portNoToRejoin = m_cmdLines.get(0).internalPort();
cmdln.leader(":" + portNoToRejoin);
}
// If local directories are being cleared
// generate a new subroot, otherwise reuse the existing directory
File subroot = null;
if (clearLocalDataDirectories) {
subroot = VoltFile.getNewSubroot();
m_subRoots.add(subroot);
} else {
if (m_subRoots.size() <= hostId) {
m_subRoots.add(VoltFile.getNewSubroot());
}
subroot = m_subRoots.get(hostId);
}
cmdln.voltFilePrefix(subroot.getPath());
cmdln.voltRoot(subroot.getPath() + "/" + m_voltdbroot);
if ((m_versionOverrides != null) && (m_versionOverrides.length > hostId)) {
assert(m_versionOverrides[hostId] != null);
assert(m_versionCheckRegexOverrides[hostId] != null);
cmdln.m_versionStringOverrideForTest = m_versionOverrides[hostId];
cmdln.m_versionCompatibilityRegexOverrideForTest = m_versionCheckRegexOverrides[hostId];
}
m_cmdLines.add(cmdln);
m_procBuilder.command().clear();
List<String> cmdlnList = cmdln.createCommandLine();
String cmdLineFull = "Start cmd host=" + String.valueOf(hostId) + " :";
for (String element : cmdlnList) {
assert(element != null);
cmdLineFull += " " + element;
}
log.info(cmdLineFull);
m_procBuilder.command().addAll(cmdlnList);
// write output to obj/release/testoutput/<test name>-n.txt
// this may need to be more unique? Also very useful to just
// set this to a hardcoded path and use "tail -f" to debug.
String testoutputdir = cmdln.buildDir() + File.separator + "testoutput";
System.out.println("Process output will be redirected to: " + testoutputdir);
// make sure the directory exists
File dir = new File(testoutputdir);
if (dir.exists()) {
assert (dir.isDirectory());