diff options
author | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2020-09-08 13:42:12 +0000 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2020-09-14 13:22:14 +0000 |
commit | 54150406f3c490463bc5371c9480452da168bd5c (patch) | |
tree | 73721c84df79dd649c967a5fe9f0525431476af6 /storageapi | |
parent | ea22ec7cb6e35cf591d08ffe898388a7f08593cc (diff) |
Basic functionality for direct RPC for StorageAPI communication
This has several advantages:
* Completely bypasses all MessageBus indirections
* Explicit setup of RPC thread pool
* Direct dispatch from RPC thread to persistence queue pool
* Better control of encoding/decoding and buffer usage
Diffstat (limited to 'storageapi')
3 files changed, 16 insertions, 15 deletions
diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.h b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.h index f3499150278..d29167031a4 100644 --- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.h +++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.h @@ -5,8 +5,7 @@ #include "protocolserialization.h" #include <vespa/documentapi/loadtypes/loadtypeset.h> -namespace storage { -namespace mbusprot { +namespace storage::mbusprot { /** * Protocol serialization version that uses Protocol Buffers for all its binary @@ -143,4 +142,3 @@ private: }; } -} diff --git a/storageapi/src/vespa/storageapi/mbusprot/storagecommand.h b/storageapi/src/vespa/storageapi/mbusprot/storagecommand.h index 26c9ef00752..ef1d5082a04 100644 --- a/storageapi/src/vespa/storageapi/mbusprot/storagecommand.h +++ b/storageapi/src/vespa/storageapi/mbusprot/storagecommand.h @@ -12,7 +12,7 @@ class StorageCommand : public mbus::Message, public StorageMessage { public: typedef std::unique_ptr<StorageCommand> UP; - StorageCommand(api::StorageCommand::SP); + explicit StorageCommand(api::StorageCommand::SP); const mbus::string & getProtocol() const override { return StorageProtocol::NAME; } uint32_t getType() const override { return _cmd->getType().getId(); } @@ -21,6 +21,9 @@ public: api::StorageMessage::SP getInternalMessage() override { return _cmd; } api::StorageMessage::CSP getInternalMessage() const override { return _cmd; } + bool has_command() const noexcept { return (_cmd.get() != nullptr); } + api::StorageCommand::SP steal_command() { return std::move(_cmd); } + bool hasBucketSequence() const override { return false; } uint8_t priority() const override { diff --git a/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp b/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp index 93030f699cc..d1bd24f5087 100644 --- a/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp +++ b/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp @@ -105,7 +105,7 @@ const MessageType MessageType::SETBUCKETSTATE_REPLY("SetBucketStateReply", SETBU const MessageType& MessageType::MessageType::get(Id id) { - std::map<Id, MessageType*>::const_iterator it = _codes.find(id); + auto it = _codes.find(id); if (it == _codes.end()) { std::ostringstream ost; ost << "No message type with id " << id << "."; @@ -115,13 +115,13 @@ MessageType::MessageType::get(Id id) } MessageType::MessageType(vespalib::stringref name, Id id, const MessageType* replyOf) - : _name(name), _id(id), _reply(NULL), _replyOf(replyOf) + : _name(name), _id(id), _reply(nullptr), _replyOf(replyOf) { _codes[id] = this; - if (_replyOf != 0) { - assert(_replyOf->_reply == 0); + if (_replyOf) { + assert(_replyOf->_reply == nullptr); // Ugly cast to let initialization work - MessageType& type = const_cast<MessageType&>(*_replyOf); + auto& type = const_cast<MessageType&>(*_replyOf); type._reply = this; } } @@ -144,7 +144,7 @@ StorageMessageAddress::StorageMessageAddress(const mbus::Route& route) _retryEnabled(false), _protocol(DOCUMENT), _cluster(""), - _type(0), + _type(nullptr), _index(0xFFFF) { } @@ -179,7 +179,7 @@ StorageMessageAddress::~StorageMessageAddress() = default; uint16_t StorageMessageAddress::getIndex() const { - if (_type == 0) { + if (!_type) { throw vespalib::IllegalStateException("Cannot retrieve node index out of external address", VESPA_STRLOC); } return _index; @@ -188,7 +188,7 @@ StorageMessageAddress::getIndex() const const lib::NodeType& StorageMessageAddress::getNodeType() const { - if (_type == 0) { + if (!_type) { throw vespalib::IllegalStateException("Cannot retrieve node type out of external address", VESPA_STRLOC); } return *_type; @@ -197,7 +197,7 @@ StorageMessageAddress::getNodeType() const const vespalib::string& StorageMessageAddress::getCluster() const { - if (_type == 0) { + if (!_type) { throw vespalib::IllegalStateException("Cannot retrieve cluster out of external address", VESPA_STRLOC); } return _cluster; @@ -209,7 +209,7 @@ StorageMessageAddress::operator==(const StorageMessageAddress& other) const if (_protocol != other._protocol) return false; if (_retryEnabled != other._retryEnabled) return false; if (_type != other._type) return false; - if (_type != 0) { + if (_type) { if (_cluster != other._cluster) return false; if (_index != other._index) return false; if (_type != other._type) return false; @@ -237,7 +237,7 @@ StorageMessageAddress::print(vespalib::asciistream & out) const if (_retryEnabled) { out << ", retry enabled"; } - if (_type == 0) { + if (!_type) { out << ", " << _route.toString() << ")"; } else { out << ", cluster " << _cluster << ", nodetype " << *_type |