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



##########
File path: libminifi/src/c2/C2Agent.cpp
##########
@@ -334,44 +334,7 @@ struct C2DebugBundleError : public C2TransferError {
 void C2Agent::handle_c2_server_response(const C2ContentResponse &resp) {
   switch (resp.op.value()) {
     case Operation::CLEAR:
-      // we've been told to clear something
-      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());
-        }
-        C2Payload response(Operation::ACKNOWLEDGE, resp.ident, true);
-        enqueue_c2_response(std::move(response));
-      } else if (resp.name == "repositories") {
-        update_sink_->drainRepositories();
-        C2Payload response(Operation::ACKNOWLEDGE, resp.ident, true);
-        enqueue_c2_response(std::move(response));
-      } else if (resp.name == "corecomponentstate") {
-        // TODO(bakaid): untested
-        std::vector<std::shared_ptr<state::StateController>> components = 
update_sink_->getComponents(resp.name);
-        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");
-        }
-        C2Payload response(Operation::ACKNOWLEDGE, resp.ident, true);
-        enqueue_c2_response(std::move(response));
-      } else {
-        logger_->log_debug("Clearing unknown %s", resp.name);
-      }
-
+      handle_clear(resp);

Review comment:
       The definition of the function changed in both PRs in different ways, so 
it will definitely conflict either way. I would keep it this way for now and 
would resolve the conflict when the other PR is merged.




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