You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "martinzink (via GitHub)" <gi...@apache.org> on 2024/07/02 17:11:16 UTC

Re: [PR] MINIFICPP-2398 Only commit once per time_slice in EventDrivenSchedulingAgent [nifi-minifi-cpp]

martinzink commented on code in PR #1815:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1815#discussion_r1662612073


##########
libminifi/src/core/Processor.cpp:
##########
@@ -167,44 +167,43 @@ bool Processor::addConnection(Connectable* conn) {
 bool Processor::flowFilesOutGoingFull() const {
   std::lock_guard<std::mutex> lock(mutex_);
 
-  for (const auto& connection_pair : outgoing_connections_) {
-    // We already has connection for this relationship
-    std::set<Connectable*> existedConnection = connection_pair.second;
-    const bool has_full_connection = std::any_of(begin(existedConnection), end(existedConnection), [](const Connectable* conn) {
-      auto connection = dynamic_cast<const Connection*>(conn);
+  for (const auto& [_name, existed_connection] : outgoing_connections_) {
+    if (ranges::any_of(existed_connection, [](const Connectable* conn) {
+      const auto connection = dynamic_cast<const Connection*>(conn);
       return connection && connection->backpressureThresholdReached();
-    });
-    if (has_full_connection) { return true; }
+    })) {
+      return true;
+    }
   }
 
   return false;
 }
 
-void Processor::onTrigger(const std::shared_ptr<ProcessContext>& context, const std::shared_ptr<ProcessSessionFactory>& session_factory) {
-  ++metrics_->iterations;
-  auto session = session_factory->createSession();
-  session->setMetrics(metrics_);
-
+void Processor::triggerAndCommit(const std::shared_ptr<ProcessContext>& context, const std::shared_ptr<ProcessSessionFactory>& session_factory) {
+  const auto process_session = session_factory->createSession();
+  process_session->setMetrics(metrics_);
   try {
-    // Call the virtual trigger function
-    auto start = std::chrono::steady_clock::now();
-    onTriggerSharedPtr(context, session);
-    metrics_->addLastOnTriggerRuntime(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start));
-    start = std::chrono::steady_clock::now();
-    session->commit();
-    metrics_->addLastSessionCommitRuntime(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start));

Review Comment:
   I've moved that logic into the (imho more fitting place) ProcessSession::commit
   https://github.com/apache/nifi-minifi-cpp/pull/1815/files#diff-d55088efe0f1ad2a600dba414bfee749c5fb634ab44418146623f892bd6756a4R807-R922



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org