MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / load

Method load

libminifi/src/FlowController.cpp:287–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285}
286
287void FlowController::load(const std::shared_ptr<core::ProcessGroup> &root, bool reload) {
288 std::lock_guard<std::recursive_mutex> flow_lock(mutex_);
289 if (running_) {
290 stop();
291 }
292 if (!initialized_) {
293 if (reload) {
294 io::NetworkPrioritizerFactory::getInstance()->clearPrioritizer();
295 }
296
297 if (root) {
298 logger_->log_info("Load Flow Controller from provided root");
299 this->root_ = root;
300 } else {
301 logger_->log_info("Instantiating new flow");
302 this->root_ = std::shared_ptr<core::ProcessGroup>(loadInitialFlow());
303 }
304
305 logger_->log_info("Loaded root processor Group");
306 logger_->log_info("Initializing timers");
307 controller_service_provider_impl_ = flow_configuration_->getControllerServiceProvider();
308 auto base_shared_ptr = std::dynamic_pointer_cast<core::controller::ControllerServiceProvider>(shared_from_this());
309
310 if (!thread_pool_.isRunning() || reload) {
311 thread_pool_.shutdown();
312 thread_pool_.setMaxConcurrentTasks(configuration_->getInt(Configure::nifi_flow_engine_threads, 2));
313 thread_pool_.setControllerServiceProvider(base_shared_ptr);
314 thread_pool_.start();
315 }
316
317 conditionalReloadScheduler<TimerDrivenSchedulingAgent>(timer_scheduler_, !timer_scheduler_ || reload);
318 conditionalReloadScheduler<EventDrivenSchedulingAgent>(event_scheduler_, !event_scheduler_ || reload);
319 conditionalReloadScheduler<CronDrivenSchedulingAgent>(cron_scheduler_, !cron_scheduler_ || reload);
320
321 std::static_pointer_cast<core::controller::StandardControllerServiceProvider>(controller_service_provider_impl_)->setRootGroup(root_);
322 std::static_pointer_cast<core::controller::StandardControllerServiceProvider>(controller_service_provider_impl_)->setSchedulingAgent(
323 std::static_pointer_cast<minifi::SchedulingAgent>(event_scheduler_));
324
325 logger_->log_info("Loaded controller service provider");
326
327 /*
328 * Without reset we have to distinguish a fresh restart and a reload, to decide if we have to
329 * increment the claims' counter on behalf of the persisted instances.
330 * ResourceClaim::getStreamCount is not suitable as multiple persisted instances
331 * might have the same claim.
332 * e.g. without reset a streamCount of 3 could mean the following:
333 * - it was a fresh restart and 3 instances of this claim have already been resurrected -> we must increment
334 * - it was a reload and 3 instances have been persisted before the shutdown -> we must not increment
335 */
336 content_repo_->reset();
337 logger_->log_info("Reset content repository");
338
339 // Load Flow File from Repo
340 loadFlowRepo();
341 logger_->log_info("Loaded flow repository");
342 initialized_ = true;
343 }
344}

Callers 15

getControllerServiceFunction · 0.45
printManifestFunction · 0.45
mainFunction · 0.45
getNextProtocolMethod · 0.45
shouldReduceMethod · 0.45
processMethod · 0.45
to_stringMethod · 0.45
run_tasksMethod · 0.45
shutdownMethod · 0.45
processMethod · 0.45
ConnectableMethod · 0.45

Calls 11

clearPrioritizerMethod · 0.80
log_infoMethod · 0.80
shutdownMethod · 0.80
getIntMethod · 0.80
setRootGroupMethod · 0.80
setSchedulingAgentMethod · 0.80
isRunningMethod · 0.45
setMaxConcurrentTasksMethod · 0.45
startMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected