CountDownLatch signalSentence1Processed = new CountDownLatch(1);
TestUtils.watchAndSignalCreation("/classifierIteration_"
+ WordCountTest.SENTENCE_1_TOTAL_WORDS,
signalSentence1Processed, zk);
gen.injectValueEvent(
new KeyValue("sentence", WordCountTest.SENTENCE_1),
"Sentences", 0);
signalSentence1Processed.await(10, TimeUnit.SECONDS);
Thread.sleep(1000);
// crash the app
forkedS4App.destroy();
// recovering and making sure checkpointing still works
forkedS4App = TestUtils.forkS4App(getClass().getName(), backendConf);
// add authorizations for continuing processing. Without these, the
// WordClassifier processed keeps waiting
for (int i = WordCountTest.SENTENCE_1_TOTAL_WORDS + 1; i <= WordCountTest.SENTENCE_1_TOTAL_WORDS
+ WordCountTest.SENTENCE_2_TOTAL_WORDS; i++) {
zk.create("/continue_" + i, new byte[0], Ids.OPEN_ACL_UNSAFE,
CreateMode.EPHEMERAL);
}
CountDownLatch sentence2Processed = new CountDownLatch(1);
TestUtils
.watchAndSignalCreation(
"/classifierIteration_"
+ (WordCountTest.SENTENCE_1_TOTAL_WORDS + WordCountTest.SENTENCE_2_TOTAL_WORDS),
sentence2Processed, zk);
gen.injectValueEvent(
new KeyValue("sentence", WordCountTest.SENTENCE_2),
"Sentences", 0);
sentence2Processed.await(10, TimeUnit.SECONDS);
Thread.sleep(1000);
// crash the app
forkedS4App.destroy();
forkedS4App = TestUtils.forkS4App(getClass().getName(), backendConf);
// add authorizations for continuing processing. Without these, the
// WordClassifier processed keeps waiting
for (int i = WordCountTest.SENTENCE_1_TOTAL_WORDS
+ WordCountTest.SENTENCE_2_TOTAL_WORDS + 1; i <= WordCountTest.TOTAL_WORDS; i++) {
zk.create("/continue_" + i, new byte[0], Ids.OPEN_ACL_UNSAFE,
CreateMode.EPHEMERAL);
}
gen.injectValueEvent(
new KeyValue("sentence", WordCountTest.SENTENCE_3),
"Sentences", 0);
signalTextProcessed.await(10, TimeUnit.SECONDS);
File results = new File(S4TestCase.DEFAULT_TEST_OUTPUT_DIR
+ File.separator + "wordcount");
String s = TestUtils.readFile(results);