close
The Wayback Machine - https://web.archive.org/web/20200914225429/https://github.com/apache/nifi-minifi-cpp/pull/891
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MINIFICPP-1349 ConsumeWindowsEventLogs should honor batch commit size in a single session #891

Open
wants to merge 12 commits into
base: main
from

Conversation

@lordgamez
Copy link
Contributor

lordgamez commented Sep 2, 2020

Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically main)?

  • Is your initial contribution a single, squashed commit?

For code changes:

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file?
  • If applicable, have you updated the NOTICE file?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.

@lordgamez lordgamez marked this pull request as draft Sep 3, 2020
@lordgamez lordgamez marked this pull request as ready for review Sep 3, 2020
}

std::wstring ConsumeWindowsEventLog::processEventLogs(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session,
size_t& processed_event_count, const EVT_HANDLE& event_query_results) {

This comment has been minimized.

@fgerlits

fgerlits Sep 3, 2020

Contributor

I would do this the other way round: return the number of events processed, and use an out parameter for the bookmark XML. Not important, but I think that is a more common pattern.

Another option would be to return a struct { size_t processed_event_count; std::wstring bookmark_xml; }.

This comment has been minimized.

@lordgamez

lordgamez Sep 8, 2020

Author Contributor

As both are output parameters I decided to return a tuple with both values. Added in 24855ee


if (eventCount > commitAndSaveBookmarkCount) {
commitAndSaveBookmark(bookmarkXml);
if (processed_event_count > 0 && !commitAndSaveBookmark(bookmark_xml, session)) {

This comment has been minimized.

@fgerlits

fgerlits Sep 3, 2020

Contributor

I think we should yield if no events were processed, too. I know we didn't before this change, but that seems like a bug.

Suggested change
if (processed_event_count > 0 && !commitAndSaveBookmark(bookmark_xml, session)) {
if (processed_event_count == 0 || !commitAndSaveBookmark(bookmark_xml, session)) {

This comment has been minimized.

@lordgamez

lordgamez Sep 8, 2020

Author Contributor

Done in 82aac08

}

std::wstring ConsumeWindowsEventLog::processEventLogs(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session,
size_t& processed_event_count, const EVT_HANDLE& event_query_results) {

This comment has been minimized.

@fgerlits

fgerlits Sep 3, 2020

Contributor

could this be const?

This comment has been minimized.

@lordgamez

lordgamez Sep 8, 2020

Author Contributor

Unfortunately no, because of getEventLogHandler in the createEventRender call. But I made 2 other methods const in 0a32d4e

batchCommitSizeTestHelper(1000);
batchCommitSizeTestHelper(5);
batchCommitSizeTestHelper(4);
batchCommitSizeTestHelper(1);
batchCommitSizeTestHelper(0);
Comment on lines 385 to 389

This comment has been minimized.

@fgerlits

fgerlits Sep 3, 2020

Contributor

I think the test is clearer if you explicitly specify the expected result, as before. Maybe the number of events could be a parameter, too, eg. batchCommitSizeTestHelper(int num_events_read, int batch_size, int num_events_processed).

Suggested change
batchCommitSizeTestHelper(1000);
batchCommitSizeTestHelper(5);
batchCommitSizeTestHelper(4);
batchCommitSizeTestHelper(1);
batchCommitSizeTestHelper(0);
batchCommitSizeTestHelper(5, 1000, 5);
batchCommitSizeTestHelper(5, 5, 5);
batchCommitSizeTestHelper(5, 4, 4);
batchCommitSizeTestHelper(5, 1, 1);
batchCommitSizeTestHelper(5, 0, 5);

This comment has been minimized.

@lordgamez

lordgamez Sep 8, 2020

Author Contributor

You are right, I made it more explicit in fa06429


REQUIRE(LogTestController::getInstance().countOccurrences("processQueue commit") == expected_num_commits);
}
std::vector<std::string> events{"Event one", "Event two", "Event three", "Event four", "Event five"};

This comment has been minimized.

@hunyadi-dev

hunyadi-dev Sep 3, 2020

Contributor

Minor, but why not just a simple range based for here?

This comment has been minimized.

@lordgamez

lordgamez Sep 8, 2020

Author Contributor

Maybe I just wanted to keep it in a single line, but yea I see it's better to have a simple for loop here, fixed in fa06429

@lordgamez lordgamez force-pushed the lordgamez:MINIFICPP-1349 branch from ed1d22e to fa06429 Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.