MINIFICPP-2771 Use separate state managers in schedule and trigger threads#2157
MINIFICPP-2771 Use separate state managers in schedule and trigger threads#2157lordgamez wants to merge 6 commits intoapache:mainfrom
Conversation
3a197b2 to
305a31f
Compare
| void StatefulProcessor::onTrigger(core::ProcessContext&, core::ProcessSession&) { | ||
| void StatefulProcessor::onTrigger(core::ProcessContext& context, core::ProcessSession&) { | ||
| std::lock_guard<std::mutex> lock(mutex_); | ||
| state_manager_ = context.getStateManager(); |
There was a problem hiding this comment.
i know this is test code, but I think it would be clearer if state_manager_ would cease to be a member and only live on the stack during the onschedule and ontrigger
| std::chrono::system_clock::time_point start_push_time_; | ||
| std::vector<std::shared_ptr<core::FlowFile>> batched_flowfiles_; | ||
| core::StateManager* state_manager_; | ||
| core::StateManager* state_manager_ = nullptr; |
There was a problem hiding this comment.
Could we remove this member and only use the state manager in the ontirgger and onschedule as a stack variabl?
There was a problem hiding this comment.
This is only used as part of the LogBatch object, but I added a gsl::finally directive to clear it at the end of the onTrigger to be sure in f9e15ed
szaszm
left a comment
There was a problem hiding this comment.
I'm +1 for this after Martin's comments are resolved. I can see that this design is far from the best, but any better design would require thorough refactoring of core APIs, and I can't suggest a better low impact fix.
b71e562 to
8d8f53c
Compare
https://issues.apache.org/jira/browse/MINIFICPP-2771
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:
For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.