* close always happens after open started retrying.
*/
@Test
public void testHdfsDownInterruptAfterOpeningRetry()
throws FlumeSpecException, IOException, InterruptedException {
final EventSink snk = new LazyOpenDecorator(FlumeBuilder.buildSink(
new Context(),
"collectorSink(\"hdfs://nonexistant/user/foo\", \"foo\")"));
final CountDownLatch started = new CountDownLatch(1);
final CountDownLatch done = new CountDownLatch(1);
Thread t = new Thread("append thread") {
public void run() {
Event e = new EventImpl("foo".getBytes());
try {
snk.open();
started.countDown();
snk.append(e);
} catch (IOException e1) {
// could throw exception but we don't care
LOG.info("don't care about this exception: ", e1);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
done.countDown();
}
};
t.start();
boolean begun = started.await(60, TimeUnit.SECONDS);
Clock.sleep(10);
assertTrue("took too long to start", begun);
snk.close();
LOG.info("Interrupting appending thread");
t.interrupt();
boolean completed = done.await(60, TimeUnit.SECONDS);
assertTrue("Timed out when attempting to shutdown", completed);
}