Search in sources :

Example 26 with RepositoryConfiguration

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());
}
Also used : ProvenanceEventRecord(org.apache.nifi.provenance.ProvenanceEventRecord) StandardProvenanceEventRecord(org.apache.nifi.provenance.StandardProvenanceEventRecord) ArrayList(java.util.ArrayList) RepositoryConfiguration(org.apache.nifi.provenance.RepositoryConfiguration) Test(org.junit.Test)

Example 27 with RepositoryConfiguration

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());
    }
}
Also used : ProvenanceEventRecord(org.apache.nifi.provenance.ProvenanceEventRecord) StandardProvenanceEventRecord(org.apache.nifi.provenance.StandardProvenanceEventRecord) RepositoryConfiguration(org.apache.nifi.provenance.RepositoryConfiguration) Test(org.junit.Test)

Aggregations

RepositoryConfiguration (org.apache.nifi.provenance.RepositoryConfiguration)27 Test (org.junit.Test)24 ProvenanceEventRecord (org.apache.nifi.provenance.ProvenanceEventRecord)16 File (java.io.File)15 StandardProvenanceEventRecord (org.apache.nifi.provenance.StandardProvenanceEventRecord)15 IndexManager (org.apache.nifi.provenance.lucene.IndexManager)9 ArrayList (java.util.ArrayList)8 SimpleIndexManager (org.apache.nifi.provenance.lucene.SimpleIndexManager)8 ArrayListEventStore (org.apache.nifi.provenance.store.ArrayListEventStore)8 EventAuthorizer (org.apache.nifi.provenance.authorization.EventAuthorizer)6 StorageSummary (org.apache.nifi.provenance.serialization.StorageSummary)6 AtomicLong (java.util.concurrent.atomic.AtomicLong)5 AccessDeniedException (org.apache.nifi.authorization.AccessDeniedException)5 EventIndexWriter (org.apache.nifi.provenance.index.EventIndexWriter)5 Query (org.apache.nifi.provenance.search.Query)5 QuerySubmission (org.apache.nifi.provenance.search.QuerySubmission)5 StorageResult (org.apache.nifi.provenance.store.StorageResult)5 List (java.util.List)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 InvocationOnMock (org.mockito.invocation.InvocationOnMock)4