summaryrefslogtreecommitdiffstats
path: root/storageapi/src
diff options
context:
space:
mode:
Diffstat (limited to 'storageapi/src')
-rw-r--r--storageapi/src/tests/mbusprot/storageprotocoltest.cpp39
-rw-r--r--storageapi/src/tests/messageapi/storage_message_address_test.cpp8
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp11
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.h10
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.cpp5
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.h9
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_2.h5
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/protocolserialization6_0.cpp9
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/protocolserialization6_0.h8
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.cpp15
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.h6
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/storagemessage.h2
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/storageprotocol.cpp13
-rw-r--r--storageapi/src/vespa/storageapi/mbusprot/storageprotocol.h5
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/bucketinforeply.cpp7
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h5
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/bucketreply.cpp8
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/bucketreply.h7
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/returncode.cpp18
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/returncode.h19
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp98
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/storagemessage.h113
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/storagereply.cpp10
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/storagereply.h4
24 files changed, 179 insertions, 255 deletions
diff --git a/storageapi/src/tests/mbusprot/storageprotocoltest.cpp b/storageapi/src/tests/mbusprot/storageprotocoltest.cpp
index e413a62ae39..5637110f341 100644
--- a/storageapi/src/tests/mbusprot/storageprotocoltest.cpp
+++ b/storageapi/src/tests/mbusprot/storageprotocoltest.cpp
@@ -56,7 +56,6 @@ struct StorageProtocolTest : TestWithParam<vespalib::Version> {
document::Bucket _bucket;
document::BucketId _dummy_remap_bucket{17, 12345};
BucketInfo _dummy_bucket_info{1,2,3,4,5, true, false, 48};
- documentapi::LoadTypeSet _loadTypes;
mbusprot::StorageProtocol _protocol;
static auto constexpr CONDITION_STRING = "There's just one condition";
@@ -66,9 +65,8 @@ struct StorageProtocolTest : TestWithParam<vespalib::Version> {
_testDocId(_testDoc->getId()),
_bucket_id(16, 0x51),
_bucket(makeDocumentBucket(_bucket_id)),
- _protocol(_docMan.getTypeRepoSP(), _loadTypes)
+ _protocol(_docMan.getTypeRepoSP())
{
- _loadTypes.addLoadType(34, "foo", documentapi::Priority::PRI_NORMAL_2);
}
~StorageProtocolTest();
@@ -115,7 +113,8 @@ namespace {
}
TEST_F(StorageProtocolTest, testAddress50) {
- StorageMessageAddress address("foo", lib::NodeType::STORAGE, 3);
+ vespalib::string cluster("foo");
+ StorageMessageAddress address(&cluster, lib::NodeType::STORAGE, 3);
EXPECT_EQ(vespalib::string("storage/cluster.foo/storage/3/default"),
address.to_mbus_route().toString());
}
@@ -816,25 +815,25 @@ TEST_P(StorageProtocolTest, serialized_size_is_used_to_set_approx_size_of_storag
}
TEST_P(StorageProtocolTest, track_memory_footprint_for_some_messages) {
- EXPECT_EQ(64u, sizeof(StorageMessage));
- EXPECT_EQ(80u, sizeof(StorageReply));
- EXPECT_EQ(104u, sizeof(BucketReply));
+ EXPECT_EQ(72u, sizeof(StorageMessage));
+ EXPECT_EQ(88u, sizeof(StorageReply));
+ EXPECT_EQ(112u, sizeof(BucketReply));
EXPECT_EQ(8u, sizeof(document::BucketId));
EXPECT_EQ(16u, sizeof(document::Bucket));
EXPECT_EQ(32u, sizeof(BucketInfo));
- EXPECT_EQ(136u, sizeof(BucketInfoReply));
- EXPECT_EQ(280u, sizeof(PutReply));
- EXPECT_EQ(264u, sizeof(UpdateReply));
- EXPECT_EQ(256u, sizeof(RemoveReply));
- EXPECT_EQ(344u, sizeof(GetReply));
- EXPECT_EQ(80u, sizeof(StorageCommand));
- EXPECT_EQ(104u, sizeof(BucketCommand));
- EXPECT_EQ(104u, sizeof(BucketInfoCommand));
- EXPECT_EQ(104u + sizeof(std::string), sizeof(TestAndSetCommand));
- EXPECT_EQ(136u + sizeof(std::string), sizeof(PutCommand));
- EXPECT_EQ(136u + sizeof(std::string), sizeof(UpdateCommand));
- EXPECT_EQ(216u + sizeof(std::string), sizeof(RemoveCommand));
- EXPECT_EQ(288u, sizeof(GetCommand));
+ EXPECT_EQ(144u, sizeof(BucketInfoReply));
+ EXPECT_EQ(288u, sizeof(PutReply));
+ EXPECT_EQ(272u, sizeof(UpdateReply));
+ EXPECT_EQ(264u, sizeof(RemoveReply));
+ EXPECT_EQ(352u, sizeof(GetReply));
+ EXPECT_EQ(88u, sizeof(StorageCommand));
+ EXPECT_EQ(112u, sizeof(BucketCommand));
+ EXPECT_EQ(112u, sizeof(BucketInfoCommand));
+ EXPECT_EQ(112u + sizeof(std::string), sizeof(TestAndSetCommand));
+ EXPECT_EQ(144u + sizeof(std::string), sizeof(PutCommand));
+ EXPECT_EQ(144u + sizeof(std::string), sizeof(UpdateCommand));
+ EXPECT_EQ(224u + sizeof(std::string), sizeof(RemoveCommand));
+ EXPECT_EQ(296u, 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 f7f254e9119..edcf795368a 100644
--- a/storageapi/src/tests/messageapi/storage_message_address_test.cpp
+++ b/storageapi/src/tests/messageapi/storage_message_address_test.cpp
@@ -9,8 +9,8 @@ namespace storage::api {
namespace {
-size_t hash_of(vespalib::stringref cluster, const lib::NodeType& type, uint16_t index) {
- return StorageMessageAddress(cluster, type, index).internal_storage_hash();
+size_t hash_of(const vespalib::string & cluster, const lib::NodeType& type, uint16_t index) {
+ return StorageMessageAddress(&cluster, type, index).internal_storage_hash();
}
}
@@ -32,8 +32,8 @@ TEST(StorageMessageAddressTest, storage_hash_covers_all_expected_fields) {
EXPECT_NE(hash_of("foo", lib::NodeType::STORAGE, 0),
hash_of("foo", lib::NodeType::STORAGE, 1));
- EXPECT_EQ(88u, sizeof(StorageMessageAddress));
- EXPECT_EQ(64u, sizeof(StorageMessage));
+ EXPECT_EQ(16u, sizeof(StorageMessageAddress));
+ EXPECT_EQ(72u, 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 2c7b4a1e6f8..45d9d2bd711 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp
+++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp
@@ -92,7 +92,7 @@ ProtocolSerialization5_0::onEncodeCommand(GBBuf& buf, const api::StorageCommand&
buf.putLong(msg.getMsgId());
buf.putByte(msg.getPriority());
buf.putShort(msg.getSourceIndex());
- buf.putInt(msg.getLoadType().getId());
+ buf.putInt(0); // LoadType 'default'
}
void
@@ -102,15 +102,12 @@ ProtocolSerialization5_0::onDecodeCommand(BBuf& buf, api::StorageCommand& msg) c
uint8_t priority = SH::getByte(buf);
msg.setPriority(priority);
msg.setSourceIndex(SH::getShort(buf));
- (void)SH::getInt(buf);
+ (void)SH::getInt(buf); // LoadType
}
-ProtocolSerialization5_0::ProtocolSerialization5_0(
- const std::shared_ptr<const document::DocumentTypeRepo>& repo,
- const documentapi::LoadTypeSet& loadTypes)
- : ProtocolSerialization4_2(repo),
- _loadTypes(loadTypes)
+ProtocolSerialization5_0::ProtocolSerialization5_0(const std::shared_ptr<const document::DocumentTypeRepo>& repo)
+ : ProtocolSerialization4_2(repo)
{
}
diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.h b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.h
index 67f02aa2d2a..8d38db89a08 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.h
+++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.h
@@ -2,17 +2,12 @@
#pragma once
#include "protocolserialization4_2.h"
-#include <vespa/documentapi/loadtypes/loadtypeset.h>
namespace storage::mbusprot {
class ProtocolSerialization5_0 : public ProtocolSerialization4_2 {
-private:
- const documentapi::LoadTypeSet& _loadTypes;
-
public:
- ProtocolSerialization5_0(const std::shared_ptr<const document::DocumentTypeRepo>&,
- const documentapi::LoadTypeSet& loadTypes);
+ ProtocolSerialization5_0(const std::shared_ptr<const document::DocumentTypeRepo>&);
document::Bucket getBucket(document::ByteBuffer& buf) const override;
void putBucket(const document::Bucket& bucket, vespalib::GrowableByteBuffer& buf) const override;
@@ -73,9 +68,6 @@ public:
SRep::UP onDecodeCreateVisitorReply(const SCmd& cmd, BBuf& buf) const override;
void onDecodeCommand(BBuf& buf, api::StorageCommand& msg) const override;
void onDecodeReply(BBuf&, api::StorageReply&) const override;
-
-protected:
- const documentapi::LoadTypeSet& loadTypes() const noexcept { return _loadTypes; };
};
}
diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.cpp b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.cpp
index 0b1f66127ba..b289c1661a0 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.cpp
+++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.cpp
@@ -44,9 +44,8 @@ ProtocolSerialization5_1::putBucketInfo(
}
ProtocolSerialization5_1::ProtocolSerialization5_1(
- const std::shared_ptr<const document::DocumentTypeRepo>& repo,
- const documentapi::LoadTypeSet& loadTypes)
- : ProtocolSerialization5_0(repo, loadTypes)
+ const std::shared_ptr<const document::DocumentTypeRepo>& repo)
+ : ProtocolSerialization5_0(repo)
{
}
diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.h b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.h
index 5df0d757ce2..b46257a2182 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.h
+++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.h
@@ -3,8 +3,7 @@
#include "protocolserialization5_0.h"
-namespace storage {
-namespace mbusprot {
+namespace storage::mbusprot {
class ProtocolSerialization5_1 : public ProtocolSerialization5_0
{
@@ -13,8 +12,7 @@ class ProtocolSerialization5_1 : public ProtocolSerialization5_0
BUCKET_ACTIVE = 0x2,
};
public:
- ProtocolSerialization5_1(const std::shared_ptr<const document::DocumentTypeRepo>&,
- const documentapi::LoadTypeSet& loadTypes);
+ ProtocolSerialization5_1(const std::shared_ptr<const document::DocumentTypeRepo>&);
api::BucketInfo getBucketInfo(document::ByteBuffer& buf) const override;
void putBucketInfo(const api::BucketInfo& info, vespalib::GrowableByteBuffer& buf) const override;
@@ -33,5 +31,4 @@ protected:
SCmd::UP onDecodeCreateBucketCommand(BBuf&) const override;
};
-} // mbusprot
-} // storage
+}
diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_2.h b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_2.h
index f6f9443248c..50200edcbcf 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_2.h
+++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_2.h
@@ -12,9 +12,8 @@ namespace storage::mbusprot {
class ProtocolSerialization5_2 : public ProtocolSerialization5_1
{
public:
- ProtocolSerialization5_2(const std::shared_ptr<const document::DocumentTypeRepo>& repo,
- const documentapi::LoadTypeSet & loadTypes)
- : ProtocolSerialization5_1(repo, loadTypes)
+ ProtocolSerialization5_2(const std::shared_ptr<const document::DocumentTypeRepo>& repo)
+ : ProtocolSerialization5_1(repo)
{}
protected:
diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization6_0.cpp b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization6_0.cpp
index 930879082ed..cd66928877c 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization6_0.cpp
+++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization6_0.cpp
@@ -3,12 +3,10 @@
#include "protocolserialization6_0.h"
#include "serializationhelper.h"
-namespace storage {
-namespace mbusprot {
+namespace storage::mbusprot {
-ProtocolSerialization6_0::ProtocolSerialization6_0(const std::shared_ptr<const document::DocumentTypeRepo> &repo,
- const documentapi::LoadTypeSet &loadTypes)
- : ProtocolSerialization5_2(repo, loadTypes)
+ProtocolSerialization6_0::ProtocolSerialization6_0(const std::shared_ptr<const document::DocumentTypeRepo> &repo)
+ : ProtocolSerialization5_2(repo)
{
}
@@ -40,4 +38,3 @@ ProtocolSerialization6_0::putBucketSpace(document::BucketSpace bucketSpace, vesp
}
}
-}
diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization6_0.h b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization6_0.h
index 5c4e6b2ec63..efce45ce844 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization6_0.h
+++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization6_0.h
@@ -3,10 +3,8 @@
#pragma once
#include "protocolserialization5_2.h"
-#include <vespa/documentapi/loadtypes/loadtypeset.h>
-namespace storage {
-namespace mbusprot {
+namespace storage::mbusprot {
/**
* Protocol serialization version adding decoding and encoding
@@ -15,8 +13,7 @@ namespace mbusprot {
class ProtocolSerialization6_0 : public ProtocolSerialization5_2
{
public:
- ProtocolSerialization6_0(const std::shared_ptr<const document::DocumentTypeRepo> &repo,
- const documentapi::LoadTypeSet &loadTypes);
+ ProtocolSerialization6_0(const std::shared_ptr<const document::DocumentTypeRepo> &repo);
document::Bucket getBucket(document::ByteBuffer &buf) const override;
void putBucket(const document::Bucket &bucket, vespalib::GrowableByteBuffer &buf) const override;
@@ -25,4 +22,3 @@ public:
};
}
-}
diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.cpp b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.cpp
index b356ce59999..98f76b4afb7 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.cpp
+++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.cpp
@@ -14,11 +14,9 @@
namespace storage::mbusprot {
-ProtocolSerialization7::ProtocolSerialization7(std::shared_ptr<const document::DocumentTypeRepo> repo,
- const documentapi::LoadTypeSet& load_types)
+ProtocolSerialization7::ProtocolSerialization7(std::shared_ptr<const document::DocumentTypeRepo> repo)
: ProtocolSerialization(),
- _repo(std::move(repo)),
- _load_types(load_types)
+ _repo(std::move(repo))
{
}
@@ -113,7 +111,6 @@ void write_request_header(vespalib::GrowableByteBuffer& buf, const api::StorageC
hdr.set_message_id(cmd.getMsgId());
hdr.set_priority(cmd.getPriority());
hdr.set_source_index(cmd.getSourceIndex());
- hdr.set_loadtype_id(cmd.getLoadType().getId());
uint8_t dest[128]; // Only primitive fields, should be plenty large enough.
auto encoded_size = static_cast<uint32_t>(hdr.ByteSizeLong());
@@ -232,12 +229,10 @@ class RequestDecoder {
protobuf::RequestHeader _hdr;
::google::protobuf::Arena _arena;
ProtobufType* _proto_obj;
- const documentapi::LoadTypeSet& _load_types;
public:
- RequestDecoder(document::ByteBuffer& in_buf, const documentapi::LoadTypeSet& load_types)
+ RequestDecoder(document::ByteBuffer& in_buf)
: _arena(),
- _proto_obj(::google::protobuf::Arena::Create<ProtobufType>(&_arena)),
- _load_types(load_types)
+ _proto_obj(::google::protobuf::Arena::Create<ProtobufType>(&_arena))
{
decode_request_header(in_buf, _hdr);
assert(in_buf.getRemaining() <= INT_MAX);
@@ -308,7 +303,7 @@ void encode_response(vespalib::GrowableByteBuffer& out_buf, const api::StorageRe
template <typename ProtobufType, typename Func>
std::unique_ptr<api::StorageCommand>
ProtocolSerialization7::decode_request(document::ByteBuffer& in_buf, Func&& f) const {
- RequestDecoder<ProtobufType> dec(in_buf, _load_types);
+ RequestDecoder<ProtobufType> dec(in_buf);
const auto& req = dec.request();
auto cmd = f(req);
dec.transfer_meta_information_to(*cmd);
diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.h b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.h
index e1d08691bc1..8f9a5d8df8d 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.h
+++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization7.h
@@ -3,7 +3,6 @@
#pragma once
#include "protocolserialization.h"
-#include <vespa/documentapi/loadtypes/loadtypeset.h>
namespace storage::mbusprot {
@@ -13,13 +12,10 @@ namespace storage::mbusprot {
*/
class ProtocolSerialization7 final : public ProtocolSerialization {
const std::shared_ptr<const document::DocumentTypeRepo> _repo;
- const documentapi::LoadTypeSet& _load_types;
public:
- ProtocolSerialization7(std::shared_ptr<const document::DocumentTypeRepo> repo,
- const documentapi::LoadTypeSet& load_types);
+ explicit ProtocolSerialization7(std::shared_ptr<const document::DocumentTypeRepo> repo);
const document::DocumentTypeRepo& type_repo() const noexcept { return *_repo; }
- const documentapi::LoadTypeSet& load_type_set() const noexcept { return _load_types; }
// Put
void onEncode(GBBuf&, const api::PutCommand&) const override;
diff --git a/storageapi/src/vespa/storageapi/mbusprot/storagemessage.h b/storageapi/src/vespa/storageapi/mbusprot/storagemessage.h
index c63271a8956..edeab31ec8a 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/storagemessage.h
+++ b/storageapi/src/vespa/storageapi/mbusprot/storagemessage.h
@@ -12,7 +12,7 @@ public:
virtual ~StorageMessage() {}
virtual api::StorageMessage::SP getInternalMessage() = 0;
- virtual storage::api::StorageMessage::CSP getInternalMessage() const = 0;
+ virtual api::StorageMessage::CSP getInternalMessage() const = 0;
};
diff --git a/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.cpp b/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.cpp
index b5107e68454..f6e68b3dd04 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.cpp
+++ b/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.cpp
@@ -15,13 +15,12 @@ namespace storage::mbusprot {
mbus::string StorageProtocol::NAME = "StorageProtocol";
-StorageProtocol::StorageProtocol(const std::shared_ptr<const document::DocumentTypeRepo> repo,
- const documentapi::LoadTypeSet& loadTypes)
- : _serializer5_0(repo, loadTypes),
- _serializer5_1(repo, loadTypes),
- _serializer5_2(repo, loadTypes),
- _serializer6_0(repo, loadTypes),
- _serializer7_0(repo, loadTypes)
+StorageProtocol::StorageProtocol(const std::shared_ptr<const document::DocumentTypeRepo> repo)
+ : _serializer5_0(repo),
+ _serializer5_1(repo),
+ _serializer5_2(repo),
+ _serializer6_0(repo),
+ _serializer7_0(repo)
{
}
diff --git a/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.h b/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.h
index 40f2d26d833..ad9ee908424 100644
--- a/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.h
+++ b/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.h
@@ -15,8 +15,7 @@ public:
static mbus::string NAME;
- StorageProtocol(const std::shared_ptr<const document::DocumentTypeRepo>,
- const documentapi::LoadTypeSet& loadTypes);
+ explicit StorageProtocol(const std::shared_ptr<const document::DocumentTypeRepo>);
~StorageProtocol() override;
const mbus::string& getName() const override { return NAME; }
@@ -29,7 +28,7 @@ private:
ProtocolSerialization5_1 _serializer5_1;
ProtocolSerialization5_2 _serializer5_2;
ProtocolSerialization6_0 _serializer6_0;
- ProtocolSerialization7 _serializer7_0;
+ ProtocolSerialization7 _serializer7_0;
};
}
diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.cpp b/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.cpp
index 67e4d835e0c..3f64a133b5f 100644
--- a/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.cpp
+++ b/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.cpp
@@ -5,13 +5,6 @@
namespace storage::api {
-BucketInfoReply::BucketInfoReply(const BucketInfoCommand& cmd,
- const ReturnCode& code)
- : BucketReply(cmd, code),
- _result()
-{
-}
-
void
BucketInfoReply::print(std::ostream& out, bool verbose,
const std::string& indent) const
diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h b/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h
index 5b784267da2..a9f206787cb 100644
--- a/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h
+++ b/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h
@@ -22,7 +22,10 @@ class BucketInfoReply : public BucketReply {
BucketInfo _result;
protected:
- BucketInfoReply(const BucketInfoCommand& cmd, const ReturnCode& code = ReturnCode(ReturnCode::OK));
+ BucketInfoReply(const BucketInfoCommand& cmd)
+ : BucketReply(cmd),
+ _result()
+ {}
public:
DECLARE_POINTER_TYPEDEFS(BucketInfoReply);
diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketreply.cpp b/storageapi/src/vespa/storageapi/messageapi/bucketreply.cpp
index e5fb7764aeb..895b6dcef24 100644
--- a/storageapi/src/vespa/storageapi/messageapi/bucketreply.cpp
+++ b/storageapi/src/vespa/storageapi/messageapi/bucketreply.cpp
@@ -9,14 +9,6 @@ using document::BucketId;
namespace storage::api {
-BucketReply::BucketReply(const BucketCommand& cmd,
- const ReturnCode& code)
- : StorageReply(cmd, code),
- _bucket(cmd.getBucket()),
- _originalBucket(cmd.getOriginalBucketId())
-{
-}
-
void
BucketReply::remapBucketId(const BucketId& bucket) {
if (_originalBucket.getRawId() == 0) {
diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketreply.h b/storageapi/src/vespa/storageapi/messageapi/bucketreply.h
index 5b4e6963fd9..9fe04dfe47d 100644
--- a/storageapi/src/vespa/storageapi/messageapi/bucketreply.h
+++ b/storageapi/src/vespa/storageapi/messageapi/bucketreply.h
@@ -9,6 +9,7 @@
#pragma once
#include "storagereply.h"
+#include "bucketcommand.h"
namespace storage::api {
@@ -19,7 +20,11 @@ class BucketReply : public StorageReply {
document::BucketId _originalBucket;
protected:
- BucketReply(const BucketCommand& cmd, const ReturnCode& code = ReturnCode(ReturnCode::OK));
+ BucketReply(const BucketCommand& cmd)
+ : StorageReply(cmd),
+ _bucket(cmd.getBucket()),
+ _originalBucket(cmd.getOriginalBucketId())
+ { }
public:
DECLARE_POINTER_TYPEDEFS(BucketReply);
diff --git a/storageapi/src/vespa/storageapi/messageapi/returncode.cpp b/storageapi/src/vespa/storageapi/messageapi/returncode.cpp
index dbe2f602703..e2184e19a33 100644
--- a/storageapi/src/vespa/storageapi/messageapi/returncode.cpp
+++ b/storageapi/src/vespa/storageapi/messageapi/returncode.cpp
@@ -5,18 +5,7 @@
namespace storage::api {
-ReturnCode::ReturnCode()
- : _result(OK),
- _message()
-{}
-
ReturnCode & ReturnCode::operator = (ReturnCode &&) noexcept = default;
-ReturnCode::~ReturnCode() = default;
-
-ReturnCode::ReturnCode(Result result)
- : _result(result),
- _message()
-{}
ReturnCode::ReturnCode(Result result, vespalib::stringref msg)
: _result(result),
@@ -168,13 +157,6 @@ ReturnCode::isBucketDisappearance() const
}
}
-vespalib::stringref
-ReturnCode::getMessage() const {
- return _message
- ? _message->operator vespalib::stringref()
- : vespalib::stringref();
-}
-
bool
ReturnCode::operator==(const ReturnCode& code) const {
return (_result == code._result) && (getMessage() == code.getMessage());
diff --git a/storageapi/src/vespa/storageapi/messageapi/returncode.h b/storageapi/src/vespa/storageapi/messageapi/returncode.h
index bef59a334d9..478aa455c85 100644
--- a/storageapi/src/vespa/storageapi/messageapi/returncode.h
+++ b/storageapi/src/vespa/storageapi/messageapi/returncode.h
@@ -61,16 +61,25 @@ private:
Result _result;
std::unique_ptr<vespalib::string> _message;
public:
- ReturnCode();
- explicit ReturnCode(Result result);
- explicit ReturnCode(Result result, vespalib::stringref msg);
+ ReturnCode()
+ : _result(OK),
+ _message()
+ { }
+ explicit ReturnCode(Result result)
+ : _result(result),
+ _message()
+ {}
+ ReturnCode(Result result, vespalib::stringref msg);
ReturnCode(const ReturnCode &);
ReturnCode & operator = (const ReturnCode &);
ReturnCode(ReturnCode &&) noexcept = default;
ReturnCode & operator = (ReturnCode &&) noexcept;
- ~ReturnCode();
- vespalib::stringref getMessage() const;
+ vespalib::stringref getMessage() const {
+ return _message
+ ? _message->operator vespalib::stringref()
+ : vespalib::stringref();
+ }
Result getResult() const { return _result; }
diff --git a/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp b/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp
index 9c5df379d22..892e7199cf3 100644
--- a/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp
+++ b/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp
@@ -1,7 +1,6 @@
// 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>
@@ -143,39 +142,47 @@ std::ostream & operator << (std::ostream & os, const StorageMessageAddress & add
return os << addr.toString();
}
-static vespalib::string
-createAddress(vespalib::stringref cluster, const lib::NodeType& type, uint16_t index)
-{
+namespace {
+
+vespalib::string
+createAddress(vespalib::stringref cluster, const lib::NodeType &type, uint16_t index) {
vespalib::asciistream os;
os << STORAGEADDRESS_PREFIX << cluster << '/' << type.toString() << '/' << index << "/default";
return os.str();
}
-size_t
-calculate_node_hash(const lib::NodeType& type, uint16_t index)
-{
- uint16_t buf[] = { type, index };
- return vespalib::hashValue(&buf, sizeof(buf));
+uint32_t
+calculate_node_hash(const lib::NodeType &type, uint16_t index) {
+ uint16_t buf[] = {type, index};
+ size_t hash = vespalib::hashValue(&buf, sizeof(buf));
+ return uint32_t(hash & 0xffffffffl) ^ uint32_t(hash >> 32);
+}
+
+vespalib::string Empty;
+
}
// TODO we ideally want this removed. Currently just in place to support usage as map key when emplacement not available
-StorageMessageAddress::StorageMessageAddress()
- : _cluster(),
+StorageMessageAddress::StorageMessageAddress() noexcept
+ : _cluster(&Empty),
_precomputed_storage_hash(0),
- _type(nullptr),
+ _type(lib::NodeType::Type::UNKNOWN),
_protocol(Protocol::STORAGE),
_index(0)
{}
-StorageMessageAddress::StorageMessageAddress(vespalib::stringref cluster, const lib::NodeType& type,
- uint16_t index, Protocol protocol)
+StorageMessageAddress::StorageMessageAddress(const vespalib::string * cluster, const lib::NodeType& type, uint16_t index) noexcept
+ : StorageMessageAddress(cluster, type, index, Protocol::STORAGE)
+{ }
+
+StorageMessageAddress::StorageMessageAddress(const vespalib::string * cluster, const lib::NodeType& type,
+ uint16_t index, Protocol protocol) noexcept
: _cluster(cluster),
_precomputed_storage_hash(calculate_node_hash(type, index)),
- _type(&type),
+ _type(type.getType()),
_protocol(protocol),
_index(index)
-{
-}
+{ }
StorageMessageAddress::~StorageMessageAddress() = default;
@@ -183,50 +190,20 @@ mbus::Route
StorageMessageAddress::to_mbus_route() const
{
mbus::Route result;
- auto address_as_str = createAddress(_cluster, *_type, _index);
+ auto address_as_str = createAddress(getCluster(), lib::NodeType::get(_type), _index);
std::vector<mbus::IHopDirective::SP> directives;
directives.emplace_back(std::make_shared<mbus::VerbatimDirective>(std::move(address_as_str)));
result.addHop(mbus::Hop(std::move(directives), false));
return result;
}
-uint16_t
-StorageMessageAddress::getIndex() const
-{
- if (!_type) {
- throw vespalib::IllegalStateException("Cannot retrieve node index out of external address", VESPA_STRLOC);
- }
- return _index;
-}
-
-const lib::NodeType&
-StorageMessageAddress::getNodeType() const
-{
- if (!_type) {
- throw vespalib::IllegalStateException("Cannot retrieve node type out of external address", VESPA_STRLOC);
- }
- return *_type;
-}
-
-const vespalib::string&
-StorageMessageAddress::getCluster() const
-{
- if (!_type) {
- throw vespalib::IllegalStateException("Cannot retrieve cluster out of external address", VESPA_STRLOC);
- }
- return _cluster;
-}
-
bool
-StorageMessageAddress::operator==(const StorageMessageAddress& other) const
+StorageMessageAddress::operator==(const StorageMessageAddress& other) const noexcept
{
if (_protocol != other._protocol) return false;
if (_type != other._type) return false;
- if (_type) {
- if (_index != other._index) return false;
- if (_type != other._type) return false;
- if (_cluster != other._cluster) return false;
- }
+ if (_index != other._index) return false;
+ if (getCluster() != other.getCluster()) return false;
return true;
}
@@ -242,15 +219,15 @@ void
StorageMessageAddress::print(vespalib::asciistream & out) const
{
out << "StorageMessageAddress(";
- if (_protocol == STORAGE) {
+ if (_protocol == Protocol::STORAGE) {
out << "Storage protocol";
} else {
out << "Document protocol";
}
- if (!_type) {
+ if (_type == lib::NodeType::Type::UNKNOWN) {
out << ", " << to_mbus_route().toString() << ")";
} else {
- out << ", cluster " << _cluster << ", nodetype " << *_type
+ out << ", cluster " << getCluster() << ", nodetype " << lib::NodeType::get(_type)
<< ", index " << _index << ")";
}
}
@@ -258,12 +235,12 @@ StorageMessageAddress::print(vespalib::asciistream & out) const
TransportContext::~TransportContext() = default;
StorageMessage::Id
-StorageMessage::generateMsgId()
+StorageMessage::generateMsgId() noexcept
{
return _G_lastMsgId.fetch_add(1, std::memory_order_relaxed);
}
-StorageMessage::StorageMessage(const MessageType& type, Id id)
+StorageMessage::StorageMessage(const MessageType& type, Id id) noexcept
: _type(type),
_msgId(id),
_address(),
@@ -273,7 +250,7 @@ StorageMessage::StorageMessage(const MessageType& type, Id id)
{
}
-StorageMessage::StorageMessage(const StorageMessage& other, Id id)
+StorageMessage::StorageMessage(const StorageMessage& other, Id id) noexcept
: _type(other._type),
_msgId(id),
_address(),
@@ -285,13 +262,8 @@ StorageMessage::StorageMessage(const StorageMessage& other, Id id)
StorageMessage::~StorageMessage() = default;
-const documentapi::LoadType&
-StorageMessage::getLoadType() const {
- return documentapi::LoadType::DEFAULT;
-}
-
void
-StorageMessage::setNewMsgId()
+StorageMessage::setNewMsgId() noexcept
{
_msgId = generateMsgId();
}
diff --git a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h
index 98552e473c1..acf651d8816 100644
--- a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h
+++ b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h
@@ -21,7 +21,6 @@
#include <iosfwd>
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.
@@ -241,16 +240,16 @@ public:
MessageType(const MessageType &) = delete;
MessageType& operator=(const MessageType &) = delete;
~MessageType();
- Id getId() const { return _id; }
- static Id getMaxId() { return MESSAGETYPE_MAX_ID; }
- const vespalib::string& getName() const { return _name; }
- bool isReply() const { return (_replyOf != 0); }
+ Id getId() const noexcept { return _id; }
+ static Id getMaxId() noexcept { return MESSAGETYPE_MAX_ID; }
+ const vespalib::string& getName() const noexcept { return _name; }
+ bool isReply() const noexcept { return (_replyOf != 0); }
/** Only valid to call on replies. */
- const MessageType& getCommandType() const { return *_replyOf; }
+ const MessageType& getCommandType() const noexcept { return *_replyOf; }
/** Only valid to call on commands. */
- const MessageType& getReplyType() const { return *_reply; }
- bool operator==(const MessageType& type) const { return (_id == type._id); }
- bool operator!=(const MessageType& type) const { return (_id != type._id); }
+ const MessageType& getReplyType() const noexcept { return *_reply; }
+ bool operator==(const MessageType& type) const noexcept { return (_id == type._id); }
+ bool operator!=(const MessageType& type) const noexcept { return (_id != type._id); }
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
};
@@ -263,40 +262,44 @@ public:
*/
class StorageMessageAddress {
public:
- enum Protocol { STORAGE, DOCUMENT };
+ enum class Protocol : uint8_t { STORAGE, DOCUMENT };
private:
- vespalib::string _cluster;
+ const vespalib::string *_cluster;
// Used for internal VDS addresses only
- size_t _precomputed_storage_hash;
- const lib::NodeType* _type;
- Protocol _protocol;
- uint16_t _index;
+ uint32_t _precomputed_storage_hash;
+ lib::NodeType::Type _type;
+ Protocol _protocol;
+ uint16_t _index;
public:
- StorageMessageAddress(); // Only to be used when transient default ctor semantics are needed by containers
- StorageMessageAddress(vespalib::stringref clusterName,
- const lib::NodeType& type, uint16_t index,
- Protocol protocol = STORAGE);
+ StorageMessageAddress() noexcept; // Only to be used when transient default ctor semantics are needed by containers
+ StorageMessageAddress(const vespalib::string * cluster, const lib::NodeType& type, uint16_t index) noexcept;
+ StorageMessageAddress(const vespalib::string * cluster, const lib::NodeType& type, uint16_t index, Protocol protocol) noexcept;
~StorageMessageAddress();
- void setProtocol(Protocol p) { _protocol = p; }
+ void setProtocol(Protocol p) noexcept { _protocol = p; }
mbus::Route to_mbus_route() const;
- Protocol getProtocol() const { return _protocol; }
- uint16_t getIndex() const;
- const lib::NodeType& getNodeType() const;
- const vespalib::string& getCluster() const;
+ Protocol getProtocol() const noexcept { return _protocol; }
+ uint16_t getIndex() const noexcept { return _index; }
+ lib::NodeType::Type getNodeType() const noexcept { return _type; }
+ const vespalib::string& getCluster() const noexcept { return *_cluster; }
// Returns precomputed hash over <type, index> pair. Other fields not included.
- [[nodiscard]] size_t internal_storage_hash() const noexcept {
+ [[nodiscard]] uint32_t internal_storage_hash() const noexcept {
return _precomputed_storage_hash;
}
- bool operator==(const StorageMessageAddress& other) const;
+ bool operator==(const StorageMessageAddress& other) const noexcept;
vespalib::string toString() const;
friend std::ostream & operator << (std::ostream & os, const StorageMessageAddress & addr);
-
+ static StorageMessageAddress create(const vespalib::string * cluster, const lib::NodeType& type, uint16_t index) noexcept {
+ return api::StorageMessageAddress(cluster, type, index);
+ }
+ static StorageMessageAddress createDocApi(const vespalib::string * cluster, const lib::NodeType& type, uint16_t index) noexcept {
+ return api::StorageMessageAddress(cluster, type, index, Protocol::DOCUMENT);
+ }
private:
void print(vespalib::asciistream & out) const;
};
@@ -349,47 +352,47 @@ public:
static const char* getPriorityString(Priority);
private:
+ static document::Bucket getDummyBucket() noexcept { return document::Bucket(document::BucketSpace::invalid(), document::BucketId()); }
mutable std::unique_ptr<TransportContext> _transportContext;
protected:
- static Id generateMsgId();
+ static Id generateMsgId() noexcept;
- const MessageType& _type;
- Id _msgId;
- std::unique_ptr<StorageMessageAddress> _address;
- vespalib::Trace _trace;
- uint32_t _approxByteSize;
- Priority _priority;
+ const MessageType& _type;
+ Id _msgId;
+ StorageMessageAddress _address;
+ vespalib::Trace _trace;
+ uint32_t _approxByteSize;
+ Priority _priority;
- StorageMessage(const MessageType& code, Id id);
- StorageMessage(const StorageMessage&, Id id);
+ StorageMessage(const MessageType& code, Id id) noexcept;
+ StorageMessage(const StorageMessage&, Id id) noexcept;
- static document::Bucket getDummyBucket() { return document::Bucket(document::BucketSpace::invalid(), document::BucketId()); }
public:
StorageMessage& operator=(const StorageMessage&) = delete;
StorageMessage(const StorageMessage&) = delete;
~StorageMessage() override;
- Id getMsgId() const { return _msgId; }
+ Id getMsgId() const noexcept { return _msgId; }
/** Method used by storage commands to set a new id. */
- void setNewMsgId();
+ void setNewMsgId() noexcept;
/**
* Set the id of this message. Typically used to set the id to a
* unique value previously generated with the generateMsgId method.
**/
- void forceMsgId(Id msgId) { _msgId = msgId; }
+ void forceMsgId(Id msgId) noexcept { _msgId = msgId; }
- const MessageType& getType() const { return _type; }
+ const MessageType& getType() const noexcept { return _type; }
- void setPriority(Priority p) { _priority = p; }
- Priority getPriority() const { return _priority; }
+ void setPriority(Priority p) noexcept { _priority = p; }
+ Priority getPriority() const noexcept { return _priority; }
- const StorageMessageAddress* getAddress() const { return _address.get(); }
+ const StorageMessageAddress* getAddress() const noexcept { return (_address.getNodeType() != lib::NodeType::Type::UNKNOWN) ? &_address : nullptr; }
- void setAddress(const StorageMessageAddress& address) {
- _address = std::make_unique<StorageMessageAddress>(address);
+ void setAddress(const StorageMessageAddress& address) noexcept {
+ _address = address;
}
/**
@@ -400,7 +403,7 @@ public:
return _approxByteSize;
}
- void setApproxByteSize(uint32_t value) {
+ void setApproxByteSize(uint32_t value) noexcept {
_approxByteSize = value;
}
@@ -409,11 +412,11 @@ public:
* created, whether it was a storageprotocol message, a documentprotocol
* message, or an RPC call.
*/
- void setTransportContext(std::unique_ptr<TransportContext> context) {
+ void setTransportContext(std::unique_ptr<TransportContext> context) noexcept {
_transportContext = std::move(context);
}
- std::unique_ptr<TransportContext> getTransportContext() const {
+ std::unique_ptr<TransportContext> getTransportContext() const noexcept {
return std::move(_transportContext);
}
@@ -427,16 +430,14 @@ public:
*/
virtual bool callHandler(MessageHandler&, const StorageMessage::SP&) const = 0;
- const documentapi::LoadType& getLoadType() const;
-
- mbus::Trace && steal_trace() { return std::move(_trace); }
- mbus::Trace& getTrace() { return _trace; }
- const mbus::Trace& getTrace() const { return _trace; }
+ mbus::Trace && steal_trace() noexcept { return std::move(_trace); }
+ mbus::Trace& getTrace() noexcept { return _trace; }
+ const mbus::Trace& getTrace() const noexcept { return _trace; }
/**
Sets the trace object for this message.
*/
- void setTrace(vespalib::Trace && trace) { _trace = std::move(trace); }
+ void setTrace(vespalib::Trace && trace) noexcept { _trace = std::move(trace); }
/**
* Cheap version of tostring().
@@ -444,7 +445,7 @@ public:
virtual vespalib::string getSummary() const;
virtual document::Bucket getBucket() const { return getDummyBucket(); }
- document::BucketId getBucketId() const { return getBucket().getBucketId(); }
+ document::BucketId getBucketId() const noexcept { return getBucket().getBucketId(); }
virtual bool hasSingleBucketId() const { return false; }
virtual LockingRequirements lockingRequirements() const noexcept {
// Safe default: assume exclusive locking is required.
diff --git a/storageapi/src/vespa/storageapi/messageapi/storagereply.cpp b/storageapi/src/vespa/storageapi/messageapi/storagereply.cpp
index 2bb9fabd7d5..b5cbd3eae54 100644
--- a/storageapi/src/vespa/storageapi/messageapi/storagereply.cpp
+++ b/storageapi/src/vespa/storageapi/messageapi/storagereply.cpp
@@ -6,9 +6,13 @@
namespace storage::api {
+StorageReply::StorageReply(const StorageCommand& cmd)
+ : StorageReply(cmd, ReturnCode())
+{}
+
StorageReply::StorageReply(const StorageCommand& cmd, ReturnCode code)
: StorageMessage(cmd.getType().getReplyType(), cmd.getMsgId()),
- _result(code)
+ _result(std::move(code))
{
setPriority(cmd.getPriority());
if (cmd.getAddress()) {
@@ -26,10 +30,8 @@ StorageReply::StorageReply(const StorageCommand& cmd, ReturnCode code)
StorageReply::~StorageReply() = default;
void
-StorageReply::print(std::ostream& out, bool verbose,
- const std::string& indent) const
+StorageReply::print(std::ostream& out, bool , const std::string& ) const
{
- (void) verbose; (void) indent;
out << "StorageReply(" << _type.getName() << ", " << _result << ")";
}
diff --git a/storageapi/src/vespa/storageapi/messageapi/storagereply.h b/storageapi/src/vespa/storageapi/messageapi/storagereply.h
index 53516949110..e423e3b5bf9 100644
--- a/storageapi/src/vespa/storageapi/messageapi/storagereply.h
+++ b/storageapi/src/vespa/storageapi/messageapi/storagereply.h
@@ -23,8 +23,8 @@ class StorageReply : public StorageMessage {
ReturnCode _result;
protected:
- explicit StorageReply(const StorageCommand& cmd,
- ReturnCode code = ReturnCode(ReturnCode::OK));
+ explicit StorageReply(const StorageCommand& cmd);
+ StorageReply(const StorageCommand& cmd, ReturnCode code);
public:
~StorageReply() override;