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

Method stop

libminifi/src/FlowController.cpp:179–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179int16_t FlowController::stop() {
180 std::lock_guard<std::recursive_mutex> flow_lock(mutex_);
181 if (running_) {
182 // immediately indicate that we are not running
183 logger_->log_info("Stop Flow Controller");
184 if (this->root_) {
185 // stop source processors first
186 this->root_->stopProcessing(timer_scheduler_, event_scheduler_, cron_scheduler_, [] (const std::shared_ptr<core::Processor>& proc) -> bool {
187 return !proc->hasIncomingConnections();
188 });
189 // we enable C2 to progressively increase the timeout
190 // in case it sees that waiting for a little longer could
191 // allow the FlowFiles to be processed
192 auto shutdown_start = std::chrono::steady_clock::now();
193 while ((std::chrono::steady_clock::now() - shutdown_start) < loadShutdownTimeoutFromConfiguration().value_or(std::chrono::milliseconds{0}) &&
194 this->root_->getTotalFlowFileCount() != 0) {
195 std::this_thread::sleep_for(shutdown_check_interval_);
196 }
197 // shutdown all other processors as well
198 this->root_->stopProcessing(timer_scheduler_, event_scheduler_, cron_scheduler_);
199 }
200 // stop after we've attempted to stop the processors.
201 timer_scheduler_->stop();
202 event_scheduler_->stop();
203 cron_scheduler_->stop();
204 thread_pool_.shutdown();
205 /* STOP! Before you change it, consider the following:
206 * -Stopping the schedulers doesn't actually quit the onTrigger functions of processors
207 * -They only guarantee that the processors are not scheduled any more
208 * -After the threadpool is stopped we can make sure that processors don't need repos and controllers anymore */
209 if (this->root_) {
210 this->root_->drainConnections();
211 }
212 this->flow_file_repo_->stop();
213 this->provenance_repo_->stop();
214 // stop the ControllerServices
215 this->controller_service_provider_impl_->disableAllControllerServices();
216 running_ = false;
217 }
218 return 0;
219}
220
221/**
222 * This function will attempt to unload yaml and stop running Processors.

Callers

nothing calls this directly

Calls 7

log_infoMethod · 0.80
stopProcessingMethod · 0.80
getTotalFlowFileCountMethod · 0.80
shutdownMethod · 0.80
drainConnectionsMethod · 0.80

Tested by

no test coverage detected