aboutsummaryrefslogtreecommitdiffstats
path: root/storageapi
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-11-24 12:54:51 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-11-24 13:05:22 +0000
commitf9efcfa2cdb7df2af7ab35609a6776f8f2d7f477 (patch)
treec64eebcd865077a433868e758e6a3c57c841b0e1 /storageapi
parent23940966c79d9977e3d7ba4939037f90058a5b50 (diff)
Remove load type from StorageMessage
Diffstat (limited to 'storageapi')
-rw-r--r--storageapi/src/tests/mbusprot/storageprotocoltest.cpp24
-rw-r--r--storageapi/src/tests/messageapi/storage_message_address_test.cpp3
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp2
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.cpp1
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp24
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/storagemessage.h10
6 files changed, 39 insertions, 25 deletions
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 <vespa/document/test/make_document_bucket.h>
#include <vespa/document/test/make_bucket_space.h>
#include <vespa/vespalib/util/growablebytebuffer.h>
-#include <vespa/vespalib/objects/nbostream.h>
-#include <iomanip>
#include <sstream>
#include <vespa/vespalib/gtest/gtest.h>
@@ -162,11 +160,9 @@ StorageProtocolTest::copyReply(const std::shared_ptr<Reply>& m)
TEST_P(StorageProtocolTest, put) {
auto cmd = std::make_shared<PutCommand>(_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<PutCommand>(_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<uint8_t>(_hdr.priority()));
dest.setSourceIndex(static_cast<uint16_t>(_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 <vespa/documentapi/loadtypes/loadtype.h>
#include <vespa/messagebus/routing/verbatimdirective.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/stllike/asciistream.h>
@@ -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 <vespa/documentapi/loadtypes/loadtype.h>
#include <vespa/messagebus/routing/route.h>
#include <vespa/messagebus/trace.h>
#include <vespa/vdslib/state/nodetype.h>
@@ -21,9 +20,8 @@
#include <map>
#include <iosfwd>
-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<StorageMessageAddress> _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; }