MockFileSystem mockFs = new MockFileSystem(fs, 3);
Context context = getContextForRetryTests();
Configurables.configure(sink, context);
Channel channel = new MemoryChannel();
Configurables.configure(channel, context);
sink.setChannel(channel);
sink.setMockFs(mockFs);
HDFSWriter hdfsWriter = new MockDataStream(mockFs);
hdfsWriter.configure(context);
sink.setMockWriter(hdfsWriter);
sink.start();
// push the event batches into channel
for (int i = 0; i < 2; i++) {
Transaction txn = channel.getTransaction();
txn.begin();
Map<String, String> hdr = Maps.newHashMap();
hdr.put("retryHeader", "v1");
channel.put(EventBuilder.withBody("random".getBytes(), hdr));
txn.commit();
txn.close();
// execute sink to process the events
sink.process();
}
// push the event batches into channel
for (int i = 0; i < 2; i++) {
Transaction txn = channel.getTransaction();
txn.begin();
Map<String, String> hdr = Maps.newHashMap();
hdr.put("retryHeader", "v2");
channel.put(EventBuilder.withBody("random".getBytes(), hdr));
txn.commit();
txn.close();
// execute sink to process the events
sink.process();
}