throws IOException, InterruptedException, KeeperException, Throwable{
final Semaphore sem = new Semaphore(0);
QuorumUtil qu = new QuorumUtil(1);
qu.startAll();
CountdownWatcher watcher1 = new CountdownWatcher();
CountdownWatcher watcher2 = new CountdownWatcher();
CountdownWatcher watcher3 = new CountdownWatcher();
int index = 1;
while(qu.getPeer(index).peer.leader == null)
index++;
Leader leader = qu.getPeer(index).peer.leader;
assertNotNull(leader);
/*
* Reusing the index variable to select a follower to connect to
*/
index = (index == 1) ? 2 : 1;
ZooKeeper zk = new DisconnectableZooKeeper("127.0.0.1:" + qu.getPeer(index).peer.getClientPort(), 1000, watcher1);
ZooKeeper zk2 = new DisconnectableZooKeeper("127.0.0.1:" + qu.getPeer(index).peer.getClientPort(), 1000,watcher2);
final ZooKeeper zk3 = new DisconnectableZooKeeper("127.0.0.1:" + qu.getPeer(3).peer.getClientPort(), 1000, watcher3);
watcher1.waitForConnected(CONNECTION_TIMEOUT);
watcher2.waitForConnected(CONNECTION_TIMEOUT);
watcher3.waitForConnected(CONNECTION_TIMEOUT);
zk.create("/first", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
zk2.create("/mybar", null, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
final AtomicBoolean runNow = new AtomicBoolean(false);