[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1255: MINIFICPP-1750 Fix C2 clear operation with corecomponentstate operand

2022-02-08 Thread GitBox


lordgamez commented on a change in pull request #1255:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1255#discussion_r801643210



##
File path: libminifi/src/c2/C2Agent.cpp
##
@@ -556,6 +519,43 @@ void C2Agent::handle_describe(const C2ContentResponse 
&resp) {
   enqueue_c2_response(std::move(response));
 }
 
+void C2Agent::handle_clear(const C2ContentResponse &resp) {
+  if (resp.name == "connection") {
+for (const auto& connection : resp.operation_arguments) {
+  logger_->log_debug("Clearing connection %s", 
connection.second.to_string());
+  update_sink_->clearConnection(connection.second.to_string());
+}
+  } else if (resp.name == "repositories") {
+update_sink_->drainRepositories();
+  } else if (resp.name == "corecomponentstate") {
+for (const auto& corecomponent : resp.operation_arguments) {
+  std::vector> components = 
update_sink_->getComponents(corecomponent.second.to_string());

Review comment:
   Now we iterate through the requrested components in the operation 
arguments instead of using the previously constant `"corecomponentstate"` which 
was set in the resp.name




-- 
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-unsubscr...@nifi.apache.org

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




[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1255: MINIFICPP-1750 Fix C2 clear operation with corecomponentstate operand

2022-02-07 Thread GitBox


lordgamez commented on a change in pull request #1255:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1255#discussion_r800541483



##
File path: libminifi/src/c2/C2Agent.cpp
##
@@ -556,6 +519,43 @@ void C2Agent::handle_describe(const C2ContentResponse 
&resp) {
   enqueue_c2_response(std::move(response));
 }
 
+void C2Agent::handle_clear(const C2ContentResponse &resp) {
+  if (resp.name == "connection") {
+for (const auto& connection : resp.operation_arguments) {
+  logger_->log_debug("Clearing connection %s", 
connection.second.to_string());
+  update_sink_->clearConnection(connection.second.to_string());
+}
+  } else if (resp.name == "repositories") {
+update_sink_->drainRepositories();
+  } else if (resp.name == "corecomponentstate") {
+for (const auto& corecomponent : resp.operation_arguments) {
+  std::vector> components = 
update_sink_->getComponents(corecomponent.second.to_string());
+  auto state_manager_provider = 
core::ProcessContext::getStateManagerProvider(logger_, controller_, 
configuration_);
+  if (state_manager_provider != nullptr) {
+for (auto &component : components) {
+  logger_->log_debug("Clearing state for component %s", 
component->getComponentName());
+  auto state_manager = 
state_manager_provider->getCoreComponentStateManager(component->getComponentUUID());
+  if (state_manager != nullptr) {
+component->stop();
+state_manager->clear();
+state_manager->persist();
+component->start();
+  } else {
+logger_->log_warn("Failed to get StateManager for component %s", 
component->getComponentUUID().to_string());
+  }
+}
+  } else {
+logger_->log_error("Failed to get StateManagerProvider");
+  }
+}
+  } else {
+logger_->log_error("Unknown clear operand %s", resp.name);
+  }
+
+  C2Payload response(Operation::ACKNOWLEDGE, resp.ident, true);
+  enqueue_c2_response(std::move(response));

Review comment:
   Changed to send acknowledge message even for unknown operands as the C2 
server should be expecting it.




-- 
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-unsubscr...@nifi.apache.org

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