sb.append("version=100000000");
currentQuorumCfgSection = sb.toString();
// Run servers 0..2 for a while
MainThread mt[] = new MainThread[SERVER_COUNT];
ZooKeeper zk[] = new ZooKeeper[SERVER_COUNT];
for (int i = 0; i <= 2; i++) {
mt[i] = new MainThread(i, ports[i][2], currentQuorumCfgSection);
mt[i].start();
zk[i] = new ZooKeeper("127.0.0.1:" + ports[i][2],
ClientBase.CONNECTION_TIMEOUT, this);
}
ReconfigTest.testNormalOperation(zk[0], zk[2]);
for (int i = 0; i <= 2; i++) {
Assert.assertTrue("waiting for server " + i + " being up",
ClientBase.waitForServerUp("127.0.0.1:" + ports[i][2],
CONNECTION_TIMEOUT * 2));
}
// shut servers 0..2 down
for (int i = 0; i <= 2; i++) {
mt[i].shutdown();
zk[i].close();
}
// generate new config string
ArrayList<String> allServersNext = new ArrayList<String>();
sb = new StringBuilder();
for (int i = 2; i < SERVER_COUNT; i++) {
String server = "server." + i + "=localhost:" + ports[i][0] + ":"
+ ports[i][1] + ":participant;localhost:" + ports[i][2];
allServersNext.add(server);
sb.append(server + "\n");
}
sb.append("version=200000000"); // version of current config is 100000000
nextQuorumCfgSection = sb.toString();
// simulate reconfig in progress - servers 0..2 have a temp reconfig
// file when they boot
for (int i = 0; i <= 2; i++) {
mt[i].writeTempDynamicConfigFile(nextQuorumCfgSection);
mt[i].start();
zk[i] = new ZooKeeper("127.0.0.1:" + ports[i][2],
ClientBase.CONNECTION_TIMEOUT, this);
}
// new server 3 has still its invalid joiner config - everyone in old
// config + itself
mt[3] = new MainThread(3, ports[3][2], currentQuorumCfg
+ allServersNext.get(1));
mt[3].start();
zk[3] = new ZooKeeper("127.0.0.1:" + ports[3][2],
ClientBase.CONNECTION_TIMEOUT, this);
for (int i = 2; i < SERVER_COUNT; i++) {
Assert.assertTrue("waiting for server " + i + " being up",
ClientBase.waitForServerUp("127.0.0.1:" + ports[i][2],