From f9efcfa2cdb7df2af7ab35609a6776f8f2d7f477 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Tue, 24 Nov 2020 12:54:51 +0000 Subject: Remove load type from StorageMessage --- .../src/tests/mbusprot/storageprotocoltest.cpp | 24 ++++++++++++++++------ .../messageapi/storage_message_address_test.cpp | 3 +-- .../mbusprot/protocolserialization5_0.cpp | 2 +- .../storageapi/mbusprot/protocolserialization7.cpp | 1 - .../vespa/storageapi/messageapi/storagemessage.cpp | 24 ++++++++++++++-------- .../vespa/storageapi/messageapi/storagemessage.h | 10 +++------ 6 files changed, 39 insertions(+), 25 deletions(-) (limited to 'storageapi') diff --git a/storageapi/src/tests/mbusprot/storageprotocoltest.cpp b/storageapi/src/tests/mbusprot/storageprotocoltest.cpp index 9fd2c96f27e..c2ebffb23e8 100644 --- a/storageapi/src/tests/mbusprot/storageprotocoltest.cpp +++ b/storageapi/src/tests/mbusprot/storageprotocoltest.cpp @@ -16,9 +16,7 @@ #include #include #include -#include -#include #include #include @@ -162,11 +160,9 @@ StorageProtocolTest::copyReply(const std::shared_ptr& m) TEST_P(StorageProtocolTest, put) { auto cmd = std::make_shared(_bucket, _testDoc, 14); cmd->setUpdateTimestamp(Timestamp(13)); - cmd->setLoadType(_loadTypes["foo"]); auto cmd2 = copyCommand(cmd); EXPECT_EQ(_bucket, cmd2->getBucket()); EXPECT_EQ(*_testDoc, *cmd2->getDocument()); - EXPECT_EQ(vespalib::string("foo"), cmd2->getLoadType().getName()); EXPECT_EQ(Timestamp(14), cmd2->getTimestamp()); EXPECT_EQ(Timestamp(13), cmd2->getUpdateTimestamp()); @@ -221,12 +217,10 @@ TEST_P(StorageProtocolTest, request_metadata_is_propagated) { auto cmd = std::make_shared(_bucket, _testDoc, 14); cmd->forceMsgId(12345); cmd->setPriority(50); - cmd->setLoadType(_loadTypes["foo"]); cmd->setSourceIndex(321); auto cmd2 = copyCommand(cmd); EXPECT_EQ(12345, cmd2->getMsgId()); EXPECT_EQ(50, cmd2->getPriority()); - EXPECT_EQ(_loadTypes["foo"].getId(), cmd2->getLoadType().getId()); EXPECT_EQ(321, cmd2->getSourceIndex()); } @@ -821,4 +815,22 @@ TEST_P(StorageProtocolTest, serialized_size_is_used_to_set_approx_size_of_storag } } +TEST_P(StorageProtocolTest, track_memory_footprint_for_some_messages) { + EXPECT_EQ(136u, sizeof(StorageReply)); + EXPECT_EQ(160u, sizeof(BucketReply)); + EXPECT_EQ(192u, sizeof(BucketInfoReply)); + EXPECT_EQ(336u, sizeof(PutReply)); + EXPECT_EQ(320u, sizeof(UpdateReply)); + EXPECT_EQ(312u, sizeof(RemoveReply)); + EXPECT_EQ(400u, sizeof(GetReply)); + EXPECT_EQ(80u, sizeof(StorageCommand)); + EXPECT_EQ(104u, sizeof(BucketCommand)); + EXPECT_EQ(104u, sizeof(BucketInfoCommand)); + EXPECT_EQ(112u, sizeof(TestAndSetCommand)); + EXPECT_EQ(144u, sizeof(PutCommand)); + EXPECT_EQ(144u, sizeof(UpdateCommand)); + EXPECT_EQ(224u, sizeof(RemoveCommand)); + EXPECT_EQ(288u, sizeof(GetCommand)); +} + } // storage::api diff --git a/storageapi/src/tests/messageapi/storage_message_address_test.cpp b/storageapi/src/tests/messageapi/storage_message_address_test.cpp index 9db282c98eb..55adcf46c0d 100644 --- a/storageapi/src/tests/messageapi/storage_message_address_test.cpp +++ b/storageapi/src/tests/messageapi/storage_message_address_test.cpp @@ -33,8 +33,7 @@ TEST(StorageMessageAddressTest, storage_hash_covers_all_expected_fields) { hash_of("foo", lib::NodeType::STORAGE, 1)); EXPECT_EQ(112u, sizeof(StorageMessageAddress)); - EXPECT_EQ(144u, sizeof(StorageMessage)); - EXPECT_EQ(80u, sizeof(documentapi::LoadType)); + EXPECT_EQ(64u, sizeof(StorageMessage)); EXPECT_EQ(16u, sizeof(mbus::Trace)); } diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp index 8a0204c8fc9..2c7b4a1e6f8 100644 --- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp +++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp @@ -102,7 +102,7 @@ ProtocolSerialization5_0::onDecodeCommand(BBuf& buf, api::StorageCommand& msg) c uint8_t priority = SH::getByte(buf); msg.setPriority(priority); msg.setSourceIndex(SH::getShort(buf)); - msg.setLoadType(_loadTypes[SH::getInt(buf)]); + (void)SH::getInt(buf); } diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.cpp b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.cpp index 5d66d86036c..b356ce59999 100644 --- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.cpp +++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.cpp @@ -253,7 +253,6 @@ public: dest.forceMsgId(_hdr.message_id()); dest.setPriority(static_cast(_hdr.priority())); dest.setSourceIndex(static_cast(_hdr.source_index())); - dest.setLoadType(_load_types[_hdr.loadtype_id()]); } ProtobufType& request() noexcept { return *_proto_obj; } diff --git a/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp b/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp index 700669739ce..16f35b8d939 100644 --- a/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp +++ b/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "storagemessage.h" - +#include #include #include #include @@ -270,7 +270,6 @@ StorageMessage::StorageMessage(const MessageType& type, Id id) : _type(type), _msgId(id), _address(), - _loadType(documentapi::LoadType::DEFAULT), _trace(), _approxByteSize(50), _priority(NORMAL) @@ -281,7 +280,6 @@ StorageMessage::StorageMessage(const StorageMessage& other, Id id) : _type(other._type), _msgId(id), _address(), - _loadType(other._loadType), _trace(other.getTrace().getLevel()), _approxByteSize(other._approxByteSize), _priority(other._priority) @@ -290,7 +288,13 @@ StorageMessage::StorageMessage(const StorageMessage& other, Id id) StorageMessage::~StorageMessage() = default; -void StorageMessage::setNewMsgId() +const documentapi::LoadType& +StorageMessage::getLoadType() const { + return documentapi::LoadType::DEFAULT; +} + +void +StorageMessage::setNewMsgId() { _msgId = generateMsgId(); } @@ -300,7 +304,8 @@ StorageMessage::getSummary() const { return toString(); } -const char* to_string(LockingRequirements req) noexcept { +const char* +to_string(LockingRequirements req) noexcept { switch (req) { case LockingRequirements::Exclusive: return "Exclusive"; case LockingRequirements::Shared: return "Shared"; @@ -308,12 +313,14 @@ const char* to_string(LockingRequirements req) noexcept { } } -std::ostream& operator<<(std::ostream& os, LockingRequirements req) { +std::ostream& +operator<<(std::ostream& os, LockingRequirements req) { os << to_string(req); return os; } -const char* to_string(InternalReadConsistency consistency) noexcept { +const char* +to_string(InternalReadConsistency consistency) noexcept { switch (consistency) { case InternalReadConsistency::Strong: return "Strong"; case InternalReadConsistency::Weak: return "Weak"; @@ -321,7 +328,8 @@ const char* to_string(InternalReadConsistency consistency) noexcept { } } -std::ostream& operator<<(std::ostream& os, InternalReadConsistency consistency) { +std::ostream& +operator<<(std::ostream& os, InternalReadConsistency consistency) { os << to_string(consistency); return os; } diff --git a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h index 58f167f5002..a2227246a52 100644 --- a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h +++ b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h @@ -12,7 +12,6 @@ #pragma once #include "messagehandler.h" -#include #include #include #include @@ -21,9 +20,8 @@ #include #include -namespace vespalib { - class asciistream; -} +namespace vespalib { class asciistream; } +namespace documentapi { class LoadType; } // The following macros are provided as a way to write storage messages simply. // They implement the parts of the code that can easily be automaticly // generated. @@ -361,7 +359,6 @@ protected: const MessageType& _type; Id _msgId; std::unique_ptr _address; - documentapi::LoadType _loadType; vespalib::Trace _trace; uint32_t _approxByteSize; Priority _priority; @@ -432,8 +429,7 @@ public: */ virtual bool callHandler(MessageHandler&, const StorageMessage::SP&) const = 0; - const documentapi::LoadType& getLoadType() const { return _loadType; } - void setLoadType(const documentapi::LoadType& type) { _loadType = type; } + const documentapi::LoadType& getLoadType() const; mbus::Trace && steal_trace() { return std::move(_trace); } mbus::Trace& getTrace() { return _trace; } -- cgit v1.2.3