}
sb.append("version=200000000\n"); // version of current config is 100000000
nextQuorumCfgSection = sb.toString();
MainThread mt[] = new MainThread[SERVER_COUNT];
ZooKeeper zk[] = new ZooKeeper[SERVER_COUNT];
// run servers 0 and 1 normally
for (int i = 0; i < 2; i++) {
mt[i] = new MainThread(i, oldClientPorts[i],
currentQuorumCfgSection);
mt[i].start();
zk[i] = new ZooKeeper("127.0.0.1:" + oldClientPorts[i],
ClientBase.CONNECTION_TIMEOUT, this);
}
for (int i = 0; i < 2; i++) {
Assert.assertTrue("waiting for server " + i + " being up",
ClientBase.waitForServerUp(
"127.0.0.1:" + oldClientPorts[i],
CONNECTION_TIMEOUT * 2));
}
ReconfigTest.testNormalOperation(zk[0], zk[1]);
// shut them down and then simulate a reboot with a reconfig in progress
for (int i = 0; i < 2; i++) {
mt[i].shutdown();
zk[i].close();
}
for (int i = 0; i < 2; i++) {
Assert.assertTrue(
"waiting for server " + i + " being up",
ClientBase.waitForServerDown("127.0.0.1:"
+ oldClientPorts[i], CONNECTION_TIMEOUT * 2));
}
for (int i = 0; i < 2; i++) {
mt[i].writeTempDynamicConfigFile(nextQuorumCfgSection);
mt[i].start();
zk[i] = new ZooKeeper("127.0.0.1:" + clientPorts[i],
ClientBase.CONNECTION_TIMEOUT, this);
}
// new members are initialized with current config + the new server
for (int i = 2; i < SERVER_COUNT; i++) {
mt[i] = new MainThread(i, clientPorts[i], currentQuorumCfg
+ allServersNext.get(i));
mt[i].start();
zk[i] = new ZooKeeper("127.0.0.1:" + clientPorts[i],
ClientBase.CONNECTION_TIMEOUT, this);
}
for (int i = 0; i < SERVER_COUNT; i++) {
Assert.assertTrue("waiting for server " + i + " being up",