summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorArne H Juul <arnej27959@users.noreply.github.com>2020-12-17 10:53:18 +0100
committerGitHub <noreply@github.com>2020-12-17 10:53:18 +0100
commit89871ab85daea71d5d401467735da094b2a49387 (patch)
tree52d39dce570c8a1e87bc6b5bf89ccb06f8e3aab5 /storage
parentfd8707d1d4c9912fb9b0a2a7e010b4eb2d8a353d (diff)
parente8d657e679f1e8cb9b24c3f847812a72fb14f947 (diff)
Merge pull request #15836 from vespa-engine/arnej/storage-cluster-context
Arnej/storage cluster context
Diffstat (limited to 'storage')
-rw-r--r--storage/src/tests/distributor/bucketstateoperationtest.cpp26
-rw-r--r--storage/src/tests/distributor/distributor_message_sender_stub.cpp1
-rw-r--r--storage/src/tests/distributor/distributor_message_sender_stub.h6
-rw-r--r--storage/src/tests/distributor/dummy_cluster_context.h13
-rw-r--r--storage/src/tests/distributor/garbagecollectiontest.cpp7
-rw-r--r--storage/src/tests/distributor/idealstatemanagertest.cpp22
-rw-r--r--storage/src/tests/distributor/joinbuckettest.cpp9
-rw-r--r--storage/src/tests/distributor/removebucketoperationtest.cpp11
-rw-r--r--storage/src/tests/distributor/splitbuckettest.cpp17
-rw-r--r--storage/src/tests/persistence/mergehandlertest.cpp4
-rw-r--r--storage/src/vespa/storage/common/cluster_context.h46
-rw-r--r--storage/src/vespa/storage/common/storagecomponent.cpp8
-rw-r--r--storage/src/vespa/storage/common/storagecomponent.h9
-rw-r--r--storage/src/vespa/storage/distributor/distributor.cpp7
-rw-r--r--storage/src/vespa/storage/distributor/distributor.h5
-rw-r--r--storage/src/vespa/storage/distributor/distributor_node_context.h5
-rw-r--r--storage/src/vespa/storage/distributor/distributorcomponent.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/distributorcomponent.h2
-rw-r--r--storage/src/vespa/storage/distributor/distributormessagesender.cpp5
-rw-r--r--storage/src/vespa/storage/distributor/distributormessagesender.h3
-rw-r--r--storage/src/vespa/storage/distributor/externaloperationhandler.cpp4
-rw-r--r--storage/src/vespa/storage/distributor/messagetracker.cpp6
-rw-r--r--storage/src/vespa/storage/distributor/messagetracker.h5
-rw-r--r--storage/src/vespa/storage/distributor/operationowner.h4
-rw-r--r--storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp4
-rw-r--r--storage/src/vespa/storage/distributor/operations/external/visitoroperation.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp4
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h3
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.h2
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/removebucketoperation.h4
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp4
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.h2
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp4
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.h3
-rw-r--r--storage/src/vespa/storage/distributor/persistencemessagetracker.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/statecheckers.cpp14
-rw-r--r--storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h1
-rw-r--r--storage/src/vespa/storage/persistence/bucketownershipnotifier.cpp3
-rw-r--r--storage/src/vespa/storage/persistence/mergehandler.cpp16
-rw-r--r--storage/src/vespa/storage/persistence/mergehandler.h5
-rw-r--r--storage/src/vespa/storage/persistence/persistencehandler.cpp2
-rw-r--r--storage/src/vespa/storage/storageserver/communicationmanager.cpp2
-rw-r--r--storage/src/vespa/storage/storageserver/mergethrottler.cpp3
45 files changed, 182 insertions, 129 deletions
diff --git a/storage/src/tests/distributor/bucketstateoperationtest.cpp b/storage/src/tests/distributor/bucketstateoperationtest.cpp
index a692ddd5cac..4abf47cd210 100644
--- a/storage/src/tests/distributor/bucketstateoperationtest.cpp
+++ b/storage/src/tests/distributor/bucketstateoperationtest.cpp
@@ -5,16 +5,13 @@
#include <vespa/storage/distributor/distributor.h>
#include <vespa/document/test/make_document_bucket.h>
#include <vespa/vespalib/gtest/gtest.h>
+#include "dummy_cluster_context.h"
using document::test::makeDocumentBucket;
using namespace ::testing;
namespace storage::distributor {
-namespace {
- vespalib::string _Storage("storage");
-}
-
struct BucketStateOperationTest : Test, DistributorTestUtil {
void SetUp() override {
createLinks();
@@ -43,7 +40,7 @@ TEST_F(BucketStateOperationTest, activate_single_node) {
BucketAndNodes bucketAndNodes(makeDocumentBucket(bid), toVector<uint16_t>(0));
std::vector<uint16_t> active;
active.push_back(0);
- SetBucketStateOperation op(&_Storage, bucketAndNodes, active);
+ SetBucketStateOperation op(dummy_cluster_context, bucketAndNodes, active);
op.setIdealStateManager(&getIdealStateManager());
op.start(_sender, framework::MilliSecTime(0));
@@ -52,7 +49,7 @@ TEST_F(BucketStateOperationTest, activate_single_node) {
std::shared_ptr<api::StorageCommand> msg = _sender.command(0);
ASSERT_EQ(msg->getType(), api::MessageType::SETBUCKETSTATE);
- EXPECT_EQ(api::StorageMessageAddress(&_Storage, lib::NodeType::STORAGE, 0).toString(),
+ EXPECT_EQ(api::StorageMessageAddress(dummy_cluster_context.cluster_name_ptr(), lib::NodeType::STORAGE, 0).toString(),
msg->getAddress()->toString());
auto& cmd = dynamic_cast<const api::SetBucketStateCommand&>(*msg);
@@ -79,7 +76,7 @@ TEST_F(BucketStateOperationTest, activate_and_deactivate_nodes) {
BucketAndNodes bucketAndNodes(makeDocumentBucket(bid), toVector<uint16_t>(0, 1));
std::vector<uint16_t> active;
active.push_back(1);
- SetBucketStateOperation op(&_Storage, bucketAndNodes, active);
+ SetBucketStateOperation op(dummy_cluster_context, bucketAndNodes, active);
op.setIdealStateManager(&getIdealStateManager());
op.start(_sender, framework::MilliSecTime(0));
@@ -88,7 +85,7 @@ TEST_F(BucketStateOperationTest, activate_and_deactivate_nodes) {
{
std::shared_ptr<api::StorageCommand> msg = _sender.command(0);
ASSERT_EQ(msg->getType(), api::MessageType::SETBUCKETSTATE);
- EXPECT_EQ(api::StorageMessageAddress(&_Storage, lib::NodeType::STORAGE, 1).toString(),
+ EXPECT_EQ(api::StorageMessageAddress(dummy_cluster_context.cluster_name_ptr(), lib::NodeType::STORAGE, 1).toString(),
msg->getAddress()->toString());
auto& cmd = dynamic_cast<const api::SetBucketStateCommand&>(*msg);
@@ -103,7 +100,8 @@ TEST_F(BucketStateOperationTest, activate_and_deactivate_nodes) {
{
std::shared_ptr<api::StorageCommand> msg = _sender.command(1);
ASSERT_EQ(msg->getType(), api::MessageType::SETBUCKETSTATE);
- EXPECT_EQ(api::StorageMessageAddress(&_Storage, lib::NodeType::STORAGE, 0).toString(),
+ EXPECT_EQ(api::StorageMessageAddress(dummy_cluster_context.cluster_name_ptr(),
+ lib::NodeType::STORAGE, 0).toString(),
msg->getAddress()->toString());
auto& cmd = dynamic_cast<const api::SetBucketStateCommand&>(*msg);
@@ -134,7 +132,7 @@ TEST_F(BucketStateOperationTest, do_not_deactivate_if_activate_fails) {
BucketAndNodes bucketAndNodes(makeDocumentBucket(bid), toVector<uint16_t>(0, 1));
std::vector<uint16_t> active;
active.push_back(1);
- SetBucketStateOperation op(&_Storage, bucketAndNodes, active);
+ SetBucketStateOperation op(dummy_cluster_context, bucketAndNodes, active);
op.setIdealStateManager(&getIdealStateManager());
op.start(_sender, framework::MilliSecTime(0));
@@ -143,7 +141,8 @@ TEST_F(BucketStateOperationTest, do_not_deactivate_if_activate_fails) {
{
std::shared_ptr<api::StorageCommand> msg = _sender.command(0);
ASSERT_EQ(msg->getType(), api::MessageType::SETBUCKETSTATE);
- EXPECT_EQ(api::StorageMessageAddress(&_Storage, lib::NodeType::STORAGE, 1).toString(),
+ EXPECT_EQ(api::StorageMessageAddress(dummy_cluster_context.cluster_name_ptr(),
+ lib::NodeType::STORAGE, 1).toString(),
msg->getAddress()->toString());
auto& cmd = dynamic_cast<const api::SetBucketStateCommand&>(*msg);
@@ -176,7 +175,7 @@ TEST_F(BucketStateOperationTest, bucket_db_not_updated_on_failure) {
BucketAndNodes bucketAndNodes(makeDocumentBucket(bid), toVector<uint16_t>(0));
std::vector<uint16_t> active;
active.push_back(0);
- SetBucketStateOperation op(&_Storage, bucketAndNodes, active);
+ SetBucketStateOperation op(dummy_cluster_context, bucketAndNodes, active);
op.setIdealStateManager(&getIdealStateManager());
op.start(_sender, framework::MilliSecTime(0));
@@ -185,7 +184,8 @@ TEST_F(BucketStateOperationTest, bucket_db_not_updated_on_failure) {
std::shared_ptr<api::StorageCommand> msg = _sender.command(0);
ASSERT_EQ(msg->getType(), api::MessageType::SETBUCKETSTATE);
- EXPECT_EQ(api::StorageMessageAddress(&_Storage, lib::NodeType::STORAGE, 0).toString(),
+ EXPECT_EQ(api::StorageMessageAddress(dummy_cluster_context.cluster_name_ptr(),
+ lib::NodeType::STORAGE, 0).toString(),
msg->getAddress()->toString());
std::shared_ptr<api::StorageReply> reply(msg->makeReply().release());
diff --git a/storage/src/tests/distributor/distributor_message_sender_stub.cpp b/storage/src/tests/distributor/distributor_message_sender_stub.cpp
index 893ebcd158a..bb0079744c2 100644
--- a/storage/src/tests/distributor/distributor_message_sender_stub.cpp
+++ b/storage/src/tests/distributor/distributor_message_sender_stub.cpp
@@ -11,7 +11,6 @@ namespace storage {
DistributorMessageSenderStub::DistributorMessageSenderStub()
: _stub_impl(),
- _cluster_name("storage"),
_pending_message_tracker(nullptr),
_operation_sequencer(nullptr)
{}
diff --git a/storage/src/tests/distributor/distributor_message_sender_stub.h b/storage/src/tests/distributor/distributor_message_sender_stub.h
index 0b5ab5ae9a7..3791839f3fe 100644
--- a/storage/src/tests/distributor/distributor_message_sender_stub.h
+++ b/storage/src/tests/distributor/distributor_message_sender_stub.h
@@ -6,12 +6,12 @@
#include <tests/common/message_sender_stub.h>
#include <cassert>
#include <string>
+#include "dummy_cluster_context.h"
namespace storage {
class DistributorMessageSenderStub : public distributor::DistributorMessageSender {
MessageSenderStub _stub_impl;
- vespalib::string _cluster_name;
distributor::PendingMessageTracker* _pending_message_tracker;
distributor::OperationSequencer* _operation_sequencer;
public:
@@ -83,8 +83,8 @@ public:
return 0;
}
- const vespalib::string& getClusterName() const override {
- return _cluster_name;
+ const ClusterContext& cluster_context() const override {
+ return dummy_cluster_context;
}
const distributor::PendingMessageTracker& getPendingMessageTracker() const override {
diff --git a/storage/src/tests/distributor/dummy_cluster_context.h b/storage/src/tests/distributor/dummy_cluster_context.h
new file mode 100644
index 00000000000..783038daf7d
--- /dev/null
+++ b/storage/src/tests/distributor/dummy_cluster_context.h
@@ -0,0 +1,13 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <vespa/storage/common/cluster_context.h>
+
+namespace storage {
+namespace {
+
+SimpleClusterContext dummy_cluster_context("storage");
+
+} // namespace <unnamed>
+} // namespace storage
diff --git a/storage/src/tests/distributor/garbagecollectiontest.cpp b/storage/src/tests/distributor/garbagecollectiontest.cpp
index e360578abec..751269fe586 100644
--- a/storage/src/tests/distributor/garbagecollectiontest.cpp
+++ b/storage/src/tests/distributor/garbagecollectiontest.cpp
@@ -8,16 +8,13 @@
#include <vespa/storage/distributor/distributor.h>
#include <vespa/document/test/make_document_bucket.h>
#include <vespa/vespalib/gtest/gtest.h>
+#include "dummy_cluster_context.h"
using document::test::makeDocumentBucket;
using namespace ::testing;
namespace storage::distributor {
-namespace {
- vespalib::string _Storage("storage");
-}
-
struct GarbageCollectionOperationTest : Test, DistributorTestUtil {
void SetUp() override {
createLinks();
@@ -33,7 +30,7 @@ struct GarbageCollectionOperationTest : Test, DistributorTestUtil {
std::shared_ptr<GarbageCollectionOperation> create_op() {
auto op = std::make_shared<GarbageCollectionOperation>(
- &_Storage,BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)),
+ dummy_cluster_context, BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)),
toVector<uint16_t>(0, 1)));
op->setIdealStateManager(&getIdealStateManager());
return op;
diff --git a/storage/src/tests/distributor/idealstatemanagertest.cpp b/storage/src/tests/distributor/idealstatemanagertest.cpp
index 24470c09114..51284307fa8 100644
--- a/storage/src/tests/distributor/idealstatemanagertest.cpp
+++ b/storage/src/tests/distributor/idealstatemanagertest.cpp
@@ -13,6 +13,7 @@
#include <vespa/document/test/make_document_bucket.h>
#include <vespa/document/test/make_bucket_space.h>
#include <vespa/vespalib/gtest/gtest.h>
+#include "dummy_cluster_context.h"
using document::test::makeDocumentBucket;
using document::test::makeBucketSpace;
@@ -59,9 +60,6 @@ struct IdealStateManagerTest : Test, DistributorTestUtil {
std::vector<document::BucketSpace> _bucketSpaces;
std::string makeBucketStatusString(const std::string &defaultSpaceBucketStatus);
};
-namespace {
- vespalib::string _Storage("storage");
-}
TEST_F(IdealStateManagerTest, sibling) {
EXPECT_EQ(document::BucketId(1,1),
@@ -190,19 +188,19 @@ TEST_F(IdealStateManagerTest, block_ideal_state_ops_on_full_request_bucket_info)
// sent to the entire node. It will then use a null bucketid.
{
auto msg = std::make_shared<api::RequestBucketInfoCommand>(makeBucketSpace(), buckets);
- msg->setAddress(api::StorageMessageAddress::create(&_Storage, lib::NodeType::STORAGE, 4));
+ msg->setAddress(api::StorageMessageAddress::create(dummy_cluster_context.cluster_name_ptr(), lib::NodeType::STORAGE, 4));
tracker.insert(msg);
}
{
- RemoveBucketOperation op(&_Storage,
+ RemoveBucketOperation op(dummy_cluster_context,
BucketAndNodes(makeDocumentBucket(bid), toVector<uint16_t>(3, 4)));
EXPECT_TRUE(op.isBlocked(tracker, op_seq));
}
{
// Don't trigger on requests to other nodes.
- RemoveBucketOperation op(&_Storage,
+ RemoveBucketOperation op(dummy_cluster_context,
BucketAndNodes(makeDocumentBucket(bid), toVector<uint16_t>(3, 5)));
EXPECT_FALSE(op.isBlocked(tracker, op_seq));
}
@@ -210,12 +208,12 @@ TEST_F(IdealStateManagerTest, block_ideal_state_ops_on_full_request_bucket_info)
// Don't block on null-bucket messages that aren't RequestBucketInfo.
{
auto msg = std::make_shared<api::CreateVisitorCommand>(makeBucketSpace(), "foo", "bar", "baz");
- msg->setAddress(api::StorageMessageAddress::create(&_Storage, lib::NodeType::STORAGE, 7));
+ msg->setAddress(api::StorageMessageAddress::create(dummy_cluster_context.cluster_name_ptr(), lib::NodeType::STORAGE, 7));
tracker.insert(msg);
}
{
- RemoveBucketOperation op(&_Storage,
+ RemoveBucketOperation op(dummy_cluster_context,
BucketAndNodes(makeDocumentBucket(bid), toVector<uint16_t>(7)));
EXPECT_FALSE(op.isBlocked(tracker, op_seq));
}
@@ -230,11 +228,11 @@ TEST_F(IdealStateManagerTest, block_check_for_all_operations_to_specific_bucket)
{
auto msg = std::make_shared<api::JoinBucketsCommand>(makeDocumentBucket(bid));
- msg->setAddress(api::StorageMessageAddress::create(&_Storage, lib::NodeType::STORAGE, 4));
+ msg->setAddress(api::StorageMessageAddress::create(dummy_cluster_context.cluster_name_ptr(), lib::NodeType::STORAGE, 4));
tracker.insert(msg);
}
{
- RemoveBucketOperation op(&_Storage,
+ RemoveBucketOperation op(dummy_cluster_context,
BucketAndNodes(makeDocumentBucket(bid), toVector<uint16_t>(7)));
// Not blocked for exact node match.
EXPECT_FALSE(checkBlock(op, makeDocumentBucket(bid), tracker, op_seq));
@@ -252,13 +250,13 @@ TEST_F(IdealStateManagerTest, block_operations_with_locked_buckets) {
{
auto msg = std::make_shared<api::JoinBucketsCommand>(bucket);
- msg->setAddress(api::StorageMessageAddress::create(&_Storage, lib::NodeType::STORAGE, 1));
+ msg->setAddress(api::StorageMessageAddress::create(dummy_cluster_context.cluster_name_ptr(), lib::NodeType::STORAGE, 1));
tracker.insert(msg);
}
auto token = op_seq.try_acquire(bucket, "foo");
EXPECT_TRUE(token.valid());
{
- RemoveBucketOperation op(&_Storage, BucketAndNodes(bucket, toVector<uint16_t>(0)));
+ RemoveBucketOperation op(dummy_cluster_context, BucketAndNodes(bucket, toVector<uint16_t>(0)));
EXPECT_TRUE(checkBlock(op, bucket, tracker, op_seq));
EXPECT_TRUE(checkBlockForAllNodes(op, bucket, tracker, op_seq));
}
diff --git a/storage/src/tests/distributor/joinbuckettest.cpp b/storage/src/tests/distributor/joinbuckettest.cpp
index 12ad52e9d5e..9382648e881 100644
--- a/storage/src/tests/distributor/joinbuckettest.cpp
+++ b/storage/src/tests/distributor/joinbuckettest.cpp
@@ -6,6 +6,7 @@
#include <vespa/document/test/make_document_bucket.h>
#include <vespa/vespalib/gtest/gtest.h>
#include <gmock/gmock.h>
+#include "dummy_cluster_context.h"
using document::test::makeDocumentBucket;
using namespace ::testing;
@@ -27,10 +28,6 @@ struct JoinOperationTest : Test, DistributorTestUtil {
}
};
-namespace {
- vespalib::string _Storage("storage");
-}
-
TEST_F(JoinOperationTest, simple) {
getConfig().setJoinCount(100);
getConfig().setJoinSize(1000);
@@ -40,7 +37,7 @@ TEST_F(JoinOperationTest, simple) {
enableDistributorClusterState("distributor:1 storage:1");
- JoinOperation op(&_Storage,
+ JoinOperation op(dummy_cluster_context,
BucketAndNodes(makeDocumentBucket(document::BucketId(32, 0)),
toVector<uint16_t>(0)),
toVector(document::BucketId(33, 1),
@@ -95,7 +92,7 @@ TEST_F(JoinOperationTest, send_sparse_joins_to_nodes_without_both_source_buckets
enableDistributorClusterState("distributor:1 storage:2");
- JoinOperation op(&_Storage,
+ JoinOperation op(dummy_cluster_context,
BucketAndNodes(makeDocumentBucket(document::BucketId(32, 0)),
toVector<uint16_t>(0, 1)),
toVector(document::BucketId(33, 1),
diff --git a/storage/src/tests/distributor/removebucketoperationtest.cpp b/storage/src/tests/distributor/removebucketoperationtest.cpp
index 26be1fc532e..c670e89b065 100644
--- a/storage/src/tests/distributor/removebucketoperationtest.cpp
+++ b/storage/src/tests/distributor/removebucketoperationtest.cpp
@@ -9,16 +9,13 @@
#include <tests/distributor/distributortestutil.h>
#include <vespa/document/test/make_document_bucket.h>
#include <vespa/vespalib/gtest/gtest.h>
+#include "dummy_cluster_context.h"
using document::test::makeDocumentBucket;
using namespace ::testing;
namespace storage::distributor {
-namespace {
- vespalib::string _Storage("storage");
-}
-
struct RemoveBucketOperationTest : Test, DistributorTestUtil {
void SetUp() override {
createLinks();
@@ -37,7 +34,7 @@ TEST_F(RemoveBucketOperationTest, simple) {
setRedundancy(1);
enableDistributorClusterState("distributor:1 storage:3");
- RemoveBucketOperation op(&_Storage,
+ RemoveBucketOperation op(dummy_cluster_context,
BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)),
toVector<uint16_t>(1,2)));
op.setIdealStateManager(&getIdealStateManager());
@@ -69,7 +66,7 @@ TEST_F(RemoveBucketOperationTest, bucket_info_mismatch_failure) {
enableDistributorClusterState("distributor:1 storage:2");
- RemoveBucketOperation op(&_Storage,
+ RemoveBucketOperation op(dummy_cluster_context,
BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)),
toVector<uint16_t>(1)));
op.setIdealStateManager(&getIdealStateManager());
@@ -104,7 +101,7 @@ TEST_F(RemoveBucketOperationTest, fail_with_invalid_bucket_info) {
enableDistributorClusterState("distributor:1 storage:2");
- RemoveBucketOperation op(&_Storage,
+ RemoveBucketOperation op(dummy_cluster_context,
BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)),
toVector<uint16_t>(1)));
op.setIdealStateManager(&getIdealStateManager());
diff --git a/storage/src/tests/distributor/splitbuckettest.cpp b/storage/src/tests/distributor/splitbuckettest.cpp
index 93351c0ab56..527fc7bfa2a 100644
--- a/storage/src/tests/distributor/splitbuckettest.cpp
+++ b/storage/src/tests/distributor/splitbuckettest.cpp
@@ -10,6 +10,7 @@
#include <tests/common/dummystoragelink.h>
#include <tests/distributor/distributortestutil.h>
#include <vespa/vespalib/gtest/gtest.h>
+#include "dummy_cluster_context.h"
using document::test::makeDocumentBucket;
using namespace document;
@@ -46,8 +47,7 @@ SplitOperationTest::SplitOperationTest()
}
namespace {
- vespalib::string _Storage("storage");
- api::StorageMessageAddress _Storage0Address(&_Storage, lib::NodeType::STORAGE, 0);
+ api::StorageMessageAddress _Storage0Address(dummy_cluster_context.cluster_name_ptr(), lib::NodeType::STORAGE, 0);
}
TEST_F(SplitOperationTest, simple) {
@@ -56,7 +56,7 @@ TEST_F(SplitOperationTest, simple) {
insertBucketInfo(document::BucketId(16, 1), 0, 0xabc, 1000,
tooLargeBucketSize, 250);
- SplitOperation op(&_Storage,
+ SplitOperation op(dummy_cluster_context,
BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)),
toVector<uint16_t>(0)),
maxSplitBits,
@@ -125,7 +125,7 @@ TEST_F(SplitOperationTest, multi_node_failure) {
enableDistributorClusterState("distributor:1 storage:2");
- SplitOperation op(&_Storage,
+ SplitOperation op(dummy_cluster_context,
BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)),
toVector<uint16_t>(0,1)),
maxSplitBits,
@@ -210,7 +210,7 @@ TEST_F(SplitOperationTest, copy_trusted_status_not_carried_over_after_split) {
addNodesToBucketDB(sourceBucket, "0=150/20/30000000/t,1=450/50/60000/u,"
"2=550/60/70000");
- SplitOperation op(&_Storage,
+ SplitOperation op(dummy_cluster_context,
BucketAndNodes(makeDocumentBucket(sourceBucket), toVector<uint16_t>(0, 1)),
maxSplitBits,
splitCount,
@@ -277,7 +277,7 @@ TEST_F(SplitOperationTest, operation_blocked_by_pending_join) {
insertBucketInfo(joinTarget, 0, 0xabc, 1000, 1234, true);
- SplitOperation op(&_Storage,
+ SplitOperation op(dummy_cluster_context,
BucketAndNodes(makeDocumentBucket(joinTarget), toVector<uint16_t>(0)),
maxSplitBits,
splitCount,
@@ -290,7 +290,8 @@ TEST_F(SplitOperationTest, operation_blocked_by_pending_join) {
tracker.clearMessagesForNode(0);
EXPECT_FALSE(op.isBlocked(tracker, op_seq));
- joinCmd->setAddress(api::StorageMessageAddress::create(&_Storage, lib::NodeType::STORAGE, 1));
+ joinCmd->setAddress(api::StorageMessageAddress::create(dummy_cluster_context.cluster_name_ptr(),
+ lib::NodeType::STORAGE, 1));
tracker.insert(joinCmd);
EXPECT_TRUE(op.isBlocked(tracker, op_seq));
@@ -309,7 +310,7 @@ TEST_F(SplitOperationTest, split_is_blocked_by_locked_bucket) {
document::BucketId source_bucket(16, 1);
insertBucketInfo(source_bucket, 0, 0xabc, 1000, tooLargeBucketSize, 250);
- SplitOperation op(&_Storage, BucketAndNodes(makeDocumentBucket(source_bucket), toVector<uint16_t>(0)),
+ SplitOperation op(dummy_cluster_context, BucketAndNodes(makeDocumentBucket(source_bucket), toVector<uint16_t>(0)),
maxSplitBits, splitCount, splitByteSize);
EXPECT_FALSE(op.isBlocked(tracker, op_seq));
diff --git a/storage/src/tests/persistence/mergehandlertest.cpp b/storage/src/tests/persistence/mergehandlertest.cpp
index c1da8e9ec06..7e810c0fff4 100644
--- a/storage/src/tests/persistence/mergehandlertest.cpp
+++ b/storage/src/tests/persistence/mergehandlertest.cpp
@@ -158,11 +158,11 @@ struct MergeHandlerTest : SingleDiskPersistenceTestUtils {
MergeHandler createHandler(size_t maxChunkSize = 0x400000) {
return MergeHandler(getEnv(), getPersistenceProvider(),
- getEnv()._component.getClusterName(), getEnv()._component.getClock(), maxChunkSize);
+ getEnv()._component.cluster_context(), getEnv()._component.getClock(), maxChunkSize);
}
MergeHandler createHandler(spi::PersistenceProvider & spi) {
return MergeHandler(getEnv(), spi,
- getEnv()._component.getClusterName(), getEnv()._component.getClock());
+ getEnv()._component.cluster_context(), getEnv()._component.getClock());
}
};
diff --git a/storage/src/vespa/storage/common/cluster_context.h b/storage/src/vespa/storage/common/cluster_context.h
new file mode 100644
index 00000000000..a7d8ab0a2e5
--- /dev/null
+++ b/storage/src/vespa/storage/common/cluster_context.h
@@ -0,0 +1,46 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <vespa/vespalib/stllike/string.h>
+
+namespace storage {
+
+/**
+ * Cluster ontext common to all storage components.
+ * For now just the cluster name, but we can consider
+ * moving other global context into this API.
+ **/
+struct ClusterContext {
+protected:
+ virtual ~ClusterContext() = default;
+public:
+ // Returns a pointer to the cluster name.
+ // Must be a valid pointer to a constant string for the
+ // lifetime of all the components that may ask for it.
+ // This API is for the benefit of StorageMessageAddress
+ // which wants to contain the pointer returned here.
+ virtual const vespalib::string * cluster_name_ptr() const noexcept = 0;
+
+ // convenience method
+ const vespalib::string &cluster_name() const noexcept {
+ return *cluster_name_ptr();
+ }
+};
+
+/**
+ * Simple ClusterContext with an exposed string.
+ **/
+struct SimpleClusterContext : ClusterContext {
+ vespalib::string my_cluster_name;
+ const vespalib::string * cluster_name_ptr() const noexcept override {
+ return &my_cluster_name;
+ }
+ SimpleClusterContext() : my_cluster_name("") {}
+ explicit SimpleClusterContext(const vespalib::string& value)
+ : my_cluster_name(value)
+ {}
+ ~SimpleClusterContext() override = default;
+};
+
+} // namespace
diff --git a/storage/src/vespa/storage/common/storagecomponent.cpp b/storage/src/vespa/storage/common/storagecomponent.cpp
index 7e0543a0893..b0ccacf487b 100644
--- a/storage/src/vespa/storage/common/storagecomponent.cpp
+++ b/storage/src/vespa/storage/common/storagecomponent.cpp
@@ -5,6 +5,7 @@
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vdslib/distribution/distribution.h>
#include <vespa/document/fieldset/fieldsetrepo.h>
+#include <cassert>
namespace storage {
@@ -24,7 +25,8 @@ StorageComponent::setNodeInfo(vespalib::stringref clusterName,
uint16_t index)
{
// Assumed to not be set dynamically.
- _clusterName = clusterName;
+ assert(_cluster_ctx.my_cluster_name.empty());
+ _cluster_ctx.my_cluster_name = clusterName;
_nodeType = &nodeType;
_index = index;
}
@@ -67,7 +69,7 @@ StorageComponent::setNodeStateUpdater(NodeStateUpdater& updater)
StorageComponent::StorageComponent(StorageComponentRegister& compReg,
vespalib::stringref name)
: Component(compReg, name),
- _clusterName(),
+ _cluster_ctx(),
_nodeType(nullptr),
_index(0),
_repos(),
@@ -96,7 +98,7 @@ vespalib::string
StorageComponent::getIdentity() const
{
vespalib::asciistream name;
- name << "storage/cluster." << _clusterName << "/"
+ name << "storage/cluster." << _cluster_ctx.cluster_name() << "/"
<< _nodeType->serialize() << "/" << _index;
return name.str();
}
diff --git a/storage/src/vespa/storage/common/storagecomponent.h b/storage/src/vespa/storage/common/storagecomponent.h
index 8910c6da587..4fda62929e7 100644
--- a/storage/src/vespa/storage/common/storagecomponent.h
+++ b/storage/src/vespa/storage/common/storagecomponent.h
@@ -31,6 +31,7 @@
#pragma once
+#include "cluster_context.h"
#include <vespa/storageframework/generic/component/component.h>
#include <vespa/storageframework/generic/component/componentregister.h>
#include <vespa/document/bucket/bucketidfactory.h>
@@ -43,13 +44,15 @@ namespace document {
}
namespace storage {
+
namespace lib {
class Distribution;
}
struct NodeStateUpdater;
struct StorageComponentRegister;
-class StorageComponent : public framework::Component {
+class StorageComponent : public framework::Component
+{
public:
struct Repos {
explicit Repos(std::shared_ptr<const document::DocumentTypeRepo> repo);
@@ -79,7 +82,7 @@ public:
StorageComponent(StorageComponentRegister&, vespalib::stringref name);
~StorageComponent() override;
- const vespalib::string & getClusterName() const { return _clusterName; }
+ const ClusterContext & cluster_context() const noexcept { return _cluster_ctx; }
const lib::NodeType& getNodeType() const { return *_nodeType; }
uint16_t getIndex() const { return _index; }
lib::Node getNode() const { return lib::Node(*_nodeType, _index); }
@@ -92,7 +95,7 @@ public:
NodeStateUpdater& getStateUpdater() const;
uint64_t getGeneration() const { return _generation.load(std::memory_order_relaxed); }
private:
- vespalib::string _clusterName;
+ SimpleClusterContext _cluster_ctx;
const lib::NodeType* _nodeType;
uint16_t _index;
std::shared_ptr<Repos> _repos;
diff --git a/storage/src/vespa/storage/distributor/distributor.cpp b/storage/src/vespa/storage/distributor/distributor.cpp
index 40e108dcda7..e93bb00b564 100644
--- a/storage/src/vespa/storage/distributor/distributor.cpp
+++ b/storage/src/vespa/storage/distributor/distributor.cpp
@@ -103,7 +103,6 @@ Distributor::Distributor(DistributorComponentRegister& compReg,
_schedulingMode(MaintenanceScheduler::NORMAL_SCHEDULING_MODE),
_recoveryTimeStarted(_component.getClock()),
_tickResult(framework::ThreadWaitInfo::NO_MORE_CRITICAL_WORK_KNOWN),
- _clusterName(_component.getClusterName()),
_bucketIdHasher(std::make_unique<BucketGcTimeCalculator::BucketIdIdentityHasher>()),
_metricUpdateHook(*this),
_metricLock(),
@@ -138,12 +137,6 @@ Distributor::getDistributorIndex() const
return _component.getIndex();
}
-const vespalib::string&
-Distributor::getClusterName() const
-{
- return _clusterName;
-}
-
const PendingMessageTracker&
Distributor::getPendingMessageTracker() const
{
diff --git a/storage/src/vespa/storage/distributor/distributor.h b/storage/src/vespa/storage/distributor/distributor.h
index 70affc59ce3..05340d7dcd2 100644
--- a/storage/src/vespa/storage/distributor/distributor.h
+++ b/storage/src/vespa/storage/distributor/distributor.h
@@ -59,6 +59,9 @@ public:
~Distributor() override;
+ const ClusterContext& cluster_context() const override {
+ return _component.cluster_context();
+ }
void onOpen() override;
void onClose() override;
bool onDown(const std::shared_ptr<api::StorageMessage>&) override;
@@ -156,7 +159,6 @@ public:
}
int getDistributorIndex() const override;
- const vespalib::string& getClusterName() const override;
const PendingMessageTracker& getPendingMessageTracker() const override;
void sendCommand(const std::shared_ptr<api::StorageCommand>&) override;
void sendReply(const std::shared_ptr<api::StorageReply>&) override;
@@ -324,7 +326,6 @@ private:
MaintenanceScheduler::SchedulingMode _schedulingMode;
framework::MilliSecTimer _recoveryTimeStarted;
framework::ThreadWaitInfo _tickResult;
- const vespalib::string _clusterName;
BucketDBMetricUpdater _bucketDBMetricUpdater;
std::unique_ptr<BucketGcTimeCalculator::BucketIdHasher> _bucketIdHasher;
MetricUpdateHook _metricUpdateHook;
diff --git a/storage/src/vespa/storage/distributor/distributor_node_context.h b/storage/src/vespa/storage/distributor/distributor_node_context.h
index 17f6fc1d065..3cb0f509ea7 100644
--- a/storage/src/vespa/storage/distributor/distributor_node_context.h
+++ b/storage/src/vespa/storage/distributor/distributor_node_context.h
@@ -2,7 +2,7 @@
#pragma once
-#include <vespa/vespalib/stllike/string.h>
+#include <vespa/storage/common/cluster_context.h>
#include <cstdint>
namespace document { class BucketIdFactory; }
@@ -14,12 +14,11 @@ namespace storage::distributor {
/**
* Interface that provides information and state about a distributor node.
*/
-class DistributorNodeContext {
+class DistributorNodeContext : public ClusterContext {
public:
virtual ~DistributorNodeContext() {}
virtual const framework::Clock& clock() const noexcept = 0;
virtual const document::BucketIdFactory& bucket_id_factory() const noexcept = 0;
- virtual const vespalib::string& cluster_name() const noexcept = 0;
virtual uint16_t node_index() const noexcept = 0;
};
diff --git a/storage/src/vespa/storage/distributor/distributorcomponent.cpp b/storage/src/vespa/storage/distributor/distributorcomponent.cpp
index d2a2a6fc6a0..fa5dfa73efc 100644
--- a/storage/src/vespa/storage/distributor/distributorcomponent.cpp
+++ b/storage/src/vespa/storage/distributor/distributorcomponent.cpp
@@ -50,7 +50,7 @@ DistributorComponent::getClusterStateBundle() const
api::StorageMessageAddress
DistributorComponent::nodeAddress(uint16_t nodeIndex) const
{
- return api::StorageMessageAddress::create(&getClusterName(), lib::NodeType::STORAGE, nodeIndex);
+ return api::StorageMessageAddress::create(cluster_name_ptr(), lib::NodeType::STORAGE, nodeIndex);
}
bool
diff --git a/storage/src/vespa/storage/distributor/distributorcomponent.h b/storage/src/vespa/storage/distributor/distributorcomponent.h
index 18923c44b1b..13c0a72d44e 100644
--- a/storage/src/vespa/storage/distributor/distributorcomponent.h
+++ b/storage/src/vespa/storage/distributor/distributorcomponent.h
@@ -147,8 +147,8 @@ public:
// Implements DistributorNodeContext
const framework::Clock& clock() const noexcept override { return getClock(); }
+ const vespalib::string * cluster_name_ptr() const noexcept override { return cluster_context().cluster_name_ptr(); }
const document::BucketIdFactory& bucket_id_factory() const noexcept override { return getBucketIdFactory(); }
- const vespalib::string& cluster_name() const noexcept override { return getClusterName(); }
uint16_t node_index() const noexcept override { return getIndex(); }
// Implements DistributorOperationContext
diff --git a/storage/src/vespa/storage/distributor/distributormessagesender.cpp b/storage/src/vespa/storage/distributor/distributormessagesender.cpp
index a9e18d00d8d..3afd2ea8139 100644
--- a/storage/src/vespa/storage/distributor/distributormessagesender.cpp
+++ b/storage/src/vespa/storage/distributor/distributormessagesender.cpp
@@ -10,9 +10,10 @@ DistributorMessageSender::sendToNode(const lib::NodeType& nodeType, uint16_t nod
const std::shared_ptr<api::StorageCommand> & cmd, bool useDocumentAPI)
{
cmd->setSourceIndex(getDistributorIndex());
+ const auto *cluster_np = cluster_context().cluster_name_ptr();
cmd->setAddress(useDocumentAPI
- ? api::StorageMessageAddress::createDocApi(&getClusterName(), nodeType, node)
- : api::StorageMessageAddress::create(&getClusterName(), nodeType, node));
+ ? api::StorageMessageAddress::createDocApi(cluster_np, nodeType, node)
+ : api::StorageMessageAddress::create(cluster_np, nodeType, node));
uint64_t msgId = cmd->getMsgId();
sendCommand(cmd);
return msgId;
diff --git a/storage/src/vespa/storage/distributor/distributormessagesender.h b/storage/src/vespa/storage/distributor/distributormessagesender.h
index ddf17058950..54be92dc99a 100644
--- a/storage/src/vespa/storage/distributor/distributormessagesender.h
+++ b/storage/src/vespa/storage/distributor/distributormessagesender.h
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
+#include <vespa/storage/common/cluster_context.h>
#include <vespa/storage/common/messagesender.h>
#include <vespa/vespalib/stllike/string.h>
@@ -20,7 +21,7 @@ public:
const std::shared_ptr<api::StorageCommand>& cmd, bool useDocumentAPI = false);
virtual int getDistributorIndex() const = 0;
- virtual const vespalib::string& getClusterName() const = 0;
+ virtual const ClusterContext & cluster_context() const = 0;
virtual const PendingMessageTracker& getPendingMessageTracker() const = 0;
virtual const OperationSequencer& operation_sequencer() const noexcept = 0;
};
diff --git a/storage/src/vespa/storage/distributor/externaloperationhandler.cpp b/storage/src/vespa/storage/distributor/externaloperationhandler.cpp
index c7466c5f420..f9ec1fffacb 100644
--- a/storage/src/vespa/storage/distributor/externaloperationhandler.cpp
+++ b/storage/src/vespa/storage/distributor/externaloperationhandler.cpp
@@ -50,8 +50,8 @@ public:
int getDistributorIndex() const override {
return _node_ctx.node_index();
}
- const vespalib::string& getClusterName() const override {
- return _node_ctx.cluster_name();
+ const ClusterContext & cluster_context() const override {
+ return _node_ctx;
}
const PendingMessageTracker& getPendingMessageTracker() const override {
abort(); // Never called by the messages using this component.
diff --git a/storage/src/vespa/storage/distributor/messagetracker.cpp b/storage/src/vespa/storage/distributor/messagetracker.cpp
index 54c85375f86..315af4f0c31 100644
--- a/storage/src/vespa/storage/distributor/messagetracker.cpp
+++ b/storage/src/vespa/storage/distributor/messagetracker.cpp
@@ -9,8 +9,8 @@ LOG_SETUP(".messagetracker");
namespace storage::distributor {
-MessageTracker::MessageTracker(const vespalib::string * clusterName)
- : _clusterName(clusterName)
+MessageTracker::MessageTracker(const ClusterContext& cluster_context)
+ : _cluster_ctx(cluster_context)
{}
MessageTracker::~MessageTracker() = default;
@@ -19,7 +19,7 @@ void
MessageTracker::flushQueue(MessageSender& sender)
{
for (uint32_t i = 0; i < _commandQueue.size(); i++) {
- _commandQueue[i]._msg->setAddress(api::StorageMessageAddress::create(_clusterName, lib::NodeType::STORAGE, _commandQueue[i]._target));
+ _commandQueue[i]._msg->setAddress(api::StorageMessageAddress::create(_cluster_ctx.cluster_name_ptr(), lib::NodeType::STORAGE, _commandQueue[i]._target));
_sentMessages[_commandQueue[i]._msg->getMsgId()] = _commandQueue[i]._target;
sender.sendCommand(_commandQueue[i]._msg);
}
diff --git a/storage/src/vespa/storage/distributor/messagetracker.h b/storage/src/vespa/storage/distributor/messagetracker.h
index ccc856a7032..ae33f6fc407 100644
--- a/storage/src/vespa/storage/distributor/messagetracker.h
+++ b/storage/src/vespa/storage/distributor/messagetracker.h
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
+#include <vespa/storage/common/cluster_context.h>
#include <vespa/storage/common/messagesender.h>
#include <vespa/vespalib/stllike/string.h>
#include <vector>
@@ -24,7 +25,7 @@ public:
uint16_t _target;
};
- MessageTracker(const vespalib::string * clusterName);
+ MessageTracker(const ClusterContext &cluster_context);
MessageTracker(MessageTracker &&) = default;
MessageTracker & operator = (MessageTracker &&) = default;
MessageTracker(const MessageTracker &) = delete;
@@ -52,7 +53,7 @@ protected:
// Keeps track of which node a message was sent to.
std::map<uint64_t, uint16_t> _sentMessages;
- const vespalib::string * _clusterName;
+ const ClusterContext &_cluster_ctx;
};
}
diff --git a/storage/src/vespa/storage/distributor/operationowner.h b/storage/src/vespa/storage/distributor/operationowner.h
index 5f346a0104f..5cd0fcb644d 100644
--- a/storage/src/vespa/storage/distributor/operationowner.h
+++ b/storage/src/vespa/storage/distributor/operationowner.h
@@ -40,8 +40,8 @@ public:
return _sender.getDistributorIndex();
}
- const vespalib::string& getClusterName() const override {
- return _sender.getClusterName();
+ const ClusterContext & cluster_context() const override {
+ return _sender.cluster_context();
}
const PendingMessageTracker& getPendingMessageTracker() const override {
diff --git a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
index 454aa808bad..80e7942c68e 100644
--- a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
@@ -81,8 +81,8 @@ struct IntermediateMessageSender : DistributorMessageSender {
return forward.getDistributorIndex();
}
- const vespalib::string& getClusterName() const override {
- return forward.getClusterName();
+ const ClusterContext & cluster_context() const override {
+ return forward.cluster_context();
}
const PendingMessageTracker& getPendingMessageTracker() const override {
diff --git a/storage/src/vespa/storage/distributor/operations/external/visitoroperation.cpp b/storage/src/vespa/storage/distributor/operations/external/visitoroperation.cpp
index 606b3931464..292a3a5fc0b 100644
--- a/storage/src/vespa/storage/distributor/operations/external/visitoroperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/external/visitoroperation.cpp
@@ -816,7 +816,7 @@ VisitorOperation::sendStorageVisitor(uint16_t node,
vespalib::string storageInstanceId(os.str());
cmd->setInstanceId(storageInstanceId);
- cmd->setAddress(api::StorageMessageAddress::create(&_node_ctx.cluster_name(), lib::NodeType::STORAGE, node));
+ cmd->setAddress(api::StorageMessageAddress::create(_node_ctx.cluster_name_ptr(), lib::NodeType::STORAGE, node));
cmd->setMaximumPendingReplyCount(pending);
cmd->setQueueTimeout(computeVisitorQueueTimeoutMs());
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp
index ae337696527..71f5693329a 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp
@@ -12,9 +12,9 @@ LOG_SETUP(".distributor.operation.idealstate.remove");
namespace storage::distributor {
-GarbageCollectionOperation::GarbageCollectionOperation(const vespalib::string * clusterName, const BucketAndNodes& nodes)
+GarbageCollectionOperation::GarbageCollectionOperation(const ClusterContext& cluster_ctx, const BucketAndNodes& nodes)
: IdealStateOperation(nodes),
- _tracker(clusterName),
+ _tracker(cluster_ctx),
_replica_info(),
_max_documents_removed(0)
{}
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h
index ee207214859..545dd10b539 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h
@@ -13,7 +13,8 @@ class PendingMessageTracker;
class GarbageCollectionOperation : public IdealStateOperation
{
public:
- GarbageCollectionOperation(const vespalib::string * clusterName, const BucketAndNodes& nodes);
+ GarbageCollectionOperation(const ClusterContext& cluster_ctx,
+ const BucketAndNodes& nodes);
~GarbageCollectionOperation() override;
void onStart(DistributorMessageSender& sender) override;
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp
index 1fee6942dfb..44f7b5d3b49 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp
@@ -10,7 +10,7 @@ LOG_SETUP(".distributor.operation.idealstate.join");
using namespace storage::distributor;
-JoinOperation::JoinOperation(const vespalib::string * clusterName,
+JoinOperation::JoinOperation(const ClusterContext &clusterName,
const BucketAndNodes& nodes,
const std::vector<document::BucketId>& bucketsToJoin)
: IdealStateOperation(nodes),
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.h b/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.h
index 9c683d32102..ad133a937e4 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.h
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.h
@@ -16,7 +16,7 @@ public:
* @param bucketAndNodes The bucket to join into, along with the nodes this operation uses.
* @param bucketsToJoin The buckets to join together. The size of this array should always be either one or two.
*/
- JoinOperation(const vespalib::string * clusterName,
+ JoinOperation(const ClusterContext& cluster_ctx,
const BucketAndNodes& nodes,
const std::vector<document::BucketId>& bucketsToJoin);
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp
index 51883053603..7a1529606b0 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp
@@ -228,7 +228,7 @@ MergeOperation::deleteSourceOnlyNodes(
if (!sourceOnlyNodes.empty()) {
_removeOperation = std::make_unique<RemoveBucketOperation>(
- &_manager->getDistributorComponent().getClusterName(),
+ _manager->getDistributorComponent().cluster_context(),
BucketAndNodes(getBucket(), sourceOnlyNodes));
// Must not send removes to source only copies if something has caused
// pending load to the copy after the merge was sent!
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/removebucketoperation.h b/storage/src/vespa/storage/distributor/operations/idealstate/removebucketoperation.h
index 5efc7e15a81..5b79a465f4e 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/removebucketoperation.h
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/removebucketoperation.h
@@ -11,8 +11,8 @@ class PendingMessageTracker;
class RemoveBucketOperation : public IdealStateOperation
{
public:
- RemoveBucketOperation(const vespalib::string * clusterName, const BucketAndNodes& nodes)
- : IdealStateOperation(nodes), _tracker(clusterName)
+ RemoveBucketOperation(const ClusterContext &cluster_context, const BucketAndNodes& nodes)
+ : IdealStateOperation(nodes), _tracker(cluster_context)
{}
/**
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp
index caca8264ff9..f05feae6dab 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp
@@ -10,11 +10,11 @@ LOG_SETUP(".distributor.operation.idealstate.setactive");
namespace storage::distributor {
-SetBucketStateOperation::SetBucketStateOperation(const vespalib::string * clusterName,
+SetBucketStateOperation::SetBucketStateOperation(const ClusterContext &cluster_ctx,
const BucketAndNodes& nodes,
const std::vector<uint16_t>& wantedActiveNodes)
: IdealStateOperation(nodes),
- _tracker(clusterName),
+ _tracker(cluster_ctx),
_wantedActiveNodes(wantedActiveNodes)
{ }
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.h b/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.h
index 40134b83f5e..1c818f9198d 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.h
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.h
@@ -9,7 +9,7 @@ namespace storage::distributor {
class SetBucketStateOperation : public IdealStateOperation
{
public:
- SetBucketStateOperation(const vespalib::string * clusterName,
+ SetBucketStateOperation(const ClusterContext& cluster_ctx,
const BucketAndNodes& nodes,
const std::vector<uint16_t>& wantedActiveNodes);
~SetBucketStateOperation() override;
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp
index 3422c2e8f7b..2b3c80f9401 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp
@@ -11,10 +11,10 @@ LOG_SETUP(".distributor.operation.idealstate.split");
using namespace storage::distributor;
-SplitOperation::SplitOperation(const vespalib::string * clusterName, const BucketAndNodes& nodes,
+SplitOperation::SplitOperation(const ClusterContext &cluster_ctx, const BucketAndNodes& nodes,
uint32_t maxBits, uint32_t splitCount, uint32_t splitSize)
: IdealStateOperation(nodes),
- _tracker(clusterName),
+ _tracker(cluster_ctx),
_maxBits(maxBits),
_splitCount(splitCount),
_splitSize(splitSize)
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.h b/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.h
index 247083c6c07..1bb82c2a39e 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.h
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.h
@@ -9,7 +9,8 @@ namespace storage::distributor {
class SplitOperation : public IdealStateOperation
{
public:
- SplitOperation(const vespalib::string * clusterName, const BucketAndNodes& nodes,
+ SplitOperation(const ClusterContext& cluster_ctx,
+ const BucketAndNodes& nodes,
uint32_t maxBits, uint32_t splitCount, uint32_t splitSize);
SplitOperation(const SplitOperation &) = delete;
SplitOperation & operator = (const SplitOperation &) = delete;
diff --git a/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp b/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp
index 2cba5c0f3c7..10e69bcfd14 100644
--- a/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp
+++ b/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp
@@ -18,7 +18,7 @@ PersistenceMessageTrackerImpl::PersistenceMessageTrackerImpl(
DistributorNodeContext& node_ctx,
DistributorOperationContext& op_ctx,
api::Timestamp revertTimestamp)
- : MessageTracker(&node_ctx.cluster_name()),
+ : MessageTracker(node_ctx),
_metric(metric),
_reply(std::move(reply)),
_op_ctx(op_ctx),
diff --git a/storage/src/vespa/storage/distributor/statecheckers.cpp b/storage/src/vespa/storage/distributor/statecheckers.cpp
index bdd0d873aba..a2342545ae1 100644
--- a/storage/src/vespa/storage/distributor/statecheckers.cpp
+++ b/storage/src/vespa/storage/distributor/statecheckers.cpp
@@ -83,7 +83,7 @@ SplitBucketStateChecker::generateMinimumBucketSplitOperation(
StateChecker::Context& c)
{
auto so = std::make_unique<SplitOperation>(
- &c.component.getClusterName(),
+ c.component.cluster_context(),
BucketAndNodes(c.getBucket(), c.entry->getNodes()),
c.distributorConfig.getMinimalBucketSplit(),
0,
@@ -101,7 +101,7 @@ SplitBucketStateChecker::generateMaxSizeExceededSplitOperation(
StateChecker::Context& c)
{
auto so = std::make_unique<SplitOperation>(
- &c.component.getClusterName(),
+ c.component.cluster_context(),
BucketAndNodes(c.getBucket(), c.entry->getNodes()),
58,
c.distributorConfig.getSplitCount(),
@@ -464,7 +464,7 @@ JoinBucketsStateChecker::check(StateChecker::Context& c)
}
sourceBuckets.push_back(c.getBucketId());
auto op = std::make_unique<JoinOperation>(
- &c.component.getClusterName(),
+ c.component.cluster_context(),
BucketAndNodes(joinedBucket, c.entry->getNodes()),
sourceBuckets);
op->setPriority(c.distributorConfig.getMaintenancePriorities().joinBuckets);
@@ -568,7 +568,7 @@ SplitInconsistentStateChecker::check(StateChecker::Context& c)
}
auto op = std::make_unique<SplitOperation>(
- &c.component.getClusterName(),
+ c.component.cluster_context(),
BucketAndNodes(c.getBucket(), c.entry->getNodes()),
getHighestUsedBits(c.entries),
0,
@@ -1006,7 +1006,7 @@ DeleteExtraCopiesStateChecker::check(StateChecker::Context& c)
if (!removedCopies.empty()) {
auto ro = std::make_unique<RemoveBucketOperation>(
- &c.component.getClusterName(),
+ c.component.cluster_context(),
BucketAndNodes(c.getBucket(), removedCopies));
ro->setPriority(c.distributorConfig.getMaintenancePriorities().deleteBucketCopy);
@@ -1106,7 +1106,7 @@ BucketStateStateChecker::check(StateChecker::Context& c)
activeNodeIndexes.push_back(activeNodes[i]._nodeIndex);
}
auto op = std::make_unique<SetBucketStateOperation>(
- &c.component.getClusterName(),
+ c.component.cluster_context(),
BucketAndNodes(c.getBucket(), operationNodes),
activeNodeIndexes);
@@ -1143,7 +1143,7 @@ GarbageCollectionStateChecker::check(Context& c)
{
if (needsGarbageCollection(c)) {
auto op = std::make_unique<GarbageCollectionOperation>(
- &c.component.getClusterName(),
+ c.component.cluster_context(),
BucketAndNodes(c.getBucket(), c.entry->getNodes()));
vespalib::asciistream reason;
diff --git a/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h b/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h
index be3c89fe176..85edfe78c28 100644
--- a/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h
+++ b/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h
@@ -38,7 +38,6 @@ public:
StorageComponentRegisterImpl();
~StorageComponentRegisterImpl() override;
- const vespalib::string& getClusterName() const { return _clusterName; }
const lib::NodeType& getNodeType() const { return *_nodeType; }
uint16_t getIndex() const { return _index; }
std::shared_ptr<const document::DocumentTypeRepo> getTypeRepo() { return _docTypeRepo; }
diff --git a/storage/src/vespa/storage/persistence/bucketownershipnotifier.cpp b/storage/src/vespa/storage/persistence/bucketownershipnotifier.cpp
index 0ff12ac71bc..4178b2bb947 100644
--- a/storage/src/vespa/storage/persistence/bucketownershipnotifier.cpp
+++ b/storage/src/vespa/storage/persistence/bucketownershipnotifier.cpp
@@ -59,7 +59,8 @@ BucketOwnershipNotifier::sendNotifyBucketToDistributor(
}
auto notifyCmd = std::make_shared<api::NotifyBucketChangeCommand>(bucket, infoToSend);
- notifyCmd->setAddress(api::StorageMessageAddress::create(&_component.getClusterName(), lib::NodeType::DISTRIBUTOR, distributorIndex));
+ const auto *cluster_np = _component.cluster_context().cluster_name_ptr();
+ notifyCmd->setAddress(api::StorageMessageAddress::create(cluster_np, lib::NodeType::DISTRIBUTOR, distributorIndex));
notifyCmd->setSourceIndex(_component.getIndex());
LOG(debug,
"Sending notify to distributor %u: %s",
diff --git a/storage/src/vespa/storage/persistence/mergehandler.cpp b/storage/src/vespa/storage/persistence/mergehandler.cpp
index b3d3b1b2737..d4d4dd5e62b 100644
--- a/storage/src/vespa/storage/persistence/mergehandler.cpp
+++ b/storage/src/vespa/storage/persistence/mergehandler.cpp
@@ -19,11 +19,11 @@ LOG_SETUP(".persistence.mergehandler");
namespace storage {
MergeHandler::MergeHandler(PersistenceUtil& env, spi::PersistenceProvider& spi,
- const vespalib::string & clusterName, const framework::Clock & clock,
+ const ClusterContext& cluster_context, const framework::Clock & clock,
uint32_t maxChunkSize,
uint32_t commonMergeChainOptimalizationMinimumSize)
: _clock(clock),
- _clusterName(clusterName),
+ _cluster_context(cluster_context),
_env(env),
_spi(spi),
_maxChunkSize(maxChunkSize),
@@ -706,7 +706,7 @@ MergeHandler::processBucketMerge(const spi::Bucket& bucket, MergeStatus& status,
assert(nodes.size() > 1);
cmd = std::make_shared<api::ApplyBucketDiffCommand>(bucket.getBucket(), nodes);
- cmd->setAddress(createAddress(&_clusterName, nodes[1].index));
+ cmd->setAddress(createAddress(_cluster_context.cluster_name_ptr(), nodes[1].index));
findCandidates(status,
active_nodes_mask,
true,
@@ -782,7 +782,7 @@ MergeHandler::processBucketMerge(const spi::Bucket& bucket, MergeStatus& status,
}
assert(nodes.size() > 1);
cmd = std::make_shared<api::ApplyBucketDiffCommand>(bucket.getBucket(), nodes);
- cmd->setAddress(createAddress(&_clusterName, nodes[1].index));
+ cmd->setAddress(createAddress(_cluster_context.cluster_name_ptr(), nodes[1].index));
// Add all the metadata, and thus use big limit. Max
// data to fetch parameter will control amount added.
findCandidates(status, active_nodes_mask, true, e.first, newMask, *cmd);
@@ -795,7 +795,7 @@ MergeHandler::processBucketMerge(const spi::Bucket& bucket, MergeStatus& status,
// merge to merge the remaining data.
if ( ! cmd ) {
cmd = std::make_shared<api::ApplyBucketDiffCommand>(bucket.getBucket(), status.nodeList);
- cmd->setAddress(createAddress(&_clusterName, status.nodeList[1].index));
+ cmd->setAddress(createAddress(_cluster_context.cluster_name_ptr(), status.nodeList[1].index));
findCandidates(status, active_nodes_mask, false, 0, 0, *cmd);
}
cmd->setPriority(status.context.getPriority());
@@ -901,7 +901,7 @@ MergeHandler::handleMergeBucket(api::MergeBucketCommand& cmd, MessageTracker::UP
bucket.toString().c_str(),
s->nodeList[1].index,
uint32_t(cmd2->getDiff().size()));
- cmd2->setAddress(createAddress(&_clusterName, s->nodeList[1].index));
+ cmd2->setAddress(createAddress(_cluster_context.cluster_name_ptr(), s->nodeList[1].index));
cmd2->setPriority(s->context.getPriority());
cmd2->setTimeout(s->timeout);
cmd2->setSourceIndex(cmd.getSourceIndex());
@@ -1111,7 +1111,7 @@ MergeHandler::handleGetBucketDiff(api::GetBucketDiffCommand& cmd, MessageTracker
bucket.toString().c_str(), cmd.getNodes()[index + 1].index,
local.size() - remote.size());
auto cmd2 = std::make_shared<api::GetBucketDiffCommand>(bucket.getBucket(), cmd.getNodes(), cmd.getMaxTimestamp());
- cmd2->setAddress(createAddress(&_clusterName, cmd.getNodes()[index + 1].index));
+ cmd2->setAddress(createAddress(_cluster_context.cluster_name_ptr(), cmd.getNodes()[index + 1].index));
cmd2->getDiff().swap(local);
cmd2->setPriority(cmd.getPriority());
cmd2->setTimeout(cmd.getTimeout());
@@ -1293,7 +1293,7 @@ MergeHandler::handleApplyBucketDiff(api::ApplyBucketDiffCommand& cmd, MessageTra
LOG(spam, "Sending ApplyBucketDiff for %s on to node %d",
bucket.toString().c_str(), cmd.getNodes()[index + 1].index);
auto cmd2 = std::make_shared<api::ApplyBucketDiffCommand>(bucket.getBucket(), cmd.getNodes());
- cmd2->setAddress(createAddress(&_clusterName, cmd.getNodes()[index + 1].index));
+ cmd2->setAddress(createAddress(_cluster_context.cluster_name_ptr(), cmd.getNodes()[index + 1].index));
cmd2->getDiff().swap(cmd.getDiff());
cmd2->setPriority(cmd.getPriority());
cmd2->setTimeout(cmd.getTimeout());
diff --git a/storage/src/vespa/storage/persistence/mergehandler.h b/storage/src/vespa/storage/persistence/mergehandler.h
index 25b7f281ef0..17a961a3982 100644
--- a/storage/src/vespa/storage/persistence/mergehandler.h
+++ b/storage/src/vespa/storage/persistence/mergehandler.h
@@ -17,6 +17,7 @@
#include <vespa/persistence/spi/bucket.h>
#include <vespa/persistence/spi/docentry.h>
#include <vespa/storageapi/message/bucket.h>
+#include <vespa/storage/common/cluster_context.h>
#include <vespa/storage/common/messagesender.h>
namespace storage {
@@ -39,7 +40,7 @@ public:
};
MergeHandler(PersistenceUtil& env, spi::PersistenceProvider& spi,
- const vespalib::string & clusterName, const framework::Clock & clock,
+ const ClusterContext& cluster_context, const framework::Clock & clock,
uint32_t maxChunkSize = 4190208,
uint32_t commonMergeChainOptimalizationMinimumSize = 64);
@@ -67,7 +68,7 @@ public:
private:
const framework::Clock &_clock;
- const vespalib::string &_clusterName;
+ const ClusterContext &_cluster_context;
PersistenceUtil &_env;
spi::PersistenceProvider &_spi;
const uint32_t _maxChunkSize;
diff --git a/storage/src/vespa/storage/persistence/persistencehandler.cpp b/storage/src/vespa/storage/persistence/persistencehandler.cpp
index d992df61780..cbe5454f4e7 100644
--- a/storage/src/vespa/storage/persistence/persistencehandler.cpp
+++ b/storage/src/vespa/storage/persistence/persistencehandler.cpp
@@ -17,7 +17,7 @@ PersistenceHandler::PersistenceHandler(vespalib::ISequencedTaskExecutor & sequen
: _clock(component.getClock()),
_env(component, filestorHandler, metrics, provider),
_processAllHandler(_env, provider),
- _mergeHandler(_env, provider, component.getClusterName(), _clock,
+ _mergeHandler(_env, provider, component.cluster_context(), _clock,
cfg.bucketMergeChunkSize,
cfg.commonMergeChainOptimalizationMinimumSize),
_asyncHandler(_env, provider, sequencedExecutor, component.getBucketIdFactory()),
diff --git a/storage/src/vespa/storage/storageserver/communicationmanager.cpp b/storage/src/vespa/storage/storageserver/communicationmanager.cpp
index 7a3dd16bbd1..6021673d472 100644
--- a/storage/src/vespa/storage/storageserver/communicationmanager.cpp
+++ b/storage/src/vespa/storage/storageserver/communicationmanager.cpp
@@ -56,7 +56,7 @@ CommunicationManager::receiveStorageReply(const std::shared_ptr<api::StorageRepl
namespace {
vespalib::string getNodeId(StorageComponent& sc) {
vespalib::asciistream ost;
- ost << sc.getClusterName() << "/" << sc.getNodeType() << "/" << sc.getIndex();
+ ost << sc.cluster_context().cluster_name() << "/" << sc.getNodeType() << "/" << sc.getIndex();
return ost.str();
}
diff --git a/storage/src/vespa/storage/storageserver/mergethrottler.cpp b/storage/src/vespa/storage/storageserver/mergethrottler.cpp
index 37a86413500..2984ba27344 100644
--- a/storage/src/vespa/storage/storageserver/mergethrottler.cpp
+++ b/storage/src/vespa/storage/storageserver/mergethrottler.cpp
@@ -373,7 +373,8 @@ MergeThrottler::forwardCommandToNode(
mergeCmd.getMaxTimestamp(),
mergeCmd.getClusterStateVersion(),
newChain));
- fwdMerge->setAddress(api::StorageMessageAddress::create(&_component.getClusterName(), lib::NodeType::STORAGE, nodeIndex));
+ const auto *cluster_np = _component.cluster_context().cluster_name_ptr();
+ fwdMerge->setAddress(api::StorageMessageAddress::create(cluster_np, lib::NodeType::STORAGE, nodeIndex));
fwdMerge->setSourceIndex(mergeCmd.getSourceIndex());
fwdMerge->setPriority(mergeCmd.getPriority());
fwdMerge->setTimeout(mergeCmd.getTimeout());