diff options
author | Tor Brede Vekterli <vekterli@yahooinc.com> | 2023-10-12 11:57:06 +0000 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@yahooinc.com> | 2023-10-12 11:57:06 +0000 |
commit | 957aed121d057ea0e3e417bd55deec3050a81e4e (patch) | |
tree | 011671a7c594e20b9d6954648a15a68879deabf5 /storage | |
parent | 39d0a12ae3a1c371660b7a92b1098af9aba037d9 (diff) |
Replace bools with type safe enums
Diffstat (limited to 'storage')
4 files changed, 14 insertions, 11 deletions
diff --git a/storage/src/vespa/storage/common/storagelink.cpp b/storage/src/vespa/storage/common/storagelink.cpp index 020c2f10467..8dedde99dc8 100644 --- a/storage/src/vespa/storage/common/storagelink.cpp +++ b/storage/src/vespa/storage/common/storagelink.cpp @@ -15,8 +15,8 @@ using namespace storage::api; namespace storage { StorageLink::StorageLink(const std::string& name, - bool allow_msg_down_during_flushing, - bool allow_msg_up_during_closed) + AllowMsgDownOnFlush allow_msg_down_during_flushing, + AllowMsgUpOnClosed allow_msg_up_during_closed) : _name(name), _up(nullptr), _down(), @@ -27,7 +27,7 @@ StorageLink::StorageLink(const std::string& name, } StorageLink::StorageLink(const std::string& name) - : StorageLink(name, false, false) + : StorageLink(name, AllowMsgDownOnFlush::Disallowed, AllowMsgUpOnClosed::Disallowed) { } @@ -147,7 +147,7 @@ void StorageLink::sendDown(const StorageMessage::SP& msg) case FLUSHINGDOWN: break; case FLUSHINGUP: - if (_allow_msg_down_during_flushing) { + if (_allow_msg_down_during_flushing == AllowMsgDownOnFlush::Allowed) { break; } [[fallthrough]]; @@ -195,7 +195,7 @@ void StorageLink::sendUp(const std::shared_ptr<StorageMessage> & msg) case FLUSHINGUP: break; case CLOSED: - if (_allow_msg_up_during_closed) { + if (_allow_msg_up_during_closed == AllowMsgUpOnClosed::Allowed) { break; } [[fallthrough]]; diff --git a/storage/src/vespa/storage/common/storagelink.h b/storage/src/vespa/storage/common/storagelink.h index 0330728d69f..877169ecc2d 100644 --- a/storage/src/vespa/storage/common/storagelink.h +++ b/storage/src/vespa/storage/common/storagelink.h @@ -41,18 +41,21 @@ public: enum State { CREATED, OPENED, CLOSING, FLUSHINGDOWN, FLUSHINGUP, CLOSED }; + enum class AllowMsgDownOnFlush { Allowed, Disallowed }; + enum class AllowMsgUpOnClosed { Allowed, Disallowed }; + private: const std::string _name; StorageLink* _up; std::unique_ptr<StorageLink> _down; std::atomic<State> _state; - const bool _allow_msg_down_during_flushing; - const bool _allow_msg_up_during_closed; + const AllowMsgDownOnFlush _allow_msg_down_during_flushing; + const AllowMsgUpOnClosed _allow_msg_up_during_closed; public: StorageLink(const std::string& name, - bool allow_msg_down_during_flushing, - bool allow_msg_up_during_closed); + AllowMsgDownOnFlush allow_msg_down_during_flushing, + AllowMsgUpOnClosed allow_msg_up_during_closed); explicit StorageLink(const std::string& name); StorageLink(const StorageLink &) = delete; diff --git a/storage/src/vespa/storage/storageserver/bouncer.cpp b/storage/src/vespa/storage/storageserver/bouncer.cpp index 66dd35a9d81..405a19c5a7e 100644 --- a/storage/src/vespa/storage/storageserver/bouncer.cpp +++ b/storage/src/vespa/storage/storageserver/bouncer.cpp @@ -22,7 +22,7 @@ LOG_SETUP(".bouncer"); namespace storage { Bouncer::Bouncer(StorageComponentRegister& compReg, const config::ConfigUri & configUri) - : StorageLink("Bouncer", false, true), // Explicitly allow msg up when closed (bouncing to flushing comm. mgr) + : StorageLink("Bouncer", AllowMsgDownOnFlush::Disallowed, AllowMsgUpOnClosed::Allowed), _config(new vespa::config::content::core::StorBouncerConfig()), _component(compReg, "bouncer"), _lock(), diff --git a/storage/src/vespa/storage/storageserver/communicationmanager.cpp b/storage/src/vespa/storage/storageserver/communicationmanager.cpp index a3a2512d2ae..cf25b944226 100644 --- a/storage/src/vespa/storage/storageserver/communicationmanager.cpp +++ b/storage/src/vespa/storage/storageserver/communicationmanager.cpp @@ -217,7 +217,7 @@ convert_to_rpc_compression_config(const vespa::config::content::core::StorCommun } CommunicationManager::CommunicationManager(StorageComponentRegister& compReg, const config::ConfigUri & configUri) - : StorageLink("Communication manager", true, false), // Explicitly allow msg down during flushing (will be bounced) + : StorageLink("Communication manager", AllowMsgDownOnFlush::Allowed, AllowMsgUpOnClosed::Disallowed), _component(compReg, "communicationmanager"), _metrics(), _shared_rpc_resources(), // Created upon initial configuration |