Skip to content

Commit 4736c83

Browse files
committed
review changes
1 parent 3e44087 commit 4736c83

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

libminifi/include/core/controller/ControllerServiceNodeMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ControllerServiceNodeMap {
4545

4646
bool put(std::string id, std::shared_ptr<ControllerServiceNode> controller_service_node, ProcessGroup* parent_group);
4747

48-
bool register_alternative_key(std::string primary_key, std::string alternative_key);
48+
bool registerAlternativeKey(std::string primary_key, std::string alternative_key);
4949

5050
void clear();
5151
std::vector<std::shared_ptr<ControllerServiceNode>> getAllControllerServices() const;

libminifi/src/core/controller/ControllerServiceNodeMap.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ ControllerServiceNode* ControllerServiceNodeMap::get(const std::string &id, cons
5353

5454
bool ControllerServiceNodeMap::put(std::string id, std::shared_ptr<ControllerServiceNode> controller_service_node,
5555
ProcessGroup* parent_group) {
56+
std::scoped_lock lock(mutex_);
5657
if (id.empty() || controller_service_node == nullptr || alternative_keys.contains(id)) {
5758
return false;
5859
}
59-
std::scoped_lock lock(mutex_);
6060
auto [_it, success] = services_.emplace(std::move(id), ServiceEntry{.controller_service_node = std::move(controller_service_node), .parent_group = parent_group});
6161
return success;
6262
}
@@ -68,6 +68,7 @@ void ControllerServiceNodeMap::clear() {
6868
node.controller_service_node->disable();
6969
}
7070
services_.clear();
71+
alternative_keys.clear();
7172
}
7273

7374
std::vector<std::shared_ptr<ControllerServiceNode>> ControllerServiceNodeMap::getAllControllerServices() const {
@@ -95,9 +96,9 @@ const ControllerServiceNodeMap::ServiceEntry* ControllerServiceNodeMap::getEntry
9596
}
9697

9798

98-
bool ControllerServiceNodeMap::register_alternative_key(std::string primary_key, std::string alternative_key) {
99+
bool ControllerServiceNodeMap::registerAlternativeKey(std::string primary_key, std::string alternative_key) {
99100
std::scoped_lock lock(mutex_);
100-
if (!services_.contains(primary_key)) {
101+
if (!services_.contains(primary_key) || services_.contains(alternative_key) || alternative_keys.contains(alternative_key)) {
101102
return false;
102103
}
103104

libminifi/src/core/controller/ControllerServiceProvider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void ControllerServiceProvider::putControllerServiceNode(const std::string& prim
5050
gsl_Expects(controller_map_);
5151
controller_map_->put(primary_key, controller_service_node, process_group);
5252
if (alternative_key) {
53-
controller_map_->register_alternative_key(primary_key, *alternative_key);
53+
controller_map_->registerAlternativeKey(primary_key, *alternative_key);
5454
}
5555
}
5656

libminifi/src/core/controller/StandardControllerServiceProvider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ std::shared_ptr<ControllerServiceNode> StandardControllerServiceProvider::create
4040

4141
controller_map_->put(id, new_service_node, parent_group);
4242
if (alternative_key) {
43-
controller_map_->register_alternative_key(id, *alternative_key);
43+
controller_map_->registerAlternativeKey(id, *alternative_key);
4444
}
4545

4646
return new_service_node;

0 commit comments

Comments
 (0)