msharee9 commented on a change in pull request #734: MINIFICPP-1157 Implement 
lightweight C2 heartbeat.
URL: https://github.com/apache/nifi-minifi-cpp/pull/734#discussion_r378462016
 
 

 ##########
 File path: libminifi/src/c2/C2Agent.cpp
 ##########
 @@ -315,16 +317,35 @@ void C2Agent::performHeartBeat() {
     payload.addPayload(std::move(deviceInfo));
   }
 
-  if (!root_response_nodes_.empty()) {
-    for (auto metric : root_response_nodes_) {
-      C2Payload child_metric_payload(Operation::HEARTBEAT);
-      child_metric_payload.setLabel(metric.first);
-      if (metric.second->isArray()) {
-        child_metric_payload.setContainer(true);
-      }
-      serializeMetrics(child_metric_payload, metric.first, 
metric.second->serialize(), metric.second->isArray());
-      payload.addPayload(std::move(child_metric_payload));
+  for (auto metric : root_response_nodes_) {
+    C2Payload child_metric_payload(Operation::HEARTBEAT);
+    bool isArray{false};
+    std::string metricName;
+    std::vector<state::response::SerializedResponseNode> metrics;
+    std::shared_ptr<state::response::NodeReporter> reporter;
+    std::shared_ptr<state::response::ResponseNode> agentInfoManifest;
+
+    //Send agent manifest in first heartbeat
+    if (!manifest_sent_
+        && (reporter = 
std::dynamic_pointer_cast<state::response::NodeReporter>(update_sink_))
+        && (agentInfoManifest = reporter->getAgentInformationWithManifest())
+        && metric.first == agentInfoManifest->getName()) {
+
+        metricName = agentInfoManifest->getName();
+        isArray = agentInfoManifest->isArray();
+        metrics = std::move(agentInfoManifest->serialize());
+        manifest_sent_ = true;
 
 Review comment:
   If C2 server does not receive the manifest in the first heartbeat, it 
requests manifest in DESCRIBE command when it next receives lightweight 
heartbeat. Sending the manifest during the first heartbeat is a slight 
optimization.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to