use of org.apache.nifi.provenance.RepositoryConfiguration in project nifi by apache.
the class TestPartitionedWriteAheadEventStore method testGetEvent.
@Test
public void testGetEvent() throws IOException {
final RepositoryConfiguration config = createConfig();
final PartitionedWriteAheadEventStore store = new PartitionedWriteAheadEventStore(config, writerFactory, readerFactory, EventReporter.NO_OP, new EventFileManager());
store.initialize();
final int numEvents = 20;
final List<ProvenanceEventRecord> events = new ArrayList<>(numEvents);
for (int i = 0; i < numEvents; i++) {
final ProvenanceEventRecord event = createEvent();
store.addEvents(Collections.singleton(event));
events.add(event);
}
// Ensure that each event is retrieved successfully.
for (int i = 0; i < numEvents; i++) {
final ProvenanceEventRecord event = store.getEvent(i).get();
assertEquals(events.get(i), event);
}
assertFalse(store.getEvent(-1L).isPresent());
assertFalse(store.getEvent(20L).isPresent());
}
use of org.apache.nifi.provenance.RepositoryConfiguration in project nifi by apache.
the class TestPartitionedWriteAheadEventStore method testWriteAfterRecoveringRepo.
@Test
public void testWriteAfterRecoveringRepo() throws IOException {
final RepositoryConfiguration config = createConfig();
final PartitionedWriteAheadEventStore store = new PartitionedWriteAheadEventStore(config, writerFactory, readerFactory, EventReporter.NO_OP, new EventFileManager());
store.initialize();
for (int i = 0; i < 4; i++) {
store.addEvents(Collections.singleton(createEvent()));
}
store.close();
final PartitionedWriteAheadEventStore recoveredStore = new PartitionedWriteAheadEventStore(config, writerFactory, readerFactory, EventReporter.NO_OP, new EventFileManager());
recoveredStore.initialize();
List<ProvenanceEventRecord> recoveredEvents = recoveredStore.getEvents(0, 10);
assertEquals(4, recoveredEvents.size());
// ensure that we can still write to the store
for (int i = 0; i < 4; i++) {
recoveredStore.addEvents(Collections.singleton(createEvent()));
}
recoveredEvents = recoveredStore.getEvents(0, 10);
assertEquals(8, recoveredEvents.size());
for (int i = 0; i < 8; i++) {
assertEquals(i, recoveredEvents.get(i).getEventId());
}
}
Aggregations