diff options
author | Tor Brede Vekterli <vekterli@yahooinc.com> | 2023-08-21 14:33:18 +0000 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@yahooinc.com> | 2023-08-21 14:33:18 +0000 |
commit | 15e28e09b7ef78530f3821a82a3743b9dcd3c284 (patch) | |
tree | 4660a8427724f17338f74201fbafbcb43df09fea /storage | |
parent | 58ff45c5a871e91499e262c1c66c2fb4fb3a1b49 (diff) |
Improve naming and make branching more obvious
Diffstat (limited to 'storage')
4 files changed, 21 insertions, 18 deletions
diff --git a/storage/src/vespa/storage/distributor/operations/cancel_scope.cpp b/storage/src/vespa/storage/distributor/operations/cancel_scope.cpp index 3a05ce3975d..af62b369517 100644 --- a/storage/src/vespa/storage/distributor/operations/cancel_scope.cpp +++ b/storage/src/vespa/storage/distributor/operations/cancel_scope.cpp @@ -5,19 +5,19 @@ namespace storage::distributor { CancelScope::CancelScope() : _cancelled_nodes(), - _ownership_lost(false) + _fully_cancelled(false) { } -CancelScope::CancelScope(ownership_change_ctor_tag) noexcept +CancelScope::CancelScope(fully_cancelled_ctor_tag) noexcept : _cancelled_nodes(), - _ownership_lost(true) + _fully_cancelled(true) { } CancelScope::CancelScope(CancelledNodeSet nodes) noexcept : _cancelled_nodes(std::move(nodes)), - _ownership_lost(false) + _fully_cancelled(false) { } @@ -34,7 +34,7 @@ void CancelScope::add_cancelled_node(uint16_t node) { } void CancelScope::merge(const CancelScope& other) { - _ownership_lost |= other._ownership_lost; + _fully_cancelled |= other._fully_cancelled; // Not using iterator insert(first, last) since that explicitly resizes, for (uint16_t node : other._cancelled_nodes) { _cancelled_nodes.insert(node); @@ -42,7 +42,7 @@ void CancelScope::merge(const CancelScope& other) { } CancelScope CancelScope::of_fully_cancelled() noexcept { - return CancelScope(ownership_change_ctor_tag{}); + return CancelScope(fully_cancelled_ctor_tag{}); } CancelScope CancelScope::of_node_subset(CancelledNodeSet nodes) noexcept { diff --git a/storage/src/vespa/storage/distributor/operations/cancel_scope.h b/storage/src/vespa/storage/distributor/operations/cancel_scope.h index 20998375a71..7619a64d39f 100644 --- a/storage/src/vespa/storage/distributor/operations/cancel_scope.h +++ b/storage/src/vespa/storage/distributor/operations/cancel_scope.h @@ -24,11 +24,11 @@ public: using CancelledNodeSet = vespalib::hash_set<uint16_t>; private: CancelledNodeSet _cancelled_nodes; - bool _ownership_lost; + bool _fully_cancelled; - struct ownership_change_ctor_tag {}; + struct fully_cancelled_ctor_tag {}; - explicit CancelScope(ownership_change_ctor_tag) noexcept; + explicit CancelScope(fully_cancelled_ctor_tag) noexcept; explicit CancelScope(CancelledNodeSet nodes) noexcept; public: CancelScope(); @@ -43,9 +43,10 @@ public: void add_cancelled_node(uint16_t node); void merge(const CancelScope& other); - [[nodiscard]] bool fully_cancelled() const noexcept { return _ownership_lost; } - // Note: partially_cancelled() does not subsume fully_cancelled(); it must be checked independently - [[nodiscard]] bool partially_cancelled() const noexcept { return !_cancelled_nodes.empty(); } + [[nodiscard]] bool fully_cancelled() const noexcept { return _fully_cancelled; } + [[nodiscard]] bool is_cancelled() const noexcept { + return (_fully_cancelled || !_cancelled_nodes.empty()); + } [[nodiscard]] bool node_is_cancelled(uint16_t node) const noexcept { return (fully_cancelled() || _cancelled_nodes.contains(node)); } diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp index c830b4d8618..bf64fa2eb82 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp @@ -261,9 +261,10 @@ void GarbageCollectionOperation::update_last_gc_timestamp_in_db() { } void GarbageCollectionOperation::merge_received_bucket_info_into_db() { - if (_cancel_scope.fully_cancelled()) { - return; - } else if (_cancel_scope.partially_cancelled()) { + if (_cancel_scope.is_cancelled()) { + if (_cancel_scope.fully_cancelled()) { + return; + } _replica_info = prune_cancelled_nodes(_replica_info, _cancel_scope); } if (!_replica_info.empty()) { diff --git a/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp b/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp index 8f93facf6cd..498f3a5feab 100644 --- a/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp +++ b/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp @@ -57,9 +57,10 @@ PersistenceMessageTrackerImpl::prune_cancelled_nodes_if_present( void PersistenceMessageTrackerImpl::updateDB() { - if (_cancel_scope.fully_cancelled()) { - return; // Fully cancelled ops cannot mutate the DB at all - } else if (_cancel_scope.partially_cancelled()) { + if (_cancel_scope.is_cancelled()) { + if (_cancel_scope.fully_cancelled()) { + return; // Fully cancelled ops cannot mutate the DB at all + } prune_cancelled_nodes_if_present(_bucketInfo, _cancel_scope); prune_cancelled_nodes_if_present(_remapBucketInfo, _cancel_scope); } |