diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-12-11 19:51:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-11 19:51:00 +0100 |
commit | c5bb55c8f86e5157b5297a43ffb0596f17ffa24c (patch) | |
tree | 23dd333ee866380e837c5fdf65f01bee9e4f03c0 /storage | |
parent | 28faf320c0257343d95ab55d933a49c8742d7050 (diff) | |
parent | da9105b4e8f2b3553bdc2f9731459f55ca1314b1 (diff) |
Merge pull request #15798 from vespa-engine/balder/wire-cluster-name-as-reference-all-the-way
- Wire the clustername through as a reference to avoid referencing te…
Diffstat (limited to 'storage')
20 files changed, 100 insertions, 98 deletions
diff --git a/storage/src/tests/distributor/bucketstateoperationtest.cpp b/storage/src/tests/distributor/bucketstateoperationtest.cpp index 60c17eb6a17..a692ddd5cac 100644 --- a/storage/src/tests/distributor/bucketstateoperationtest.cpp +++ b/storage/src/tests/distributor/bucketstateoperationtest.cpp @@ -43,7 +43,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(&_Storage, bucketAndNodes, active); op.setIdealStateManager(&getIdealStateManager()); op.start(_sender, framework::MilliSecTime(0)); @@ -79,7 +79,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(&_Storage, bucketAndNodes, active); op.setIdealStateManager(&getIdealStateManager()); op.start(_sender, framework::MilliSecTime(0)); @@ -134,7 +134,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(&_Storage, bucketAndNodes, active); op.setIdealStateManager(&getIdealStateManager()); op.start(_sender, framework::MilliSecTime(0)); @@ -176,7 +176,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(&_Storage, bucketAndNodes, active); op.setIdealStateManager(&getIdealStateManager()); op.start(_sender, framework::MilliSecTime(0)); diff --git a/storage/src/tests/distributor/garbagecollectiontest.cpp b/storage/src/tests/distributor/garbagecollectiontest.cpp index 776cfc14d84..e360578abec 100644 --- a/storage/src/tests/distributor/garbagecollectiontest.cpp +++ b/storage/src/tests/distributor/garbagecollectiontest.cpp @@ -14,6 +14,10 @@ using namespace ::testing; namespace storage::distributor { +namespace { + vespalib::string _Storage("storage"); +} + struct GarbageCollectionOperationTest : Test, DistributorTestUtil { void SetUp() override { createLinks(); @@ -29,7 +33,7 @@ struct GarbageCollectionOperationTest : Test, DistributorTestUtil { std::shared_ptr<GarbageCollectionOperation> create_op() { auto op = std::make_shared<GarbageCollectionOperation>( - "storage",BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)), + &_Storage,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 d5374907723..a592ce37910 100644 --- a/storage/src/tests/distributor/idealstatemanagertest.cpp +++ b/storage/src/tests/distributor/idealstatemanagertest.cpp @@ -195,14 +195,14 @@ TEST_F(IdealStateManagerTest, block_ideal_state_ops_on_full_request_bucket_info) } { - RemoveBucketOperation op("storage", + RemoveBucketOperation op(&_Storage, 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(&_Storage, BucketAndNodes(makeDocumentBucket(bid), toVector<uint16_t>(3, 5))); EXPECT_FALSE(op.isBlocked(tracker, op_seq)); } @@ -215,7 +215,7 @@ TEST_F(IdealStateManagerTest, block_ideal_state_ops_on_full_request_bucket_info) } { - RemoveBucketOperation op("storage", + RemoveBucketOperation op(&_Storage, BucketAndNodes(makeDocumentBucket(bid), toVector<uint16_t>(7))); EXPECT_FALSE(op.isBlocked(tracker, op_seq)); } @@ -234,7 +234,7 @@ TEST_F(IdealStateManagerTest, block_check_for_all_operations_to_specific_bucket) tracker.insert(msg); } { - RemoveBucketOperation op("storage", + RemoveBucketOperation op(&_Storage, BucketAndNodes(makeDocumentBucket(bid), toVector<uint16_t>(7))); // Not blocked for exact node match. EXPECT_FALSE(checkBlock(op, makeDocumentBucket(bid), tracker, op_seq)); @@ -258,7 +258,7 @@ TEST_F(IdealStateManagerTest, block_operations_with_locked_buckets) { auto token = op_seq.try_acquire(bucket); EXPECT_TRUE(token.valid()); { - RemoveBucketOperation op("storage", BucketAndNodes(bucket, toVector<uint16_t>(0))); + RemoveBucketOperation op(&_Storage, 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 a918a29c609..12ad52e9d5e 100644 --- a/storage/src/tests/distributor/joinbuckettest.cpp +++ b/storage/src/tests/distributor/joinbuckettest.cpp @@ -27,6 +27,10 @@ struct JoinOperationTest : Test, DistributorTestUtil { } }; +namespace { + vespalib::string _Storage("storage"); +} + TEST_F(JoinOperationTest, simple) { getConfig().setJoinCount(100); getConfig().setJoinSize(1000); @@ -36,7 +40,7 @@ TEST_F(JoinOperationTest, simple) { enableDistributorClusterState("distributor:1 storage:1"); - JoinOperation op("storage", + JoinOperation op(&_Storage, BucketAndNodes(makeDocumentBucket(document::BucketId(32, 0)), toVector<uint16_t>(0)), toVector(document::BucketId(33, 1), @@ -91,7 +95,7 @@ TEST_F(JoinOperationTest, send_sparse_joins_to_nodes_without_both_source_buckets enableDistributorClusterState("distributor:1 storage:2"); - JoinOperation op("storage", + JoinOperation op(&_Storage, 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 e2bf867ad11..26be1fc532e 100644 --- a/storage/src/tests/distributor/removebucketoperationtest.cpp +++ b/storage/src/tests/distributor/removebucketoperationtest.cpp @@ -15,6 +15,10 @@ using namespace ::testing; namespace storage::distributor { +namespace { + vespalib::string _Storage("storage"); +} + struct RemoveBucketOperationTest : Test, DistributorTestUtil { void SetUp() override { createLinks(); @@ -33,7 +37,7 @@ TEST_F(RemoveBucketOperationTest, simple) { setRedundancy(1); enableDistributorClusterState("distributor:1 storage:3"); - RemoveBucketOperation op("storage", + RemoveBucketOperation op(&_Storage, BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)), toVector<uint16_t>(1,2))); op.setIdealStateManager(&getIdealStateManager()); @@ -65,7 +69,7 @@ TEST_F(RemoveBucketOperationTest, bucket_info_mismatch_failure) { enableDistributorClusterState("distributor:1 storage:2"); - RemoveBucketOperation op("storage", + RemoveBucketOperation op(&_Storage, BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)), toVector<uint16_t>(1))); op.setIdealStateManager(&getIdealStateManager()); @@ -100,7 +104,7 @@ TEST_F(RemoveBucketOperationTest, fail_with_invalid_bucket_info) { enableDistributorClusterState("distributor:1 storage:2"); - RemoveBucketOperation op("storage", + RemoveBucketOperation op(&_Storage, 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 9bb2e8b04a7..9cb5fef600f 100644 --- a/storage/src/tests/distributor/splitbuckettest.cpp +++ b/storage/src/tests/distributor/splitbuckettest.cpp @@ -56,7 +56,7 @@ TEST_F(SplitOperationTest, simple) { insertBucketInfo(document::BucketId(16, 1), 0, 0xabc, 1000, tooLargeBucketSize, 250); - SplitOperation op("storage", + SplitOperation op(&_Storage, 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(&_Storage, 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(&_Storage, 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(&_Storage, BucketAndNodes(makeDocumentBucket(joinTarget), toVector<uint16_t>(0)), maxSplitBits, splitCount, @@ -309,7 +309,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(&_Storage, BucketAndNodes(makeDocumentBucket(source_bucket), toVector<uint16_t>(0)), maxSplitBits, splitCount, splitByteSize); EXPECT_FALSE(op.isBlocked(tracker, op_seq)); diff --git a/storage/src/vespa/storage/distributor/messagetracker.cpp b/storage/src/vespa/storage/distributor/messagetracker.cpp index 298ec028d71..54c85375f86 100644 --- a/storage/src/vespa/storage/distributor/messagetracker.cpp +++ b/storage/src/vespa/storage/distributor/messagetracker.cpp @@ -9,7 +9,7 @@ LOG_SETUP(".messagetracker"); namespace storage::distributor { -MessageTracker::MessageTracker(const std::string& clusterName) +MessageTracker::MessageTracker(const vespalib::string * clusterName) : _clusterName(clusterName) {} @@ -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(_clusterName, 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 44fa86a4f9e..ccc856a7032 100644 --- a/storage/src/vespa/storage/distributor/messagetracker.h +++ b/storage/src/vespa/storage/distributor/messagetracker.h @@ -24,9 +24,11 @@ public: uint16_t _target; }; - MessageTracker(const std::string& clusterName); + MessageTracker(const vespalib::string * clusterName); MessageTracker(MessageTracker &&) = default; MessageTracker & operator = (MessageTracker &&) = default; + MessageTracker(const MessageTracker &) = delete; + MessageTracker & operator = (const MessageTracker &) = delete; ~MessageTracker(); void queueCommand(std::shared_ptr<api::BucketCommand> msg, uint16_t target) { @@ -50,7 +52,7 @@ protected: // Keeps track of which node a message was sent to. std::map<uint64_t, uint16_t> _sentMessages; - vespalib::string _clusterName; + const vespalib::string * _clusterName; }; } diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp index fc127c2e0eb..ae337696527 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp @@ -12,7 +12,7 @@ LOG_SETUP(".distributor.operation.idealstate.remove"); namespace storage::distributor { -GarbageCollectionOperation::GarbageCollectionOperation(const std::string& clusterName, const BucketAndNodes& nodes) +GarbageCollectionOperation::GarbageCollectionOperation(const vespalib::string * clusterName, const BucketAndNodes& nodes) : IdealStateOperation(nodes), _tracker(clusterName), _replica_info(), diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h index 28de9592a63..ee207214859 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h +++ b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h @@ -13,8 +13,8 @@ class PendingMessageTracker; class GarbageCollectionOperation : public IdealStateOperation { public: - GarbageCollectionOperation(const std::string& clusterName, const BucketAndNodes& nodes); - ~GarbageCollectionOperation(); + GarbageCollectionOperation(const vespalib::string * clusterName, const BucketAndNodes& nodes); + ~GarbageCollectionOperation() override; void onStart(DistributorMessageSender& sender) override; void onReceive(DistributorMessageSender& sender, const std::shared_ptr<api::StorageReply> &) override; diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp index 292df7c5e07..1fee6942dfb 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp @@ -3,12 +3,23 @@ #include "joinoperation.h" #include <vespa/storageapi/message/bucketsplitting.h> #include <vespa/storage/distributor/distributor_bucket_space.h> +#include <vespa/storage/distributor/idealstatemanager.h> #include <climits> #include <vespa/log/bufferedlogger.h> LOG_SETUP(".distributor.operation.idealstate.join"); using namespace storage::distributor; +JoinOperation::JoinOperation(const vespalib::string * clusterName, + const BucketAndNodes& nodes, + const std::vector<document::BucketId>& bucketsToJoin) + : IdealStateOperation(nodes), + _tracker(clusterName), + _bucketsToJoin(bucketsToJoin) +{} + +JoinOperation::~JoinOperation() = default; + void JoinOperation::onStart(DistributorMessageSender& sender) { diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.h b/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.h index 86372231058..9c683d32102 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.h +++ b/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.h @@ -1,12 +1,10 @@ // 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/distributor/idealstatemanager.h> -#include <vespa/storage/distributor/operations/idealstate/idealstateoperation.h> +#include "idealstateoperation.h" #include <vespa/storage/distributor/messagetracker.h> -namespace storage { -namespace distributor { +namespace storage::distributor { class JoinOperation : public IdealStateOperation { @@ -18,15 +16,11 @@ 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 std::string& clusterName, + JoinOperation(const vespalib::string * clusterName, const BucketAndNodes& nodes, - const std::vector<document::BucketId>& bucketsToJoin) - : IdealStateOperation(nodes), - _tracker(clusterName), - _bucketsToJoin(bucketsToJoin) - {}; + const std::vector<document::BucketId>& bucketsToJoin); - ~JoinOperation() {} + ~JoinOperation() override; void onStart(DistributorMessageSender& sender) override; @@ -62,6 +56,4 @@ protected: std::vector<document::BucketId> _bucketsToJoin; }; -} // distributor -} // storage - +} diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp index 16b510c22be..51883053603 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp @@ -227,16 +227,13 @@ MergeOperation::deleteSourceOnlyNodes( getBucketId().toString().c_str()); if (!sourceOnlyNodes.empty()) { - _removeOperation.reset( - new RemoveBucketOperation( - _manager->getDistributorComponent().getClusterName(), - BucketAndNodes(getBucket(), sourceOnlyNodes))); + _removeOperation = std::make_unique<RemoveBucketOperation>( + &_manager->getDistributorComponent().getClusterName(), + 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! if (_removeOperation->isBlocked(sender.getPendingMessageTracker(), sender.operation_sequencer())) { - LOG(debug, - "Source only removal for %s was blocked by a pending " - "operation", + LOG(debug, "Source only removal for %s was blocked by a pending operation", getBucketId().toString().c_str()); _ok = false; done(); diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/removebucketoperation.h b/storage/src/vespa/storage/distributor/operations/idealstate/removebucketoperation.h index 95583685836..5efc7e15a81 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/removebucketoperation.h +++ b/storage/src/vespa/storage/distributor/operations/idealstate/removebucketoperation.h @@ -11,7 +11,7 @@ class PendingMessageTracker; class RemoveBucketOperation : public IdealStateOperation { public: - RemoveBucketOperation(const std::string& clusterName, const BucketAndNodes& nodes) + RemoveBucketOperation(const vespalib::string * clusterName, const BucketAndNodes& nodes) : IdealStateOperation(nodes), _tracker(clusterName) {} diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp index 6a87688c295..caca8264ff9 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp @@ -10,7 +10,7 @@ LOG_SETUP(".distributor.operation.idealstate.setactive"); namespace storage::distributor { -SetBucketStateOperation::SetBucketStateOperation(const std::string& clusterName, +SetBucketStateOperation::SetBucketStateOperation(const vespalib::string * clusterName, const BucketAndNodes& nodes, const std::vector<uint16_t>& wantedActiveNodes) : IdealStateOperation(nodes), @@ -18,20 +18,17 @@ SetBucketStateOperation::SetBucketStateOperation(const std::string& clusterName, _wantedActiveNodes(wantedActiveNodes) { } -SetBucketStateOperation::~SetBucketStateOperation() {} +SetBucketStateOperation::~SetBucketStateOperation() = default; void SetBucketStateOperation::enqueueSetBucketStateCommand(uint16_t node, bool active) { - std::shared_ptr<api::SetBucketStateCommand> msg( - new api::SetBucketStateCommand( - getBucket(), - active - ? api::SetBucketStateCommand::ACTIVE - : api::SetBucketStateCommand::INACTIVE)); + auto msg = std::make_shared<api::SetBucketStateCommand>(getBucket(), + active + ? api::SetBucketStateCommand::ACTIVE + : api::SetBucketStateCommand::INACTIVE); LOG(debug, "Enqueuing %s for %s to node %u", active ? "Activate" : "Deactivate", - getBucketId().toString().c_str(), - node); + getBucketId().toString().c_str(), node); setCommandMeta(*msg); _tracker.queueCommand(msg, node); } diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.h b/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.h index 3fb0c81421e..40134b83f5e 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.h +++ b/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.h @@ -9,10 +9,10 @@ namespace storage::distributor { class SetBucketStateOperation : public IdealStateOperation { public: - SetBucketStateOperation(const std::string& clusterName, + SetBucketStateOperation(const vespalib::string * clusterName, const BucketAndNodes& nodes, const std::vector<uint16_t>& wantedActiveNodes); - ~SetBucketStateOperation(); + ~SetBucketStateOperation() override; void onStart(DistributorMessageSender&) override; void onReceive(DistributorMessageSender&, const std::shared_ptr<api::StorageReply>&) override; diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp index ea9cb56fae8..3422c2e8f7b 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp @@ -11,7 +11,7 @@ LOG_SETUP(".distributor.operation.idealstate.split"); using namespace storage::distributor; -SplitOperation::SplitOperation(const std::string& clusterName, const BucketAndNodes& nodes, +SplitOperation::SplitOperation(const vespalib::string * clusterName, const BucketAndNodes& nodes, uint32_t maxBits, uint32_t splitCount, uint32_t splitSize) : IdealStateOperation(nodes), _tracker(clusterName), diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.h b/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.h index 9e24852886d..247083c6c07 100644 --- a/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.h +++ b/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.h @@ -9,7 +9,7 @@ namespace storage::distributor { class SplitOperation : public IdealStateOperation { public: - SplitOperation(const std::string& clusterName, const BucketAndNodes& nodes, + SplitOperation(const vespalib::string * clusterName, const BucketAndNodes& nodes, uint32_t maxBits, uint32_t splitCount, uint32_t splitSize); SplitOperation(const SplitOperation &) = delete; SplitOperation & operator = (const SplitOperation &) = delete; @@ -19,7 +19,6 @@ public: void onReceive(DistributorMessageSender& sender, const std::shared_ptr<api::StorageReply> &) override; const char* getName() const override { return "split"; }; Type getType() const override { return SPLIT_BUCKET; } - uint32_t getMaxSplitBits() const { return _maxBits; } bool isBlocked(const PendingMessageTracker&, const OperationSequencer&) const override; bool shouldBlockThisOperation(uint32_t, uint8_t) const override; protected: @@ -28,7 +27,6 @@ protected: uint32_t _maxBits; uint32_t _splitCount; uint32_t _splitSize; - std::vector<document::BucketId> _inconsistentBuckets; }; } diff --git a/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp b/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp index cd5f1558c87..2cba5c0f3c7 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.cluster_name()), _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 9616ca018b5..bdd0d873aba 100644 --- a/storage/src/vespa/storage/distributor/statecheckers.cpp +++ b/storage/src/vespa/storage/distributor/statecheckers.cpp @@ -82,15 +82,14 @@ StateChecker::Result SplitBucketStateChecker::generateMinimumBucketSplitOperation( StateChecker::Context& c) { - IdealStateOperation::UP so(new SplitOperation( - c.component.getClusterName(), + auto so = std::make_unique<SplitOperation>( + &c.component.getClusterName(), BucketAndNodes(c.getBucket(), c.entry->getNodes()), c.distributorConfig.getMinimalBucketSplit(), 0, - 0)); + 0); - so->setPriority(c.distributorConfig.getMaintenancePriorities() - .splitDistributionBits); + so->setPriority(c.distributorConfig.getMaintenancePriorities().splitDistributionBits); so->setDetailedReason( "[Splitting bucket because the current system size requires " "a higher minimum split bit]"); @@ -101,15 +100,14 @@ StateChecker::Result SplitBucketStateChecker::generateMaxSizeExceededSplitOperation( StateChecker::Context& c) { - IdealStateOperation::UP so(new SplitOperation( - c.component.getClusterName(), + auto so = std::make_unique<SplitOperation>( + &c.component.getClusterName(), BucketAndNodes(c.getBucket(), c.entry->getNodes()), 58, c.distributorConfig.getSplitCount(), - c.distributorConfig.getSplitSize())); + c.distributorConfig.getSplitSize()); - so->setPriority(c.distributorConfig.getMaintenancePriorities() - .splitLargeBucket); + so->setPriority(c.distributorConfig.getMaintenancePriorities().splitLargeBucket); const BucketInfo& info(c.entry.getBucketInfo()); vespalib::asciistream ost; @@ -465,12 +463,11 @@ JoinBucketsStateChecker::check(StateChecker::Context& c) sourceBuckets.push_back(c.getBucketId()); } sourceBuckets.push_back(c.getBucketId()); - IdealStateOperation::UP op(new JoinOperation( - c.component.getClusterName(), + auto op = std::make_unique<JoinOperation>( + &c.component.getClusterName(), BucketAndNodes(joinedBucket, c.entry->getNodes()), - sourceBuckets)); - op->setPriority(c.distributorConfig.getMaintenancePriorities() - .joinBuckets); + sourceBuckets); + op->setPriority(c.distributorConfig.getMaintenancePriorities().joinBuckets); vespalib::asciistream ost; ost << "[Joining buckets " << sourceBuckets[1].toString() @@ -570,15 +567,14 @@ SplitInconsistentStateChecker::check(StateChecker::Context& c) return Result::noMaintenanceNeeded(); } - IdealStateOperation::UP op(new SplitOperation( - c.component.getClusterName(), + auto op = std::make_unique<SplitOperation>( + &c.component.getClusterName(), BucketAndNodes(c.getBucket(), c.entry->getNodes()), getHighestUsedBits(c.entries), 0, - 0)); + 0); - op->setPriority(c.distributorConfig.getMaintenancePriorities() - .splitInconsistentBucket); + op->setPriority(c.distributorConfig.getMaintenancePriorities().splitInconsistentBucket); op->setDetailedReason(getReason(c.getBucketId(), c.entries)); return Result::createStoredResult(std::move(op), MaintenancePriority::HIGH); } @@ -970,8 +966,7 @@ DeleteExtraCopiesStateChecker::removeRedundantEmptyOrConsistentCopies( && enoughCopiesKept(keptIdealCopies, keptNonIdealCopies, c) && !cp.active()) { - addToRemoveSet(cp, "redundant in-sync copy", - removedCopies, reasons); + addToRemoveSet(cp, "redundant in-sync copy", removedCopies, reasons); } else { ++keptNonIdealCopies; } @@ -1010,12 +1005,11 @@ DeleteExtraCopiesStateChecker::check(StateChecker::Context& c) } if (!removedCopies.empty()) { - IdealStateOperation::UP ro(new RemoveBucketOperation( - c.component.getClusterName(), - BucketAndNodes(c.getBucket(), removedCopies))); + auto ro = std::make_unique<RemoveBucketOperation>( + &c.component.getClusterName(), + BucketAndNodes(c.getBucket(), removedCopies)); - ro->setPriority(c.distributorConfig.getMaintenancePriorities() - .deleteBucketCopy); + ro->setPriority(c.distributorConfig.getMaintenancePriorities().deleteBucketCopy); ro->setDetailedReason(reasons.str()); return Result::createStoredResult(std::move(ro), MaintenancePriority::HIGH); } @@ -1112,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.getClusterName(), BucketAndNodes(c.getBucket(), operationNodes), activeNodeIndexes); @@ -1148,10 +1142,9 @@ StateChecker::Result GarbageCollectionStateChecker::check(Context& c) { if (needsGarbageCollection(c)) { - IdealStateOperation::UP op( - new GarbageCollectionOperation( - c.component.getClusterName(), - BucketAndNodes(c.getBucket(), c.entry->getNodes()))); + auto op = std::make_unique<GarbageCollectionOperation>( + &c.component.getClusterName(), + BucketAndNodes(c.getBucket(), c.entry->getNodes())); vespalib::asciistream reason; reason << "[Needs garbage collection: Last check at " |