MINIFICPP-1288 - FlowController start/load refactor#890
MINIFICPP-1288 - FlowController start/load refactor#890hunyadi-dev wants to merge 11 commits intoapache:mainfrom
Conversation
… FlowController and use it to redefine reload (to be removed)
…oad (to be removed) to reload requirements and load_without_reload
… invocations that assumes that the FlowController is initialized
…ting that the start is initialized
…d run tests accordingly
876798a to
2a4e8ab
Compare
…lowController::start
2a4e8ab to
02aff17
Compare
arpadboda
left a comment
There was a problem hiding this comment.
Most looks good, added some comments.
…initializeSchedulersWithClearedThreadPool
szaszm
left a comment
There was a problem hiding this comment.
Since the requirement of "one has to call load before start" is not documented anywhere, I would restore the initialized_ variable to prevent invalid usage of FlowController.
I fell into this trap of only calling stop/start instead of stop,unload/load,start while working on #875
| timer_scheduler_ = std::make_shared<TimerDrivenSchedulingAgent>(NonNullControllerServiceProviderPtr(this), provenance_repo_, flow_file_repo_, content_repo_, configuration_, thread_pool_); | ||
| event_scheduler_ = std::make_shared<EventDrivenSchedulingAgent>(NonNullControllerServiceProviderPtr(this), provenance_repo_, flow_file_repo_, content_repo_, configuration_, thread_pool_); | ||
| cron_scheduler_ = std::make_shared<CronDrivenSchedulingAgent>(NonNullControllerServiceProviderPtr(this), provenance_repo_, flow_file_repo_, content_repo_, configuration_, thread_pool_); |
There was a problem hiding this comment.
Consider using gsl::make_not_null and relying on implicit conversion to base class pointer.
| timer_scheduler_ = std::make_shared<TimerDrivenSchedulingAgent>(NonNullControllerServiceProviderPtr(this), provenance_repo_, flow_file_repo_, content_repo_, configuration_, thread_pool_); | |
| event_scheduler_ = std::make_shared<EventDrivenSchedulingAgent>(NonNullControllerServiceProviderPtr(this), provenance_repo_, flow_file_repo_, content_repo_, configuration_, thread_pool_); | |
| cron_scheduler_ = std::make_shared<CronDrivenSchedulingAgent>(NonNullControllerServiceProviderPtr(this), provenance_repo_, flow_file_repo_, content_repo_, configuration_, thread_pool_); | |
| timer_scheduler_ = std::make_shared<TimerDrivenSchedulingAgent>(gsl::make_not_null(this), provenance_repo_, flow_file_repo_, content_repo_, configuration_, thread_pool_); | |
| event_scheduler_ = std::make_shared<EventDrivenSchedulingAgent>(gsl::make_not_null(this), provenance_repo_, flow_file_repo_, content_repo_, configuration_, thread_pool_); | |
| cron_scheduler_ = std::make_shared<CronDrivenSchedulingAgent>(gsl::make_not_null(this), provenance_repo_, flow_file_repo_, content_repo_, configuration_, thread_pool_); |
There was a problem hiding this comment.
What is the advantake of using make_not_null? It does nothing, does it?
Update:
I see what you mean now.
I see what you mean, but I disagree. I would definitely avoid adding states like this to an object. I found it already quite a task to decipher in what state can we reach each of the member functions. How about either of these options:
|
I don't really understand what you mean by making |
It is easiest to review this PR on a per-commit basis.
The FlowController methods:
start,stop,load,unload(and maybe evenwaitUnload), were strongly coupled and were controlled through FlowController states that made it difficult to argue about what goes on in each of them.loadhad two versions with only minor differences, one reload (with a few extra steps) and one non-reload. The version that did the reload was only called duringapplyConfiguration, so I moved the extra behaviour required there (and renamed the related functions accordingly to prove there were no other instances of calling reload).loadwas also changing the state ofinitialized_read by only itself andstart, but it is easy to argue thatloadis never called twice andstartis never called without a preceedingload, proving this variable clutter.