szaszm commented on code in PR #2057:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2057#discussion_r2489223370
##########
libminifi/src/c2/C2Agent.cpp:
##########
@@ -871,6 +852,46 @@ void C2Agent::handle_sync(const
org::apache::nifi::minifi::c2::C2ContentResponse
enqueue_c2_response(std::move(response));
}
+void C2Agent::handle_start_stop(const C2ContentResponse& resp) {
+ const auto lowered_response_name = utils::string::toLower(resp.name);
+ if (lowered_response_name == "c2") {
+ std::ignore = raise(SIGTERM);
+ }
+
+ auto executeStartStopOnComponent = [this, &resp](const std::string&
component_name) {
+ update_sink_->executeOnComponent(component_name, [this, &resp,
&component_name] (state::StateController& component) {
+ const std::string component_message = component_name == "FlowController"
? "all processors" : "processor " + component_name;
+ if (resp.op == Operation::stop) {
+ logger_->log_debug("Stopping {}", component_message);
+ component.stop();
+ } else {
+ logger_->log_debug("Starting {}", component_message);
+ component.start();
+ }
+ });
+ };
+
+ if (lowered_response_name == "flow" || lowered_response_name == "processor")
{
+ if (lowered_response_name == "flow") {
+ executeStartStopOnComponent("FlowController");
+ } else {
+ auto processor_id = resp.getStringArgument("processorId");
+ if (processor_id) {
+ executeStartStopOnComponent(processor_id.value());
+ } else {
+ logger_->log_warn("Processor start/stop request missing 'processorId'
argument");
+ }
+ }
+ } else {
+ executeStartStopOnComponent(resp.name);
+ }
Review Comment:
```suggestion
if (lowered_response_name == "flow" ) {
executeStartStopOnComponent("FlowController");
} else if (lowered_response_name == "processor") {
auto processor_id = resp.getStringArgument("processorId");
if (processor_id) {
executeStartStopOnComponent(processor_id.value());
} else {
logger_->log_warn("Processor start/stop request missing 'processorId'
argument");
}
} else {
executeStartStopOnComponent(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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]