szaszm commented on code in PR #1941:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1941#discussion_r2282290944


##########
libminifi/include/c2/FlowStatusBuilder.h:
##########


Review Comment:
   I think this whole class should be a function called `buildFlowStatus`, with 
parameters instead of data members.



##########
libminifi/include/c2/FlowStatusRequest.h:
##########
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <string>
+#include <unordered_set>
+
+namespace org::apache::nifi::minifi::c2 {
+
+enum class FlowStatusQueryType {
+  processor,
+  connection,
+  instance,
+  systemdiagnostics
+};
+
+enum class FlowStatusQueryOption {
+  health,
+  stats,
+  bulletins,
+  processorstats,
+  flowfilerepositoryusage,
+  contentrepositoryusage
+};
+
+struct FlowStatusRequest {
+  FlowStatusQueryType query_type;
+  std::string identifier;
+  std::unordered_set<FlowStatusQueryOption> options;
+
+  explicit FlowStatusRequest(const std::string& query_string);

Review Comment:
   A long comment explaining the format would be greatly appreciated. Also, 
consider taking a string_view.



##########
libminifi/test/unit/FlowStatusBuilderTests.cpp:
##########


Review Comment:
   Is flowStatus thread-safe? Can we spam hundreds of requests in parallel and 
check that each one gets the proper result?
   Is there no data race between writers of metrics / bulletins / etc and 
flowStatus readers? Are the reads / writes synchronized?



##########
libminifi/src/c2/ControllerSocketProtocol.cpp:
##########
@@ -187,6 +187,12 @@ void ControllerSocketProtocol::initialize() {
   }
 }
 
+void ControllerSocketProtocol::setRoot(core::ProcessGroup* root) {
+  if (auto controller_socket_reporter = controller_socket_reporter_.lock()) {
+    controller_socket_reporter->setRoot(root);
+  }
+}
+

Review Comment:
   What happens to the pointed-to root process group on a flow update? Does the 
FlowController call setRoot with the new root process group before freeing the 
old root?



##########
controller/Controller.cpp:
##########
@@ -267,4 +267,24 @@ nonstd::expected<void, std::string> getDebugBundle(const 
utils::net::SocketData&
   return {};
 }
 
+bool getFlowStatus(const utils::net::SocketData& socket_data, const 
std::string& status_query, std::ostream &out) {
+  std::unique_ptr<io::BaseStream> connection_stream = 
std::make_unique<utils::net::AsioSocketConnection>(socket_data);

Review Comment:
   Why does this need to be cast to a base class pointer?
   ```suggestion
     const auto connection_stream = 
std::make_unique<utils::net::AsioSocketConnection>(socket_data);
   ```



##########
libminifi/src/core/BulletinStore.cpp:
##########
@@ -68,6 +68,17 @@ std::deque<Bulletin> 
BulletinStore::getBulletins(std::optional<std::chrono::syst
   return {};
 }
 
+std::vector<Bulletin> BulletinStore::getBulletinsForProcessor(const 
std::string& processor_uuid) const {
+  std::lock_guard<std::mutex> lock(mutex_);
+  std::vector<Bulletin> bulletins;
+  for (const auto& bulletin : bulletins_) {
+    if (bulletin.source_id == processor_uuid) {
+      bulletins.push_back(bulletin);
+    }
+  }
+  return bulletins;

Review Comment:
   ```suggestion
     return bulletins_
         | std::ranges::filter([&](const auto& elem) { return elem.source_id == 
processor_uuid; })
         | ranges::to<std::vector>();
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to