super(0);
}
@Test
public void runBookieServerZKExpireBehaviourTest() throws Exception {
BookieServer server = null;
try {
File f = File.createTempFile("bookieserver", "test");
f.delete();
f.mkdir();
HashSet<Thread> threadset = new HashSet<Thread>();
int threadCount = Thread.activeCount();
Thread threads[] = new Thread[threadCount*2];
threadCount = Thread.enumerate(threads);
for(int i = 0; i < threadCount; i++) {
if (threads[i].getName().indexOf("SendThread") != -1) {
threadset.add(threads[i]);
}
}
ServerConfiguration conf = newServerConfiguration(initialPort + 1, HOSTPORT, f, new File[] { f });
server = new BookieServer(conf);
server.start();
Thread.sleep(10);
Thread sendthread = null;
threadCount = Thread.activeCount();
threads = new Thread[threadCount*2];
threadCount = Thread.enumerate(threads);
for(int i = 0; i < threadCount; i++) {
if (threads[i].getName().indexOf("SendThread") != -1
&& !threadset.contains(threads[i])) {
sendthread = threads[i];
break;
}
}
assertNotNull("Send thread not found", sendthread);
sendthread.suspend();
Thread.sleep(2*10000);
sendthread.resume();
// allow watcher thread to run
Thread.sleep(3000);
assertFalse("Bookie should have shutdown on losing zk session", server.isBookieRunning());
assertFalse("Nio Server should have shutdown on losing zk session", server.isNioServerRunning());
assertFalse("Bookie Server should have shutdown on losing zk session", server.isRunning());
} finally {
server.shutdown();
}
}