fgerlits commented on code in PR #1933: URL: https://github.com/apache/nifi-minifi-cpp/pull/1933#discussion_r2084498760
########## libminifi/src/core/controller/StandardControllerServiceProvider.cpp: ########## @@ -0,0 +1,128 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "core/controller/StandardControllerServiceProvider.h" + +#include "core/controller/StandardControllerServiceNode.h" +#include "core/TypedValues.h" + +using namespace std::literals::chrono_literals; + +namespace org::apache::nifi::minifi::core::controller { + +std::shared_ptr<ControllerServiceNode> StandardControllerServiceProvider::createControllerService(const std::string& type, const std::string&, const std::string& id, bool) { Review Comment: If we are not using the 2nd and 4th arguments, can we remove them from the interface? ########## libminifi/src/core/controller/StandardControllerServiceNode.cpp: ########## @@ -46,16 +57,32 @@ bool StandardControllerServiceNode::enable() { for (const auto& service : linked_controller_services_) { services.push_back(service->getControllerServiceImplementation()); if (!service->enable()) { - logger_->log_debug("Linked Service '{}' could not be enabled", service->getName()); + logger_->log_warn("Linked Service '{}' could not be enabled", service->getName()); return false; } } - impl->setLinkedControllerServices(services); - impl->onEnable(); + try { + impl->setLinkedControllerServices(services); + impl->onEnable(); + } catch(const std::exception& e) { + logger_->log_warn("Service '{}' failed to enable: {}", getName(), e.what()); + controller_service_->setState(ENABLING); + return false; + } + } else { + logger_->log_warn("Service '{}' service implementation could not be found", controller_service_->getName()); + controller_service_->setState(ENABLING); + return false; Review Comment: This block could be moved up to line 52, as `if (nullptr == impl) { ... }`, to simplify the structure. -- 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]
