bakaid commented on a change in pull request #721: MINIFICPP-1135 - Add a
watchdog to schedulingAgent to warn in case of…
URL: https://github.com/apache/nifi-minifi-cpp/pull/721#discussion_r372866799
##########
File path: libminifi/src/SchedulingAgent.cpp
##########
@@ -125,6 +138,17 @@ bool SchedulingAgent::onTrigger(const
std::shared_ptr<core::Processor> &processo
return false;
}
+void SchedulingAgent::watchDogFunc() {
+ std::lock_guard<std::mutex> lock(watchdog_mtx_);
+ auto now = std::chrono::system_clock::now();
+ for (const auto& info : scheduled_processors_) {
+ auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now -
info.start_time_).count();
+ if (elapsed > SCHEDULING_WATCHDOG_ALERT_PERIOD) {
+ logger_->log_warn("%s::onTrigger is running for %zu ms in %s",
info.name_, elapsed, info.uuid_);
Review comment:
`std::chrono::duration::count()` has a return type of `Rep`, which in the
case of `std::chrono::milliseconds` is `/*signed integer type of at least 45
bits*/` (https://en.cppreference.com/w/cpp/chrono/duration).
So we can safely assume it's an `int64_t`, but surely not a `size_t`, that
the `%zu` would indicate.
I suggest making `elapsed` an `int64_t` and using `%lld` in the format
string (`PRId64` would be the completely correct solution, but we don't use
these anywhere, that's the scope of a complete refactor).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services