Java Code Examples for org.apache.nifi.provenance.search.QueryResult#awaitCompletion()
The following examples show how to use
org.apache.nifi.provenance.search.QueryResult#awaitCompletion() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestLuceneEventIndex.java From localization_nifi with Apache License 2.0 | 5 votes |
@Test(timeout = 5000) public void addThenQueryWithEmptyQuery() throws InterruptedException { final RepositoryConfiguration repoConfig = createConfig(); final IndexManager indexManager = new SimpleIndexManager(repoConfig); final LuceneEventIndex index = new LuceneEventIndex(repoConfig, indexManager, 1, EventReporter.NO_OP); final ProvenanceEventRecord event = createEvent(); index.addEvent(event, new StorageSummary(event.getEventId(), "1.prov", "1", 1, 2L, 2L)); final Query query = new Query(UUID.randomUUID().toString()); final ArrayListEventStore eventStore = new ArrayListEventStore(); eventStore.addEvent(event); index.initialize(eventStore); // We don't know how long it will take for the event to be indexed, so keep querying until // we get a result. The test will timeout after 5 seconds if we've still not succeeded. List<ProvenanceEventRecord> matchingEvents = Collections.emptyList(); while (matchingEvents.isEmpty()) { final QuerySubmission submission = index.submitQuery(query, EventAuthorizer.GRANT_ALL, "unit test user"); assertNotNull(submission); final QueryResult result = submission.getResult(); assertNotNull(result); result.awaitCompletion(100, TimeUnit.MILLISECONDS); assertTrue(result.isFinished()); assertNull(result.getError()); matchingEvents = result.getMatchingEvents(); assertNotNull(matchingEvents); Thread.sleep(100L); // avoid crushing the CPU } assertEquals(1, matchingEvents.size()); assertEquals(event, matchingEvents.get(0)); }
Example 2
Source File: TestLuceneEventIndex.java From nifi with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void addThenQueryWithEmptyQuery() throws InterruptedException { assumeFalse(isWindowsEnvironment()); final RepositoryConfiguration repoConfig = createConfig(); final IndexManager indexManager = new StandardIndexManager(repoConfig); final LuceneEventIndex index = new LuceneEventIndex(repoConfig, indexManager, 1, EventReporter.NO_OP); final ProvenanceEventRecord event = createEvent(); index.addEvent(event, new StorageSummary(event.getEventId(), "1.prov", "1", 1, 2L, 2L)); final Query query = new Query(UUID.randomUUID().toString()); final ArrayListEventStore eventStore = new ArrayListEventStore(); eventStore.addEvent(event); index.initialize(eventStore); // We don't know how long it will take for the event to be indexed, so keep querying until // we get a result. The test will timeout after 5 seconds if we've still not succeeded. List<ProvenanceEventRecord> matchingEvents = Collections.emptyList(); while (matchingEvents.isEmpty()) { final QuerySubmission submission = index.submitQuery(query, EventAuthorizer.GRANT_ALL, "unit test user"); assertNotNull(submission); final QueryResult result = submission.getResult(); assertNotNull(result); result.awaitCompletion(4000, TimeUnit.MILLISECONDS); assertTrue(result.isFinished()); assertNull(result.getError()); matchingEvents = result.getMatchingEvents(); assertNotNull(matchingEvents); Thread.sleep(100L); // avoid crushing the CPU } assertEquals(1, matchingEvents.size()); assertEquals(event, matchingEvents.get(0)); }
Example 3
Source File: TestLuceneEventIndex.java From localization_nifi with Apache License 2.0 | 4 votes |
@Test(timeout = 50000) public void testQuerySpecificField() throws InterruptedException { final RepositoryConfiguration repoConfig = createConfig(); final IndexManager indexManager = new SimpleIndexManager(repoConfig); final LuceneEventIndex index = new LuceneEventIndex(repoConfig, indexManager, 2, EventReporter.NO_OP); // add 2 events, one of which we will query for. final ProvenanceEventRecord event = createEvent(); index.addEvent(event, new StorageSummary(event.getEventId(), "1.prov", "1", 1, 2L, 2L)); index.addEvent(createEvent(), new StorageSummary(2L, "1.prov", "1", 1, 2L, 2L)); // Create a query that searches for the event with the FlowFile UUID equal to the first event's. final Query query = new Query(UUID.randomUUID().toString()); query.addSearchTerm(SearchTerms.newSearchTerm(SearchableFields.FlowFileUUID, event.getFlowFileUuid())); final ArrayListEventStore eventStore = new ArrayListEventStore(); eventStore.addEvent(event); index.initialize(eventStore); // We don't know how long it will take for the event to be indexed, so keep querying until // we get a result. The test will timeout after 5 seconds if we've still not succeeded. List<ProvenanceEventRecord> matchingEvents = Collections.emptyList(); while (matchingEvents.isEmpty()) { final QuerySubmission submission = index.submitQuery(query, EventAuthorizer.GRANT_ALL, "unit test user"); assertNotNull(submission); final QueryResult result = submission.getResult(); assertNotNull(result); result.awaitCompletion(100, TimeUnit.MILLISECONDS); assertTrue(result.isFinished()); assertNull(result.getError()); matchingEvents = result.getMatchingEvents(); assertNotNull(matchingEvents); Thread.sleep(100L); // avoid crushing the CPU } assertEquals(1, matchingEvents.size()); assertEquals(event, matchingEvents.get(0)); }
Example 4
Source File: TestLuceneEventIndex.java From nifi with Apache License 2.0 | 4 votes |
@Test(timeout = 50000) public void testQuerySpecificField() throws InterruptedException { final RepositoryConfiguration repoConfig = createConfig(); final IndexManager indexManager = new StandardIndexManager(repoConfig); final LuceneEventIndex index = new LuceneEventIndex(repoConfig, indexManager, 2, EventReporter.NO_OP); // add 2 events, one of which we will query for. final ProvenanceEventRecord event = createEvent(); index.addEvent(event, new StorageSummary(event.getEventId(), "1.prov", "1", 1, 2L, 2L)); index.addEvent(createEvent(), new StorageSummary(2L, "1.prov", "1", 1, 2L, 2L)); // Create a query that searches for the event with the FlowFile UUID equal to the first event's. final Query query = new Query(UUID.randomUUID().toString()); query.addSearchTerm(SearchTerms.newSearchTerm(SearchableFields.FlowFileUUID, event.getFlowFileUuid())); final ArrayListEventStore eventStore = new ArrayListEventStore(); eventStore.addEvent(event); index.initialize(eventStore); // We don't know how long it will take for the event to be indexed, so keep querying until // we get a result. The test will timeout after 5 seconds if we've still not succeeded. List<ProvenanceEventRecord> matchingEvents = Collections.emptyList(); while (matchingEvents.isEmpty()) { final QuerySubmission submission = index.submitQuery(query, EventAuthorizer.GRANT_ALL, "unit test user"); assertNotNull(submission); final QueryResult result = submission.getResult(); assertNotNull(result); result.awaitCompletion(4000, TimeUnit.MILLISECONDS); assertTrue(result.isFinished()); assertNull(result.getError()); matchingEvents = result.getMatchingEvents(); assertNotNull(matchingEvents); Thread.sleep(100L); // avoid crushing the CPU } assertEquals(1, matchingEvents.size()); assertEquals(event, matchingEvents.get(0)); }