-
Notifications
You must be signed in to change notification settings - Fork 99
MINIFICPP-2700 Log errors if ContentRepository creation failed #2083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be better to inject a logger as a function parameter instead of creating one locally for a semi-related class.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good idea, review changes |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,33 +28,31 @@ using namespace std::literals::chrono_literals; | |
|
|
||
| namespace org::apache::nifi::minifi::core { | ||
|
|
||
| std::unique_ptr<core::ContentRepository> createContentRepository(const std::string& configuration_class_name, bool fail_safe, const std::string& repo_name) { | ||
| std::unique_ptr<core::ContentRepository> createContentRepository(const std::string& configuration_class_name, | ||
| const std::string& repo_name, | ||
| logging::Logger* logger) { | ||
| std::string class_name_lc = configuration_class_name; | ||
| std::transform(class_name_lc.begin(), class_name_lc.end(), class_name_lc.begin(), ::tolower); | ||
| try { | ||
| auto return_obj = core::ClassLoader::getDefaultClassLoader().instantiate<core::ContentRepository>(class_name_lc, | ||
| class_name_lc); | ||
| if (return_obj) { | ||
| return_obj->setName(repo_name); | ||
| return return_obj; | ||
| } | ||
| if (class_name_lc == "volatilecontentrepository") { | ||
| return std::make_unique<core::repository::VolatileContentRepository>(repo_name); | ||
| } else if (class_name_lc == "filesystemrepository") { | ||
| return std::make_unique<core::repository::FileSystemRepository>(repo_name); | ||
| } | ||
| if (fail_safe) { | ||
| return std::make_unique<core::repository::VolatileContentRepository>("fail_safe"); | ||
| } else { | ||
| throw std::runtime_error("Support for the provided configuration class could not be found"); | ||
| } | ||
| } catch (const std::runtime_error&) { | ||
| if (fail_safe) { | ||
| return std::make_unique<core::repository::VolatileContentRepository>("fail_safe"); | ||
| } | ||
|
|
||
| auto return_obj = core::ClassLoader::getDefaultClassLoader().instantiate<core::ContentRepository>(class_name_lc, | ||
| class_name_lc); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this indentation looks bad; it may be better to keep this on one line |
||
| if (return_obj) { | ||
| return_obj->setName(repo_name); | ||
| return return_obj; | ||
| } | ||
|
|
||
| throw std::runtime_error("Support for the provided configuration class could not be found"); | ||
| if (class_name_lc == "volatilecontentrepository") { | ||
| return std::make_unique<core::repository::VolatileContentRepository>(repo_name); | ||
| } | ||
| if (class_name_lc == "filesystemrepository") { | ||
| return std::make_unique<core::repository::FileSystemRepository>(repo_name); | ||
| } | ||
|
|
||
| logger->log_critical("Could not create the configured content repository ({})", configuration_class_name); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we allow |
||
| if (class_name_lc == "databasecontentrepository") { | ||
| logger->log_error("To use DatabaseContentRepository MiNiFi needs RocksDB extension, please check the extension path configured in minifi.properties"); | ||
| } | ||
| throw std::runtime_error("Support for the provided configuration class could not be found, check logs for more details"); | ||
| } | ||
|
|
||
| std::unique_ptr<core::Repository> createRepository(const std::string& configuration_class_name, const std::string& repo_name) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the documentation of the
fail_safeparameter should be removed (also below, before thecreateRepositoryfunction)