diff options
author | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2021-10-12 13:47:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-12 13:47:54 +0200 |
commit | bdd99f74125262db1cca095057d50a29a6b59d39 (patch) | |
tree | b0191e9a799b19d2d9ef53a5dbcddf7e4476bbc8 /storage | |
parent | 620a888b08526826c15cb47a3fdb04647bbc1114 (diff) | |
parent | 0a7933068aa4ae8a415a59b963dd5ddd9b91d442 (diff) |
Merge pull request #19517 from vespa-engine/toregge/remove-dead-code-in-put-operation
Remove dead code in PutOperation.
Diffstat (limited to 'storage')
3 files changed, 0 insertions, 114 deletions
diff --git a/storage/src/tests/distributor/putoperationtest.cpp b/storage/src/tests/distributor/putoperationtest.cpp index b75f5ec3d6f..6ad67ab91c2 100644 --- a/storage/src/tests/distributor/putoperationtest.cpp +++ b/storage/src/tests/distributor/putoperationtest.cpp @@ -49,7 +49,6 @@ public: } document::BucketId createAndSendSampleDocument(vespalib::duration timeout); - std::string getNodes(const std::string& infoString); void sendReply(int idx = -1, api::ReturnCode::Result result @@ -455,68 +454,6 @@ TEST_F(PutOperationTest, update_correct_bucket_on_remapped_put) { dumpBucket(document::BucketId(17, 13))); } -BucketInfo -parseBucketInfoString(const std::string& nodeList) { - vespalib::StringTokenizer tokenizer(nodeList, ","); - - BucketInfo entry; - for (uint32_t i = 0; i < tokenizer.size(); i++) { - vespalib::StringTokenizer tokenizer2(tokenizer[i], "-"); - int node = atoi(tokenizer2[0].data()); - int size = atoi(tokenizer2[1].data()); - bool trusted = (tokenizer2[2] == "true"); - - entry.addNode(BucketCopy(0, - node, - api::BucketInfo(size, size * 1000, size * 2000)) - .setTrusted(trusted), - toVector<uint16_t>(0)); - } - - return entry; -} - -std::string -PutOperationTest::getNodes(const std::string& infoString) { - Document::SP doc(createDummyDocument("test", "uri")); - document::BucketId bid(operation_context().make_split_bit_constrained_bucket_id(doc->getId())); - - BucketInfo entry = parseBucketInfoString(infoString); - - std::ostringstream ost; - - std::vector<uint16_t> targetNodes; - std::vector<uint16_t> createNodes; - PutOperation::getTargetNodes(getDistributorBucketSpace().get_ideal_service_layer_nodes_bundle(bid).get_available_nodes(), - targetNodes, createNodes, entry, 2); - - ost << "target( "; - for (uint32_t i = 0; i < targetNodes.size(); i++) { - ost << targetNodes[i] << " "; - } - ost << ") create( "; - for (uint32_t i = 0; i < createNodes.size(); i++) { - ost << createNodes[i] << " "; - } - ost << ")"; - - return ost.str(); -} - -TEST_F(PutOperationTest, target_nodes) { - setup_stripe(2, 6, "storage:6 distributor:1"); - - // Ideal state of bucket is 1,2. - ASSERT_EQ("target( 1 2 ) create( 1 2 )", getNodes("")); - ASSERT_EQ("target( 1 2 ) create( 2 )", getNodes("1-1-true")); - ASSERT_EQ("target( 1 2 ) create( 2 )", getNodes("1-1-false")); - ASSERT_EQ("target( 3 4 5 ) create( )", getNodes("3-1-true,4-1-true,5-1-true")); - ASSERT_EQ("target( 3 4 ) create( )", getNodes("3-2-true,4-2-true,5-1-false")); - ASSERT_EQ("target( 1 3 4 ) create( )", getNodes("3-2-true,4-2-true,1-1-false")); - ASSERT_EQ("target( 4 5 ) create( )", getNodes("4-2-false,5-1-false")); - ASSERT_EQ("target( 1 4 ) create( 1 )", getNodes("4-1-true")); -} - TEST_F(PutOperationTest, replica_not_resurrected_in_db_when_node_down_in_active_state) { setup_stripe(Redundancy(3), NodeCount(3), "distributor:1 storage:3"); diff --git a/storage/src/vespa/storage/distributor/operations/external/putoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/putoperation.cpp index cecca947cce..e91df1da51e 100644 --- a/storage/src/vespa/storage/distributor/operations/external/putoperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/external/putoperation.cpp @@ -36,55 +36,6 @@ PutOperation::PutOperation(const DistributorNodeContext& node_ctx, { } -namespace { - -bool hasNode(const std::vector<uint16_t>& vec, uint16_t value) { - for (uint32_t i = 0; i < vec.size(); i++) { - if (vec[i] == value) { - return true; - } - } - - return false; -}; - -} - -void -PutOperation::getTargetNodes(const std::vector<uint16_t>& idealNodes, std::vector<uint16_t>& targetNodes, - std::vector<uint16_t>& createNodes, const BucketInfo& bucketInfo, uint32_t redundancy) -{ - // First insert all nodes that are trusted or already in the ideal state. - for (uint32_t i = 0; i < bucketInfo.getNodeCount(); i++) { - if (bucketInfo.getNodeRef(i).trusted() || hasNode(idealNodes,bucketInfo.getNodeRef(i).getNode())) { - LOG(spam, "Adding target node %u with %s since it's trusted or in ideal state", - i, bucketInfo.getNodeRef(i).toString().c_str()); - targetNodes.push_back(bucketInfo.getNodeRef(i).getNode()); - } - } - - // Then insert all nodes that already exist if we need them. - for (uint32_t i = 0; targetNodes.size() < redundancy && i < bucketInfo.getNodeCount(); i++) { - if (!hasNode(targetNodes, bucketInfo.getNodeRef(i).getNode())) { - LOG(spam, "Adding target node %u with %s since it already exists", - i, bucketInfo.getNodeRef(i).toString().c_str()); - targetNodes.push_back(bucketInfo.getNodeRef(i).getNode()); - } - } - - // Then add stuff from ideal state. - for (uint32_t i = 0; targetNodes.size() < redundancy && i < idealNodes.size(); i++) { - if (!hasNode(targetNodes, idealNodes[i])) { - targetNodes.push_back(idealNodes[i]); - LOG(spam, "Adding target+create node %u it's in ideal state", idealNodes[i]); - createNodes.push_back(idealNodes[i]); - } - } - - std::sort(targetNodes.begin(), targetNodes.end()); - std::sort(createNodes.begin(), createNodes.end()); -} - void PutOperation::insertDatabaseEntryAndScheduleCreateBucket(const OperationTargetList& copies, bool setOneActive, const api::StorageCommand& originalCommand, diff --git a/storage/src/vespa/storage/distributor/operations/external/putoperation.h b/storage/src/vespa/storage/distributor/operations/external/putoperation.h index d6d24815f60..61e4678496f 100644 --- a/storage/src/vespa/storage/distributor/operations/external/putoperation.h +++ b/storage/src/vespa/storage/distributor/operations/external/putoperation.h @@ -36,8 +36,6 @@ public: void onReceive(DistributorStripeMessageSender& sender, const std::shared_ptr<api::StorageReply> &) override; void onClose(DistributorStripeMessageSender& sender) override; - static void getTargetNodes(const std::vector<uint16_t>& idealNodes, std::vector<uint16_t>& targetNodes, - std::vector<uint16_t>& createNodes, const BucketInfo& bucketInfo, uint32_t redundancy); private: PersistenceMessageTrackerImpl _trackerInstance; PersistenceMessageTracker& _tracker; |