diff options
author | Tor Egge <Tor.Egge@oath.com> | 2017-10-18 11:06:41 +0000 |
---|---|---|
committer | Tor Egge <Tor.Egge@oath.com> | 2017-10-18 11:10:28 +0000 |
commit | 8530d49ee9f6e4e6cf613d59bc454d39082046b3 (patch) | |
tree | 5efa62e18589854c9d21a026c8a0acce8c422e12 /storage | |
parent | 4dc24814728e5440466db2f765355fdae7208261 (diff) |
Take document::Bucket instead of document::BucketId as constructor
argument to more storage commands.
Diffstat (limited to 'storage')
15 files changed, 95 insertions, 69 deletions
diff --git a/storage/src/tests/persistence/diskmoveoperationhandlertest.cpp b/storage/src/tests/persistence/diskmoveoperationhandlertest.cpp index 3d7e65fec1c..6dd05c238d5 100644 --- a/storage/src/tests/persistence/diskmoveoperationhandlertest.cpp +++ b/storage/src/tests/persistence/diskmoveoperationhandlertest.cpp @@ -4,6 +4,9 @@ #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/storage/persistence/messages.h> #include <tests/persistence/persistencetestutils.h> +#include <tests/common/make_document_bucket.h> + +using storage::test::makeDocumentBucket; namespace storage { @@ -43,7 +46,7 @@ DiskMoveOperationHandlerTest::testSimple() DiskMoveOperationHandler diskMoveHandler( getEnv(3), getPersistenceProvider()); - BucketDiskMoveCommand move(document::BucketId(16, 4), 3, 4); + BucketDiskMoveCommand move(makeDocumentBucket(document::BucketId(16, 4)), 3, 4); spi::Context context(documentapi::LoadType::DEFAULT, 0, 0); diskMoveHandler.handleBucketDiskMove(move, context); diff --git a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp index 87655d8bd35..001e3a0c6ca 100644 --- a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp +++ b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp @@ -490,7 +490,7 @@ FileStorManagerTest::testDiskMove() { std::shared_ptr<BucketDiskMoveCommand> cmd( - new BucketDiskMoveCommand(bid, 0, 1)); + new BucketDiskMoveCommand(makeDocumentBucket(bid), 0, 1)); top.sendDown(cmd); top.waitForMessages(1, _waitTime); @@ -571,7 +571,7 @@ FileStorManagerTest::testRepairNotifiesDistributorOnChange() getDummyPersistence().simulateMaintenanceFailure(); std::shared_ptr<RepairBucketCommand> cmd( - new RepairBucketCommand(document::BucketId(16, 1), 0)); + new RepairBucketCommand(makeDocumentBucket(document::BucketId(16, 1)), 0)); top.sendDown(cmd); top.waitForMessages(2, _waitTime); @@ -1931,7 +1931,7 @@ createIterator(DummyStorageLink& link, selection.setFromTimestamp(spi::Timestamp(fromTime.getTime())); selection.setToTimestamp(spi::Timestamp(toTime.getTime())); CreateIteratorCommand::SP createIterCmd( - new CreateIteratorCommand(bucket, + new CreateIteratorCommand(makeDocumentBucket(bucket), selection, headerOnly ? "[header]" : "[all]", spi::NEWEST_DOCUMENT_ONLY)); @@ -2019,7 +2019,7 @@ FileStorManagerTest::testVisiting() 127)); spi::IteratorId iterId(createIterator(top, ids[0], "true")); std::shared_ptr<GetIterCommand> cmd( - new GetIterCommand(std::move(token), ids[0], iterId, 16*1024)); + new GetIterCommand(std::move(token), makeDocumentBucket(ids[0]), iterId, 16*1024)); top.sendDown(cmd); top.waitForMessages(1, _waitTime); CPPUNIT_ASSERT_EQUAL((size_t) 1, top.getNumReplies()); @@ -2047,7 +2047,7 @@ FileStorManagerTest::testVisiting() 16*1024, 127)); std::shared_ptr<GetIterCommand> cmd( - new GetIterCommand(std::move(token), ids[1], iterId, 16*1024)); + new GetIterCommand(std::move(token), makeDocumentBucket(ids[1]), iterId, 16*1024)); top.sendDown(cmd); top.waitForMessages(1, _waitTime); CPPUNIT_ASSERT_EQUAL((size_t) 1, top.getNumReplies()); @@ -2086,7 +2086,7 @@ FileStorManagerTest::testVisiting() 16*1024, 127)); std::shared_ptr<GetIterCommand> cmd( - new GetIterCommand(std::move(token), ids[1], iterId, 16*1024)); + new GetIterCommand(std::move(token), makeDocumentBucket(ids[1]), iterId, 16*1024)); top.sendDown(cmd); top.waitForMessages(1, _waitTime); CPPUNIT_ASSERT_EQUAL((size_t) 1, top.getNumReplies()); @@ -2807,7 +2807,7 @@ FileStorManagerTest::testGetIter() 2048, 127)); std::shared_ptr<GetIterCommand> cmd( - new GetIterCommand(std::move(token), bid, iterId, 2048)); + new GetIterCommand(std::move(token), makeDocumentBucket(bid), iterId, 2048)); top.sendDown(cmd); top.waitForMessages(1, _waitTime); CPPUNIT_ASSERT_EQUAL((size_t) 1, top.getNumReplies()); @@ -2845,7 +2845,7 @@ FileStorManagerTest::testGetIter() 2048, 127)); std::shared_ptr<GetIterCommand> cmd( - new GetIterCommand(std::move(token), bid, iterId, 2048)); + new GetIterCommand(std::move(token), makeDocumentBucket(bid), iterId, 2048)); top.sendDown(cmd); top.waitForMessages(1, _waitTime); CPPUNIT_ASSERT_EQUAL((size_t) 1, top.getNumReplies()); @@ -2909,7 +2909,7 @@ FileStorManagerTest::testSetBucketActiveState() // Trigger bucket info to be read back into the database { std::shared_ptr<ReadBucketInfo> cmd( - new ReadBucketInfo(bid)); + new ReadBucketInfo(makeDocumentBucket(bid))); top.sendDown(cmd); top.waitForMessages(1, _waitTime); CPPUNIT_ASSERT_EQUAL((size_t) 1, top.getNumReplies()); diff --git a/storage/src/tests/persistence/filestorage/operationabortingtest.cpp b/storage/src/tests/persistence/filestorage/operationabortingtest.cpp index 9a71fe16a15..f3054132cb9 100644 --- a/storage/src/tests/persistence/filestorage/operationabortingtest.cpp +++ b/storage/src/tests/persistence/filestorage/operationabortingtest.cpp @@ -352,7 +352,7 @@ OperationAbortingTest::testDoNotAbortRecheckBucketCommands() { document::BucketId bucket(16, 1); std::vector<api::StorageMessage::SP> msgs; - msgs.push_back(api::StorageMessage::SP(new RecheckBucketInfoCommand(bucket))); + msgs.push_back(api::StorageMessage::SP(new RecheckBucketInfoCommand(makeDocumentBucket(bucket)))); bool shouldCreateBucketInitially(true); doTestSpecificOperationsNotAborted( diff --git a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp index c5875139e1e..cf6d5183ce1 100644 --- a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp +++ b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp @@ -16,6 +16,8 @@ #include <vespa/log/bufferedlogger.h> LOG_SETUP(".storage.bucketdb.initializer"); +using document::BucketSpace; + namespace storage { using BucketSet = vespalib::hash_set<document::BucketId, document::BucketId::hash>; @@ -153,7 +155,7 @@ StorageBucketDBInitializer::onOpen() // Trigger bucket database initialization for (uint32_t i=0; i<_system._partitions.size(); ++i) { if (!_system._partitions[i].isUp()) continue; - ReadBucketList::SP msg(new ReadBucketList(spi::PartitionId(i))); + ReadBucketList::SP msg(new ReadBucketList(BucketSpace::placeHolder(), spi::PartitionId(i))); _state._lists[msg->getMsgId()] = msg; sendDown(msg); } @@ -335,26 +337,27 @@ StorageBucketDBInitializer::reportHtmlStatus( // Always called from worker thread. Worker monitor already grabbed void -StorageBucketDBInitializer::registerBucket(const document::BucketId& bucket, +StorageBucketDBInitializer::registerBucket(const document::Bucket &bucket, spi::PartitionId partition, api::BucketInfo bucketInfo) { + document::BucketId bucketId(bucket.getBucketId()); StorBucketDatabase::WrappedEntry entry(_system._bucketDatabase.get( - bucket, "StorageBucketDBInitializer::registerBucket", + bucketId, "StorageBucketDBInitializer::registerBucket", StorBucketDatabase::CREATE_IF_NONEXISTING)); if (bucketInfo.valid()) { if (entry.preExisted()) { LOG(debug, "Had value %s for %s before registering", entry->getBucketInfo().toString().c_str(), - bucket.toString().c_str()); + bucketId.toString().c_str()); } LOG(debug, "Got new value %s from %s partition %u", - bucketInfo.toString().c_str(), bucket.toString().c_str(), + bucketInfo.toString().c_str(), bucketId.toString().c_str(), partition.getValue()); entry->setBucketInfo(bucketInfo); } else { LOG(debug, "Got invalid bucket info from %s partition %u: %s", - bucket.toString().c_str(), partition.getValue(), + bucketId.toString().c_str(), partition.getValue(), bucketInfo.toString().c_str()); } if (entry.preExisted()) { @@ -362,13 +365,13 @@ StorageBucketDBInitializer::registerBucket(const document::BucketId& bucket, LOG(debug, "%s already existed in bucket database on disk %i. " "Might have been moved from wrong directory prior to " "listing this directory.", - bucket.toString().c_str(), int(partition)); + bucketId.toString().c_str(), int(partition)); return; } uint32_t keepOnDisk, joinFromDisk; if (_system._distribution.getPreferredAvailableDisk( _system._nodeState, _system._nodeIndex, - bucket.stripUnused()) == partition) + bucketId.stripUnused()) == partition) { keepOnDisk = partition; joinFromDisk = entry->disk; @@ -378,7 +381,7 @@ StorageBucketDBInitializer::registerBucket(const document::BucketId& bucket, } LOG(debug, "%s exist on both disk %u and disk %i. Joining two versions " "onto disk %u.", - bucket.toString().c_str(), entry->disk, int(partition), keepOnDisk); + bucketId.toString().c_str(), entry->disk, int(partition), keepOnDisk); entry.unlock(); // Must not have bucket db lock while sending down InternalBucketJoinCommand::SP cmd(new InternalBucketJoinCommand( @@ -388,13 +391,13 @@ StorageBucketDBInitializer::registerBucket(const document::BucketId& bucket, } sendDown(cmd); } else { - _system._component.getMinUsedBitsTracker().update(bucket); + _system._component.getMinUsedBitsTracker().update(bucketId); LOG(spam, "Inserted %s on disk %i into bucket database", - bucket.toString().c_str(), int(partition)); + bucketId.toString().c_str(), int(partition)); entry->disk = partition; entry.write(); uint16_t disk(_system._distribution.getIdealDisk( - _system._nodeState, _system._nodeIndex, bucket.stripUnused(), + _system._nodeState, _system._nodeIndex, bucketId.stripUnused(), lib::Distribution::IDEAL_DISK_EVEN_IF_DOWN)); if (disk != partition) { ++_metrics._wrongDisk; @@ -478,7 +481,8 @@ StorageBucketDBInitializer::sendReadBucketInfo(spi::PartitionId disk) _state._infoSetByLoad += finder._alreadySet; } for (uint32_t i=0; i<finder._next.size(); ++i) { - ReadBucketInfo::SP cmd(new ReadBucketInfo(finder._next[i])); + document::Bucket bucket(BucketSpace::placeHolder(), finder._next[i]); + ReadBucketInfo::SP cmd(new ReadBucketInfo(bucket)); cmd->setPriority(_config._infoReadPriority); state._pending.insert(finder._next[i]); _state._infoRequests[cmd->getMsgId()] = disk; @@ -583,7 +587,7 @@ StorageBucketDBInitializer::handleReadBucketListReply( api::BucketInfo info; assert(!info.valid()); for (uint32_t i=0, n=list.size(); i<n; ++i) { - registerBucket(list[i], reply.getPartition(), info); + registerBucket(document::Bucket(reply.getBucketSpace(), list[i]), reply.getPartition(), info); } if (++_state._dirsListed == _state._dirsToList) { handleListingCompleted(); diff --git a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h index b28b5a65cd4..99f273a384a 100644 --- a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h +++ b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h @@ -179,7 +179,7 @@ public: bool handleBadLocation(const document::BucketId&, std::vector<uint32_t>& path); /** Register a bucket in the bucket database. */ - void registerBucket(const document::BucketId&, + void registerBucket(const document::Bucket &bucket, spi::PartitionId, api::BucketInfo bucketInfo); /** diff --git a/storage/src/vespa/storage/bucketmover/bucketmover.cpp b/storage/src/vespa/storage/bucketmover/bucketmover.cpp index 005e73767c1..01276db8087 100644 --- a/storage/src/vespa/storage/bucketmover/bucketmover.cpp +++ b/storage/src/vespa/storage/bucketmover/bucketmover.cpp @@ -13,6 +13,8 @@ #include <vespa/log/bufferedlogger.h> LOG_SETUP(".bucketmover"); +using document::BucketSpace; + namespace storage::bucketmover { BucketMover::BucketMover(const config::ConfigUri & configUri, @@ -131,8 +133,9 @@ BucketMover::queueNewMoves() break; } _pendingMoves.push_back(nextMove); + document::Bucket bucket(BucketSpace::placeHolder(), nextMove.getBucketId()); std::shared_ptr<BucketDiskMoveCommand> cmd( - new BucketDiskMoveCommand(nextMove.getBucketId(), + new BucketDiskMoveCommand(bucket, nextMove.getSourceDisk(), nextMove.getTargetDisk())); cmd->setPriority(nextMove.getPriority()); diff --git a/storage/src/vespa/storage/common/bucketmessages.cpp b/storage/src/vespa/storage/common/bucketmessages.cpp index c7e013392f7..1317f5e0814 100644 --- a/storage/src/vespa/storage/common/bucketmessages.cpp +++ b/storage/src/vespa/storage/common/bucketmessages.cpp @@ -7,8 +7,10 @@ using document::BucketSpace; namespace storage { -ReadBucketList::ReadBucketList(spi::PartitionId partition) - : api::InternalCommand(ID), _partition(partition) +ReadBucketList::ReadBucketList(BucketSpace bucketSpace, spi::PartitionId partition) + : api::InternalCommand(ID), + _bucketSpace(bucketSpace), + _partition(partition) { } ReadBucketList::~ReadBucketList() { } @@ -25,6 +27,7 @@ ReadBucketList::print(std::ostream& out, bool verbose, const std::string& indent ReadBucketListReply::ReadBucketListReply(const ReadBucketList& cmd) : api::InternalReply(ID, cmd), + _bucketSpace(cmd.getBucketSpace()), _partition(cmd.getPartition()) { } @@ -45,9 +48,9 @@ ReadBucketList::makeReply() { return std::make_unique<ReadBucketListReply>(*this); } -ReadBucketInfo::ReadBucketInfo(const document::BucketId& bucketId) +ReadBucketInfo::ReadBucketInfo(const document::Bucket &bucket) : api::InternalCommand(ID), - _bucket(BucketSpace::placeHolder(), bucketId) + _bucket(bucket) { } ReadBucketInfo::~ReadBucketInfo() { } @@ -91,9 +94,9 @@ std::unique_ptr<api::StorageReply> ReadBucketInfo::makeReply() { } -RepairBucketCommand::RepairBucketCommand(const document::BucketId& bucket, uint16_t disk) +RepairBucketCommand::RepairBucketCommand(const document::Bucket &bucket, uint16_t disk) : api::InternalCommand(ID), - _bucket(BucketSpace::placeHolder(), bucket), + _bucket(bucket), _disk(disk), _verifyBody(false), _moveToIdealDisk(false) @@ -154,10 +157,10 @@ RepairBucketCommand::makeReply() { return std::make_unique<RepairBucketReply>(*this); } -BucketDiskMoveCommand::BucketDiskMoveCommand(const document::BucketId& bucket, +BucketDiskMoveCommand::BucketDiskMoveCommand(const document::Bucket &bucket, uint16_t srcDisk, uint16_t dstDisk) : api::InternalCommand(ID), - _bucket(BucketSpace::placeHolder(), bucket), + _bucket(bucket), _srcDisk(srcDisk), _dstDisk(dstDisk) { @@ -209,10 +212,10 @@ BucketDiskMoveCommand::makeReply() } -InternalBucketJoinCommand::InternalBucketJoinCommand(const document::BucketId& bucket, +InternalBucketJoinCommand::InternalBucketJoinCommand(const document::Bucket &bucket, uint16_t keepOnDisk, uint16_t joinFromDisk) : api::InternalCommand(ID), - _bucket(BucketSpace::placeHolder(), bucket), + _bucket(bucket), _keepOnDisk(keepOnDisk), _joinFromDisk(joinFromDisk) { diff --git a/storage/src/vespa/storage/common/bucketmessages.h b/storage/src/vespa/storage/common/bucketmessages.h index 9eef9ed6068..36e3a18c6b7 100644 --- a/storage/src/vespa/storage/common/bucketmessages.h +++ b/storage/src/vespa/storage/common/bucketmessages.h @@ -17,14 +17,16 @@ namespace storage { * @brief List buckets existing on a partition. */ class ReadBucketList : public api::InternalCommand { + document::BucketSpace _bucketSpace; spi::PartitionId _partition; public: typedef std::unique_ptr<ReadBucketList> UP; static const uint32_t ID = 2003; - ReadBucketList(spi::PartitionId partition); + ReadBucketList(document::BucketSpace bucketSpace, spi::PartitionId partition); ~ReadBucketList(); + document::BucketSpace getBucketSpace() const { return _bucketSpace; } spi::PartitionId getPartition() const { return _partition; } std::unique_ptr<api::StorageReply> makeReply() override; @@ -38,6 +40,7 @@ public: * @ingroup common */ class ReadBucketListReply : public api::InternalReply { + document::BucketSpace _bucketSpace; spi::PartitionId _partition; spi::BucketIdListResult::List _buckets; @@ -49,6 +52,7 @@ public: ReadBucketListReply(const ReadBucketList& cmd); ~ReadBucketListReply(); + document::BucketSpace getBucketSpace() const { return _bucketSpace; } spi::PartitionId getPartition() const { return _partition; } spi::BucketIdListResult::List& getBuckets() { return _buckets; } @@ -75,7 +79,7 @@ class ReadBucketInfo : public api::InternalCommand { public: static const uint32_t ID = 2005; - ReadBucketInfo(const document::BucketId& bucketId); + ReadBucketInfo(const document::Bucket &bucket); ~ReadBucketInfo(); document::Bucket getBucket() const override { return _bucket; } @@ -129,7 +133,7 @@ public: static const uint32_t ID = 2007; - RepairBucketCommand(const document::BucketId& bucket, uint16_t disk); + RepairBucketCommand(const document::Bucket &bucket, uint16_t disk); ~RepairBucketCommand(); bool hasSingleBucketId() const override { return true; } @@ -196,7 +200,7 @@ public: typedef std::shared_ptr<BucketDiskMoveCommand> SP; static const uint32_t ID = 2012; - BucketDiskMoveCommand(const document::BucketId& bucket, uint16_t srcDisk, uint16_t dstDisk); + BucketDiskMoveCommand(const document::Bucket &bucket, uint16_t srcDisk, uint16_t dstDisk); ~BucketDiskMoveCommand(); document::Bucket getBucket() const override { return _bucket; } @@ -267,7 +271,7 @@ class InternalBucketJoinCommand : public api::InternalCommand { public: static const uint32_t ID = 2015; - InternalBucketJoinCommand(const document::BucketId& bucket, uint16_t keepOnDisk, uint16_t joinFromDisk); + InternalBucketJoinCommand(const document::Bucket &bucket, uint16_t keepOnDisk, uint16_t joinFromDisk); ~InternalBucketJoinCommand(); document::Bucket getBucket() const override { return _bucket; } diff --git a/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp b/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp index d0002841bbd..093576622db 100644 --- a/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp +++ b/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp @@ -8,6 +8,8 @@ #include <vespa/log/log.h> LOG_SETUP(".persistence.filestor.modifiedbucketchecker"); +using document::BucketSpace; + namespace storage { ModifiedBucketChecker::ModifiedBucketChecker( @@ -146,8 +148,8 @@ ModifiedBucketChecker::nextRecheckChunk( size_t n = std::min(_maxPendingChunkSize, _rechecksNotStarted.size()); for (size_t i = 0; i < n; ++i) { - document::BucketId bid(_rechecksNotStarted.back()); - commandsToSend.emplace_back(new RecheckBucketInfoCommand(bid)); + document::Bucket bucket(BucketSpace::placeHolder(), _rechecksNotStarted.back()); + commandsToSend.emplace_back(new RecheckBucketInfoCommand(bucket)); _rechecksNotStarted.pop_back(); } _pendingRequests = n; diff --git a/storage/src/vespa/storage/persistence/messages.cpp b/storage/src/vespa/storage/persistence/messages.cpp index 5a7f679a0bf..78f4b02a192 100644 --- a/storage/src/vespa/storage/persistence/messages.cpp +++ b/storage/src/vespa/storage/persistence/messages.cpp @@ -7,12 +7,12 @@ using document::BucketSpace; namespace storage { GetIterCommand::GetIterCommand(framework::MemoryToken::UP token, - const document::BucketId& bucketId, + const document::Bucket &bucket, const spi::IteratorId iteratorId, uint32_t maxByteSize) : api::InternalCommand(ID), _token(std::move(token)), - _bucket(BucketSpace::placeHolder(), bucketId), + _bucket(bucket), _iteratorId(iteratorId), _maxByteSize(maxByteSize) { @@ -55,12 +55,12 @@ GetIterReply::print(std::ostream& out, bool verbose, const std::string& indent) } } -CreateIteratorCommand::CreateIteratorCommand(const document::BucketId& bucketId, +CreateIteratorCommand::CreateIteratorCommand(const document::Bucket &bucket, const spi::Selection& selection, const std::string& fields, spi::IncludedVersions includedVersions) : api::InternalCommand(ID), - _bucket(BucketSpace::placeHolder(), bucketId), + _bucket(bucket), _selection(selection), _fieldSet(fields), _includedVersions(includedVersions), @@ -122,9 +122,9 @@ DestroyIteratorCommand::makeReply() { return std::make_unique<DestroyIteratorReply>(*this); } -RecheckBucketInfoCommand::RecheckBucketInfoCommand(const document::BucketId& bucketId) +RecheckBucketInfoCommand::RecheckBucketInfoCommand(const document::Bucket& bucket) : api::InternalCommand(ID), - _bucket(BucketSpace::placeHolder(), bucketId) + _bucket(bucket) { } RecheckBucketInfoCommand::~RecheckBucketInfoCommand() { } diff --git a/storage/src/vespa/storage/persistence/messages.h b/storage/src/vespa/storage/persistence/messages.h index 7f38839d80c..d47a389a8c1 100644 --- a/storage/src/vespa/storage/persistence/messages.h +++ b/storage/src/vespa/storage/persistence/messages.h @@ -25,7 +25,7 @@ public: typedef std::shared_ptr<GetIterCommand> SP; GetIterCommand(framework::MemoryToken::UP token, - const document::BucketId& bucketId, + const document::Bucket &bucket, const spi::IteratorId iteratorId, uint32_t maxByteSize); ~GetIterCommand(); @@ -93,7 +93,7 @@ public: typedef std::unique_ptr<CreateIteratorCommand> UP; typedef std::shared_ptr<CreateIteratorCommand> SP; - CreateIteratorCommand(const document::BucketId& bucketId, + CreateIteratorCommand(const document::Bucket &bucket, const spi::Selection& selection, const std::string& fields, spi::IncludedVersions includedVersions); @@ -176,7 +176,7 @@ public: typedef std::shared_ptr<RecheckBucketInfoCommand> SP; typedef std::unique_ptr<RecheckBucketInfoCommand> UP; - RecheckBucketInfoCommand(const document::BucketId& bucketId); + RecheckBucketInfoCommand(const document::Bucket &bucket); ~RecheckBucketInfoCommand(); document::Bucket getBucket() const override { return _bucket; } diff --git a/storage/src/vespa/storage/persistence/persistencethread.cpp b/storage/src/vespa/storage/persistence/persistencethread.cpp index 7a8aec6afa2..75db3d3114d 100644 --- a/storage/src/vespa/storage/persistence/persistencethread.cpp +++ b/storage/src/vespa/storage/persistence/persistencethread.cpp @@ -447,7 +447,7 @@ PersistenceThread::handleReadBucketList(ReadBucketList& cmd) _env._metrics.readBucketList, _env._component.getClock())); - spi::BucketIdListResult result(_spi.listBuckets(document::BucketSpace::placeHolder(), cmd.getPartition())); + spi::BucketIdListResult result(_spi.listBuckets(cmd.getBucketSpace(), cmd.getPartition())); if (checkForError(result, *tracker)) { ReadBucketListReply::SP reply(new ReadBucketListReply(cmd)); result.getList().swap(reply->getBuckets()); diff --git a/storage/src/vespa/storage/storageserver/bucketintegritychecker.cpp b/storage/src/vespa/storage/storageserver/bucketintegritychecker.cpp index 1bf15fefb90..337eaef69a5 100644 --- a/storage/src/vespa/storage/storageserver/bucketintegritychecker.cpp +++ b/storage/src/vespa/storage/storageserver/bucketintegritychecker.cpp @@ -14,6 +14,7 @@ LOG_SETUP(".bucketintegritychecker"); using std::shared_ptr; +using document::BucketSpace; namespace storage { @@ -595,9 +596,9 @@ BucketIntegrityChecker::run(framework::ThreadHandle& thread) } break; } - + document::Bucket bucket(BucketSpace::placeHolder(), bid); std::shared_ptr<RepairBucketCommand> cmd( - new RepairBucketCommand(bid, _status[i].disk)); + new RepairBucketCommand(bucket, _status[i].disk)); cmd->verifyBody(_currentRunWithFullVerification); cmd->moveToIdealDisk(true); cmd->setPriority(230); diff --git a/storage/src/vespa/storage/visiting/visitor.cpp b/storage/src/vespa/storage/visiting/visitor.cpp index e6dfb70960e..b91e38e035e 100644 --- a/storage/src/vespa/storage/visiting/visitor.cpp +++ b/storage/src/vespa/storage/visiting/visitor.cpp @@ -17,6 +17,8 @@ #include <vespa/log/log.h> LOG_SETUP(".visitor.instance"); +using document::BucketSpace; + namespace storage { Visitor::HitCounter::HitCounter(const document::OrderingSpecification* ordering) @@ -211,7 +213,7 @@ Visitor::BucketIterationState::~BucketIterationState() LOG(debug, "Visitor '%s' sending DestroyIteratorCommand for %s, " "iterator id %zu.", _visitor._id.c_str(), - _bucketId.toString().c_str(), + _bucket.getBucketId().toString().c_str(), uint64_t(_iteratorId)); _messageHandler.send(cmd, _visitor); } @@ -242,6 +244,7 @@ Visitor::Visitor(StorageComponent& component) _visitorTarget(), _state(STATE_NOT_STARTED), _buckets(), + _bucketSpace(BucketSpace::placeHolder()), _currentBucket(), _bucketStates(), _calledStartingVisitor(false), @@ -768,7 +771,8 @@ Visitor::onCreateIteratorReply( { std::list<BucketIterationState*>::reverse_iterator it = _bucketStates.rbegin(); - document::BucketId bucketId(reply->getBucketId()); + document::Bucket bucket(reply->getBucket()); + document::BucketId bucketId(bucket.getBucketId()); for (; it != _bucketStates.rend(); ++it) { if ((*it)->getBucketId() == bucketId) { break; @@ -807,7 +811,7 @@ Visitor::onCreateIteratorReply( return; } std::shared_ptr<GetIterCommand> cmd( - new GetIterCommand(std::move(token), bucketId, + new GetIterCommand(std::move(token), bucket, bucketState.getIteratorId(), _docBlockSize)); cmd->setLoadType(_initiatingCmd->getLoadType()); @@ -1229,7 +1233,7 @@ Visitor::getIterators() } std::shared_ptr<GetIterCommand> cmd( new GetIterCommand(std::move(token), - bucketState.getBucketId(), + bucketState.getBucket(), bucketState.getIteratorId(), _docBlockSize)); cmd->setLoadType(_initiatingCmd->getLoadType()); @@ -1257,11 +1261,11 @@ Visitor::getIterators() _bucketStates.size() < _visitorOptions._maxPending && _currentBucket < _buckets.size()) { - document::BucketId bucketId(_buckets[_currentBucket]); + document::Bucket bucket(_bucketSpace, _buckets[_currentBucket]); std::unique_ptr<BucketIterationState> newBucketState( - new BucketIterationState(*this, *_messageHandler, bucketId)); + new BucketIterationState(*this, *_messageHandler, bucket)); LOG(debug, "Visitor '%s': Sending create iterator for bucket %s.", - _id.c_str(), bucketId.toString().c_str()); + _id.c_str(), bucket.getBucketId().toString().c_str()); spi::Selection selection = spi::Selection(spi::DocumentSelection(_documentSelectionString)); @@ -1271,7 +1275,7 @@ Visitor::getIterators() spi::Timestamp(_visitorOptions._toTime.getTime())); std::shared_ptr<CreateIteratorCommand> cmd( - new CreateIteratorCommand(bucketId, + new CreateIteratorCommand(bucket, selection, _visitorOptions._fieldSet, _visitorOptions._visitRemoves ? diff --git a/storage/src/vespa/storage/visiting/visitor.h b/storage/src/vespa/storage/visiting/visitor.h index d7d693e41fe..1c156ff187a 100644 --- a/storage/src/vespa/storage/visiting/visitor.h +++ b/storage/src/vespa/storage/visiting/visitor.h @@ -131,17 +131,17 @@ private: Visitor& _visitor; VisitorMessageHandler& _messageHandler; public: - document::BucketId _bucketId; + document::Bucket _bucket; spi::IteratorId _iteratorId; uint32_t _pendingIterators; bool _completed; BucketIterationState(Visitor& visitor, VisitorMessageHandler& messageHandler, - const document::BucketId& id) + const document::Bucket &bucket) : _visitor(visitor), _messageHandler(messageHandler), - _bucketId(id), + _bucket(bucket), _iteratorId(0), _pendingIterators(0), _completed(false) @@ -153,7 +153,8 @@ private: void setCompleted(bool completed = true) { _completed = completed; } bool isCompleted() const { return _completed; } - const document::BucketId& getBucketId() const { return _bucketId; } + document::Bucket getBucket() const { return _bucket; } + document::BucketId getBucketId() const { return _bucket.getBucketId(); } void setIteratorId(spi::IteratorId iteratorId) { _iteratorId = iteratorId; @@ -172,7 +173,7 @@ private: void print(std::ostream& out, bool, const std::string& ) const override { out << "BucketIterationState(" - << _bucketId + << _bucket.getBucketId() << ", pending GetIters: " << _pendingIterators << ", iterator id: " << _iteratorId << ", completed: " << (_completed ? "yes" : "no") @@ -279,6 +280,7 @@ private: // The list of buckets to visit. std::vector<document::BucketId> _buckets; + document::BucketSpace _bucketSpace; // The iterator iterating the buckets to visit. uint32_t _currentBucket; |