adamdebreceni commented on code in PR #2231:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2231#discussion_r4562547211


##########
libminifi/src/core/flow/StructuredConfiguration.cpp:
##########
@@ -1149,4 +1078,83 @@ std::string StructuredConfiguration::serialize(const 
core::ProcessGroup& process
   return flow_serializer_->serialize(process_group, schema_, 
sensitive_values_encryptor_, {}, parameter_contexts_);
 }
 
+void StructuredConfiguration::parseReportingTasks(const Node& 
reporting_tasks_node, core::ProcessGroup* parent_group) {
+  if (!reporting_tasks_node || !reporting_tasks_node.isSequence()) {
+    return;
+  }
+  for (const auto& reporting_task_node : reporting_tasks_node) {
+    checkRequiredField(reporting_task_node, schema_.name);
+    auto name = reporting_task_node[schema_.name].getString().value();
+    utils::Identifier id;
+    id = getOrGenerateId(reporting_task_node);
+
+    checkRequiredField(reporting_task_node, schema_.type);
+    auto type = reporting_task_node[schema_.type].getString().value();
+
+    auto reporting_task = 
createProcessor(utils::string::partAfterLastOccurrenceOf(type, '.'), type, 
name, id);
+    if (!reporting_task) {
+      logger_->log_error("Could not create a processor {} with id {}", name, 
id.to_string());
+      throw std::invalid_argument("Could not create processor " + name);
+    }
+
+    reporting_task->setFlowIdentifier(flow_version_->getFlowIdentifier());
+
+    auto scheduling_strategy = getOptionalField(reporting_task_node, 
schema_.scheduling_strategy, DEFAULT_SCHEDULING_STRATEGY);
+    if (scheduling_strategy == "TIMER_DRIVEN") {
+      reporting_task->setSchedulingStrategy(core::TIMER_DRIVEN);
+    } else {
+      reporting_task->setSchedulingStrategy(core::CRON_DRIVEN);
+    }
+    auto scheduling_period_str = getOptionalField(reporting_task_node, 
schema_.scheduling_period, DEFAULT_SCHEDULING_PERIOD_STR);
+    if (scheduling_strategy == "TIMER_DRIVEN") {
+      if (auto scheduling_period = 
utils::timeutils::StringToDuration<std::chrono::nanoseconds>(scheduling_period_str))
 {
+        reporting_task->setSchedulingPeriod(*scheduling_period);
+      }
+    } else {
+      reporting_task->setCronPeriod(scheduling_period_str);
+    }
+
+    if (auto penalization_node = 
reporting_task_node[schema_.penalization_period]) {
+      if (auto penalization_period = 
utils::timeutils::StringToDuration<std::chrono::milliseconds>(penalization_node.getString().value()))
 {
+        reporting_task->setPenalizationPeriod(penalization_period.value());
+      }
+    }
+
+    if (auto yield_node = reporting_task_node[schema_.proc_yield_period]) {
+      if (auto yield_period = 
utils::timeutils::StringToDuration<std::chrono::milliseconds>(yield_node.getString().value()))
 {
+        reporting_task->setYieldPeriodMsec(yield_period.value());
+      }
+    }
+
+    if (auto bulletin_level_node = 
reporting_task_node[schema_.bulletin_level]) {
+      if (auto bulletin_level = bulletin_level_node.getString().value(); 
!bulletin_level.empty()) {
+        
reporting_task->setLogBulletinLevel(core::logging::mapStringToLogLevel(bulletin_level));
+      }
+    }
+
+    if (auto run_node = reporting_task_node[schema_.runduration_nanos]) {
+      if (auto run_duration_nanos = 
parsing::parseIntegral<uint64_t>(run_node.getIntegerAsString().value())) {
+        
reporting_task->setRunDurationNano(std::chrono::nanoseconds(*run_duration_nanos));
+      }
+    }
+
+    if (Node properties_node = 
reporting_task_node[schema_.processor_properties]) {
+      parsePropertiesNode(properties_node, *reporting_task, name, nullptr);
+    }
+
+    reporting_task->setLoggerCallback([this, processor = 
reporting_task.get()](core::logging::LOG_LEVEL level, const std::string& 
message) {
+      if (level < processor->getLogBulletinLevel()) {
+        return;
+      }
+      if (bulletin_store_) {
+        bulletin_store_->addProcessorBulletin(*processor, level, message);
+      }
+    });

Review Comment:
   instead of removing it, I added the default implementation so the bulletins 
work for reporting tasks as well



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