Injector injector = CoreTestUtils.createInjectorWithNonFailFastZKClients();
TCPEmitter emitter = injector.getInstance(TCPEmitter.class);
Event event = new Event();
event.put("command", String.class, "setValue1");
event.put("value", String.class, "message1");
event.setStreamId("inputStream");
emitter.send(
0,
injector.getInstance(SerializerDeserializerFactory.class)
.createSerializerDeserializer(Thread.currentThread().getContextClassLoader()).serialize(event));
if (manualCheckpointing) {
insertCheckpointInstruction(injector, emitter);
}
Assert.assertTrue(signalCheckpointed.await(10, TimeUnit.SECONDS));
forkedS4App.destroy();
zk.delete("/data", -1);
signalConsumerReady = getConsumerReadySignal("inputStream");
DeploymentUtils.initAppConfig(
new AppConfig.Builder()
.appClassName(S4AppWithManualCheckpointing.class.getName())
.namedParameters(
ImmutableMap.of("s4.checkpointing.filesystem.storageRootPath",
CommTestUtils.DEFAULT_STORAGE_DIR.getAbsolutePath()))
.customModulesNames(ImmutableList.of(backendModuleClass.getName())).build(), "cluster1", true,
"localhost:2181");
forkedS4App = CoreTestUtils.forkS4Node(new String[] { "-c", "cluster1" }, new ZkClient("localhost:2181"), 10,
"cluster1");
Assert.assertTrue(signalConsumerReady.await(20, TimeUnit.SECONDS));
// // trigger recovery by sending application event to set value 2
CountDownLatch signalValue2Set = new CountDownLatch(1);
CoreTestUtils.watchAndSignalCreation("/value2Set", signalValue2Set, zk);
event = new Event();
event.setStreamId("inputStream");
event.put("command", String.class, "setValue2");
event.put("value", String.class, "message2");
emitter.send(
0,
injector.getInstance(SerializerDeserializerFactory.class)
.createSerializerDeserializer(Thread.currentThread().getContextClassLoader()).serialize(event));