diff options
author | Tor Egge <Tor.Egge@oath.com> | 2017-10-23 12:14:19 +0000 |
---|---|---|
committer | Tor Egge <Tor.Egge@oath.com> | 2017-10-23 12:14:19 +0000 |
commit | c2105574acbf1694e83b4b43fa8200fb48eb79b2 (patch) | |
tree | 094e665bed23596671614b6b9131a11fabbe5677 | |
parent | 116c78e48da8f099c32168c48f8fbde56a2f74a0 (diff) |
Add bucket space to request bucket info command.
11 files changed, 64 insertions, 16 deletions
diff --git a/document/src/vespa/document/test/CMakeLists.txt b/document/src/vespa/document/test/CMakeLists.txt index f16bfe0144a..1620a8fad39 100644 --- a/document/src/vespa/document/test/CMakeLists.txt +++ b/document/src/vespa/document/test/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_library(document_test OBJECT SOURCES + make_bucket_space.cpp make_document_bucket.cpp DEPENDS ) diff --git a/document/src/vespa/document/test/make_bucket_space.cpp b/document/src/vespa/document/test/make_bucket_space.cpp new file mode 100644 index 00000000000..a213e5e36b7 --- /dev/null +++ b/document/src/vespa/document/test/make_bucket_space.cpp @@ -0,0 +1,12 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "make_bucket_space.h" + +namespace document::test { + +BucketSpace makeBucketSpace() +{ + return BucketSpace::placeHolder(); +} + +} diff --git a/document/src/vespa/document/test/make_bucket_space.h b/document/src/vespa/document/test/make_bucket_space.h new file mode 100644 index 00000000000..8289ec2030a --- /dev/null +++ b/document/src/vespa/document/test/make_bucket_space.h @@ -0,0 +1,13 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include <vespa/document/bucket/bucketspace.h> + +namespace document::test { + +// Helper function used by unit tests + +BucketSpace makeBucketSpace(); + +} diff --git a/storage/src/tests/bucketdb/bucketmanagertest.cpp b/storage/src/tests/bucketdb/bucketmanagertest.cpp index 98f3e06fc62..8cc046861be 100644 --- a/storage/src/tests/bucketdb/bucketmanagertest.cpp +++ b/storage/src/tests/bucketdb/bucketmanagertest.cpp @@ -15,6 +15,7 @@ #include <tests/common/dummystoragelink.h> #include <tests/common/testhelper.h> #include <vespa/document/test/make_document_bucket.h> +#include <vespa/document/test/make_bucket_space.h> #include <vespa/vdslib/state/random.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/testkit/testapp.h> @@ -31,6 +32,7 @@ using config::FileSpec; using document::DocumentType; using document::DocumentTypeRepo; using document::test::makeDocumentBucket; +using document::test::makeBucketSpace; namespace storage { @@ -415,13 +417,13 @@ void BucketManagerTest::testRequestBucketInfoWithState() // Send a request bucket info command that will be outdated and failed. std::shared_ptr<api::RequestBucketInfoCommand> cmd1( - new api::RequestBucketInfoCommand(0, states[1])); + new api::RequestBucketInfoCommand(makeBucketSpace(), 0, states[1])); // Send two request bucket info commands that will be processed together // when the bucket manager is idle, as states are equivalent std::shared_ptr<api::RequestBucketInfoCommand> cmd2( - new api::RequestBucketInfoCommand(0, states[2])); + new api::RequestBucketInfoCommand(makeBucketSpace(), 0, states[2])); std::shared_ptr<api::RequestBucketInfoCommand> cmd3( - new api::RequestBucketInfoCommand(0, states[3])); + new api::RequestBucketInfoCommand(makeBucketSpace(), 0, states[3])); // Tag server initialized before starting _top->open(); @@ -559,7 +561,7 @@ void BucketManagerTest::testRequestBucketInfoWithList() bids.push_back(document::BucketId(16, 0xe8c8)); std::shared_ptr<api::RequestBucketInfoCommand> cmd( - new api::RequestBucketInfoCommand(bids)); + new api::RequestBucketInfoCommand(makeBucketSpace(), bids)); _top->sendDown(cmd); _top->waitForMessages(1, 5); @@ -729,11 +731,11 @@ public: } auto createFullFetchCommand() const { - return std::make_shared<api::RequestBucketInfoCommand>(0, _state); + return std::make_shared<api::RequestBucketInfoCommand>(makeBucketSpace(), 0, _state); } auto createFullFetchCommandWithHash(vespalib::stringref hash) const { - return std::make_shared<api::RequestBucketInfoCommand>(0, _state, hash); + return std::make_shared<api::RequestBucketInfoCommand>(makeBucketSpace(), 0, _state, hash); } auto acquireBucketLockAndSendInfoRequest(const document::BucketId& bucket) { @@ -907,7 +909,7 @@ BucketManagerTest::testOrderRepliesAfterBucketSpecificRequest() auto infoRoundtrip = std::async(std::launch::async, [&]() { std::vector<document::BucketId> buckets{bucketA}; - auto infoCmd = std::make_shared<api::RequestBucketInfoCommand>(buckets); + auto infoCmd = std::make_shared<api::RequestBucketInfoCommand>(makeBucketSpace(), buckets); // Can't complete until `guard` has been unlocked. _top->sendDown(infoCmd); // Barrier: bucket reply and subsequent split reply @@ -947,7 +949,7 @@ BucketManagerTest::testQueuedRepliesOnlyDispatchedWhenAllProcessingDone() auto singleBucketInfo = std::async(std::launch::async, [&]() { std::vector<document::BucketId> buckets{bucketA}; - auto infoCmd = std::make_shared<api::RequestBucketInfoCommand>(buckets); + auto infoCmd = std::make_shared<api::RequestBucketInfoCommand>(makeBucketSpace(), buckets); _top->sendDown(infoCmd); _top->waitForMessages(3, MESSAGE_WAIT_TIME); }); @@ -1209,7 +1211,7 @@ void BucketManagerTest::sendSingleBucketInfoRequest(const document::BucketId& id) { std::vector<document::BucketId> buckets{id}; - auto infoCmd = std::make_shared<api::RequestBucketInfoCommand>(buckets); + auto infoCmd = std::make_shared<api::RequestBucketInfoCommand>(makeBucketSpace(), buckets); _top->sendDown(infoCmd); } diff --git a/storage/src/tests/distributor/idealstatemanagertest.cpp b/storage/src/tests/distributor/idealstatemanagertest.cpp index e48046fb4ac..fe7a03856c7 100644 --- a/storage/src/tests/distributor/idealstatemanagertest.cpp +++ b/storage/src/tests/distributor/idealstatemanagertest.cpp @@ -10,8 +10,10 @@ #include <vespa/storageapi/message/bucketsplitting.h> #include <tests/distributor/distributortestutil.h> #include <vespa/document/test/make_document_bucket.h> +#include <vespa/document/test/make_bucket_space.h> using document::test::makeDocumentBucket; +using document::test::makeBucketSpace; namespace storage { namespace distributor { @@ -198,7 +200,7 @@ IdealStateManagerTest::testBlockIdealStateOpsOnFullRequestBucketInfo() // sent to the entire node. It will then use a null bucketid. { std::shared_ptr<api::RequestBucketInfoCommand> msg( - new api::RequestBucketInfoCommand(buckets)); + new api::RequestBucketInfoCommand(makeBucketSpace(), buckets)); msg->setAddress( api::StorageMessageAddress("storage", lib::NodeType::STORAGE, 4)); tracker.insert(msg); diff --git a/storage/src/vespa/storage/distributor/bucketdbupdater.cpp b/storage/src/vespa/storage/distributor/bucketdbupdater.cpp index ce7f7afc670..2a056949f9a 100644 --- a/storage/src/vespa/storage/distributor/bucketdbupdater.cpp +++ b/storage/src/vespa/storage/distributor/bucketdbupdater.cpp @@ -14,6 +14,7 @@ LOG_SETUP(".distributor.bucketdb.updater"); using storage::lib::Node; using storage::lib::NodeType; +using document::BucketSpace; namespace storage::distributor { @@ -81,7 +82,7 @@ BucketDBUpdater::sendRequestBucketInfo( buckets.push_back(bucket); std::shared_ptr<api::RequestBucketInfoCommand> msg( - new api::RequestBucketInfoCommand(buckets)); + new api::RequestBucketInfoCommand(BucketSpace::placeHolder(), buckets)); LOG(debug, "Sending request bucket info command %lu for " diff --git a/storage/src/vespa/storage/distributor/pendingclusterstate.cpp b/storage/src/vespa/storage/distributor/pendingclusterstate.cpp index bd14ded3710..9ad803b7b7f 100644 --- a/storage/src/vespa/storage/distributor/pendingclusterstate.cpp +++ b/storage/src/vespa/storage/distributor/pendingclusterstate.cpp @@ -10,6 +10,8 @@ #include <vespa/log/log.h> LOG_SETUP(".pendingclusterstate"); +using document::BucketSpace; + namespace storage::distributor { using lib::Node; @@ -317,6 +319,7 @@ PendingClusterState::requestNode(uint16_t node) std::shared_ptr<api::RequestBucketInfoCommand> cmd( new api::RequestBucketInfoCommand( + BucketSpace::placeHolder(), _sender.getDistributorIndex(), _newClusterState, distributionHash)); diff --git a/storageapi/src/tests/mbusprot/storageprotocoltest.cpp b/storageapi/src/tests/mbusprot/storageprotocoltest.cpp index bfd657c2f05..0c8b5d326fe 100644 --- a/storageapi/src/tests/mbusprot/storageprotocoltest.cpp +++ b/storageapi/src/tests/mbusprot/storageprotocoltest.cpp @@ -16,6 +16,7 @@ #include <vespa/document/repo/documenttyperepo.h> #include <vespa/document/update/fieldpathupdates.h> #include <vespa/document/test/make_document_bucket.h> +#include <vespa/document/test/make_bucket_space.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/vespalib/util/growablebytebuffer.h> #include <vespa/vespalib/objects/nbostream.h> @@ -30,6 +31,7 @@ using document::DocumentId; using document::DocumentType; using document::DocumentTypeRepo; using document::test::makeDocumentBucket; +using document::test::makeBucketSpace; using storage::lib::ClusterState; using vespalib::string; @@ -389,7 +391,7 @@ StorageProtocolTest::testRequestBucketInfo51() std::vector<document::BucketId> ids; ids.push_back(document::BucketId(3)); ids.push_back(document::BucketId(7)); - RequestBucketInfoCommand::SP cmd(new RequestBucketInfoCommand(ids)); + RequestBucketInfoCommand::SP cmd(new RequestBucketInfoCommand(makeBucketSpace(), ids)); RequestBucketInfoCommand::SP cmd2(copyCommand(cmd, _version5_1)); CPPUNIT_ASSERT_EQUAL(ids, cmd2->getBuckets()); CPPUNIT_ASSERT(!cmd2->hasSystemState()); @@ -399,6 +401,7 @@ StorageProtocolTest::testRequestBucketInfo51() { ClusterState state("distributor:3 .1.s:d"); RequestBucketInfoCommand::SP cmd(new RequestBucketInfoCommand( + makeBucketSpace(), 3, state, "14")); RequestBucketInfoCommand::SP cmd2(copyCommand(cmd, _version5_1)); CPPUNIT_ASSERT(cmd2->hasSystemState()); diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp index 2bd160b1aab..22f58ebc58b 100644 --- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp +++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp @@ -638,12 +638,13 @@ ProtocolSerialization5_0::onDecodeRequestBucketInfoCommand(BBuf& buf) const buckets[i] = document::BucketId(SH::getLong(buf)); } api::RequestBucketInfoCommand::UP msg; + BucketSpace bucketSpace(BucketSpace::placeHolder()); if (buckets.size() != 0) { - msg.reset(new api::RequestBucketInfoCommand(buckets)); + msg.reset(new api::RequestBucketInfoCommand(bucketSpace, buckets)); } else { int distributor = SH::getShort(buf); lib::ClusterState state(SH::getString(buf)); - msg.reset(new api::RequestBucketInfoCommand(distributor, state, SH::getString(buf))); + msg.reset(new api::RequestBucketInfoCommand(bucketSpace, distributor, state, SH::getString(buf))); } onDecodeCommand(buf, *msg); return api::StorageCommand::UP(msg.release()); diff --git a/storageapi/src/vespa/storageapi/message/bucket.cpp b/storageapi/src/vespa/storageapi/message/bucket.cpp index 983a65114b3..18ad95c2c02 100644 --- a/storageapi/src/vespa/storageapi/message/bucket.cpp +++ b/storageapi/src/vespa/storageapi/message/bucket.cpp @@ -440,8 +440,10 @@ ApplyBucketDiffReply::print(std::ostream& out, bool verbose, } RequestBucketInfoCommand::RequestBucketInfoCommand( + document::BucketSpace bucketSpace, const std::vector<document::BucketId>& buckets) : StorageCommand(MessageType::REQUESTBUCKETINFO), + _bucketSpace(bucketSpace), _buckets(buckets), _state(), _distributor(0xFFFF) @@ -449,9 +451,11 @@ RequestBucketInfoCommand::RequestBucketInfoCommand( } RequestBucketInfoCommand::RequestBucketInfoCommand( + document::BucketSpace bucketSpace, uint16_t distributor, const lib::ClusterState& state, const vespalib::stringref & distributionHash) : StorageCommand(MessageType::REQUESTBUCKETINFO), + _bucketSpace(bucketSpace), _buckets(), _state(new lib::ClusterState(state)), _distributor(distributor), @@ -460,8 +464,10 @@ RequestBucketInfoCommand::RequestBucketInfoCommand( } RequestBucketInfoCommand::RequestBucketInfoCommand( + document::BucketSpace bucketSpace, uint16_t distributor, const lib::ClusterState& state) : StorageCommand(MessageType::REQUESTBUCKETINFO), + _bucketSpace(bucketSpace), _buckets(), _state(new lib::ClusterState(state)), _distributor(distributor), diff --git a/storageapi/src/vespa/storageapi/message/bucket.h b/storageapi/src/vespa/storageapi/message/bucket.h index d2bf97e7768..0c97772d184 100644 --- a/storageapi/src/vespa/storageapi/message/bucket.h +++ b/storageapi/src/vespa/storageapi/message/bucket.h @@ -336,6 +336,7 @@ public: * the buckets that belong to the given distributor should be returned. */ class RequestBucketInfoCommand : public StorageCommand { + document::BucketSpace _bucketSpace; std::vector<document::BucketId> _buckets; std::unique_ptr<lib::ClusterState> _state; uint16_t _distributor; @@ -343,12 +344,15 @@ class RequestBucketInfoCommand : public StorageCommand { public: explicit RequestBucketInfoCommand( + document::BucketSpace bucketSpace, const std::vector<document::BucketId>& buckets); - RequestBucketInfoCommand(uint16_t distributor, + RequestBucketInfoCommand(document::BucketSpace bucketSpace, + uint16_t distributor, const lib::ClusterState& state, const vespalib::stringref & _distributionHash); - RequestBucketInfoCommand(uint16_t distributor, + RequestBucketInfoCommand(document::BucketSpace bucketSpace, + uint16_t distributor, const lib::ClusterState& state); const std::vector<document::BucketId>& getBuckets() const { return _buckets; } |