lordgamez commented on code in PR #1503:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1503#discussion_r1150924463


##########
libminifi/src/c2/ControllerSocketMetricsPublisher.cpp:
##########
@@ -0,0 +1,96 @@
+/**
+ * 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.
+ */
+#include "c2/ControllerSocketMetricsPublisher.h"
+#include "utils/gsl.h"
+#include "core/Resource.h"
+#include "c2/C2Agent.h"
+
+namespace org::apache::nifi::minifi::c2 {
+
+std::unordered_map<std::string, ControllerSocketReporter::QueueSize> 
ControllerSocketMetricsPublisher::getQueueSizes() {
+  std::lock_guard<std::recursive_mutex> guard(queue_metrics_node_mutex_);
+  std::unordered_map<std::string, QueueSize> sizes;
+  if (!queue_metrics_node_) {
+    return sizes;
+  }
+  for (const auto& metric : queue_metrics_node_->calculateMetrics()) {
+    gsl_Expects(metric.labels.contains("connection_name"));
+    if (metric.name == "queue_size") {
+      sizes[metric.labels.at("connection_name")].queue_size = 
static_cast<uint32_t>(metric.value);
+    } else if (metric.name == "queue_size_max") {
+      sizes[metric.labels.at("connection_name")].queue_size_max = 
static_cast<uint32_t>(metric.value);
+    }
+  }
+  return sizes;
+}
+
+std::unordered_set<std::string> 
ControllerSocketMetricsPublisher::getFullConnections() {
+  std::lock_guard<std::recursive_mutex> guard(queue_metrics_node_mutex_);
+  std::unordered_set<std::string> full_connections;
+  if (!queue_metrics_node_) {
+    return full_connections;
+  }

Review Comment:
   You are right it's not needed here, updated in 
be90c45f9f3fe3d065a8470e5b86514d3dfc6039



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