diff options
author | Geir Storli <geirstorli@yahoo.no> | 2017-11-21 14:55:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-21 14:55:20 +0100 |
commit | 37b2885f24f82f316f231adec6cea9d90c2ea4d8 (patch) | |
tree | 072f6e0cc50af56c0b69b10312f7ba45f989092d /storage | |
parent | 39c75dd01b0e85b6d4ab7c06cfc8458d0990921b (diff) | |
parent | 06bc77caeb6aa730e35fef1666319085727b5fbb (diff) |
Merge pull request #4214 from vespa-engine/toregge/use-content-bucket-space-to-get-distribution
Use ContentBucketSpace to get Distribution.
Diffstat (limited to 'storage')
4 files changed, 12 insertions, 10 deletions
diff --git a/storage/src/vespa/storage/bucketdb/bucketmanager.cpp b/storage/src/vespa/storage/bucketdb/bucketmanager.cpp index 5e7cf4af046..00fa5c95c9b 100644 --- a/storage/src/vespa/storage/bucketdb/bucketmanager.cpp +++ b/storage/src/vespa/storage/bucketdb/bucketmanager.cpp @@ -104,14 +104,14 @@ namespace { DistributorStateCache _state; std::unordered_map<uint16_t, ResultArray>& _result; const document::BucketIdFactory& _factory; - std::shared_ptr<lib::Distribution> _storageDistribution; + std::shared_ptr<const lib::Distribution> _storageDistribution; public: DistributorInfoGatherer( const lib::ClusterState& systemState, std::unordered_map<uint16_t, ResultArray>& result, const document::BucketIdFactory& factory, - std::shared_ptr<lib::Distribution> distribution) + std::shared_ptr<const lib::Distribution> distribution) : _state(*distribution, systemState), _result(result), _factory(factory), @@ -513,7 +513,7 @@ BucketManager::processRequestBucketInfoCommands(document::BucketSpace bucketSpac typedef std::shared_ptr<api::RequestBucketInfoCommand> RBISP; std::map<uint16_t, RBISP> requests; - lib::Distribution::SP distribution(_component.getDistribution()); + auto distribution(_component.getBucketSpaceRepo().get(bucketSpace).getDistribution()); lib::ClusterState::CSP clusterState( _component.getStateUpdater().getSystemState()); assert(clusterState.get()); diff --git a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp index eaebba9ccc5..fc2c2066b6f 100644 --- a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp +++ b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp @@ -68,7 +68,6 @@ StorageBucketDBInitializer::System::System( _partitions(partitions), _bucketSpaceRepo(_component.getBucketSpaceRepo()), _nodeIndex(_component.getIndex()), - _distribution(*_component.getDistribution()), _nodeState() { // Is this correct? We should get the node state from the node state updater @@ -372,6 +371,7 @@ StorageBucketDBInitializer::reportHtmlStatus( // Always called from worker thread. Worker monitor already grabbed void StorageBucketDBInitializer::registerBucket(const document::Bucket &bucket, + const lib::Distribution &distribution, spi::PartitionId partition, api::BucketInfo bucketInfo) { @@ -403,7 +403,7 @@ StorageBucketDBInitializer::registerBucket(const document::Bucket &bucket, return; } uint32_t keepOnDisk, joinFromDisk; - if (_system._distribution.getPreferredAvailableDisk( + if (distribution.getPreferredAvailableDisk( _system._nodeState, _system._nodeIndex, bucketId.stripUnused()) == partition) { @@ -429,7 +429,7 @@ StorageBucketDBInitializer::registerBucket(const document::Bucket &bucket, bucketId.toString().c_str(), int(partition)); entry->disk = partition; entry.write(); - uint16_t disk(_system._distribution.getIdealDisk( + uint16_t disk(distribution.getIdealDisk( _system._nodeState, _system._nodeIndex, bucketId.stripUnused(), lib::Distribution::IDEAL_DISK_EVEN_IF_DOWN)); if (disk != partition) { @@ -621,8 +621,10 @@ StorageBucketDBInitializer::handleReadBucketListReply( const spi::BucketIdListResult::List& list(reply.getBuckets()); api::BucketInfo info; assert(!info.valid()); + const auto &contentBucketSpace(_system._bucketSpaceRepo.get(reply.getBucketSpace())); + auto distribution(contentBucketSpace.getDistribution()); for (uint32_t i=0, n=list.size(); i<n; ++i) { - registerBucket(document::Bucket(reply.getBucketSpace(), list[i]), reply.getPartition(), info); + registerBucket(document::Bucket(reply.getBucketSpace(), list[i]), *distribution, 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 15fbd5172cb..57b95e14f48 100644 --- a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h +++ b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h @@ -80,7 +80,6 @@ class StorageBucketDBInitializer : public StorageLink, const spi::PartitionStateList& _partitions; const ContentBucketSpaceRepo& _bucketSpaceRepo; uint32_t _nodeIndex; - lib::Distribution& _distribution; lib::NodeState _nodeState; // Disk info for ideal state calculations framework::Thread::UP _thread; @@ -188,6 +187,7 @@ public: std::vector<uint32_t>& path); /** Register a bucket in the bucket database. */ void registerBucket(const document::Bucket &bucket, + const lib::Distribution &distribution, spi::PartitionId, api::BucketInfo bucketInfo); /** diff --git a/storage/src/vespa/storage/common/servicelayercomponent.cpp b/storage/src/vespa/storage/common/servicelayercomponent.cpp index 68c41536f97..11311a4d189 100644 --- a/storage/src/vespa/storage/common/servicelayercomponent.cpp +++ b/storage/src/vespa/storage/common/servicelayercomponent.cpp @@ -28,7 +28,7 @@ ServiceLayerComponent::getBucketDatabase(BucketSpace bucketSpace) const uint16_t ServiceLayerComponent::getIdealPartition(const document::Bucket& bucket) const { - return getDistribution()->getIdealDisk( + return _bucketSpaceRepo->get(bucket.getBucketSpace()).getDistribution()->getIdealDisk( *getStateUpdater().getReportedNodeState(), getIndex(), bucket.getBucketId(), lib::Distribution::IDEAL_DISK_EVEN_IF_DOWN); } @@ -37,7 +37,7 @@ uint16_t ServiceLayerComponent::getPreferredAvailablePartition( const document::Bucket& bucket) const { - return getDistribution()->getPreferredAvailableDisk( + return _bucketSpaceRepo->get(bucket.getBucketSpace()).getDistribution()->getPreferredAvailableDisk( *getStateUpdater().getReportedNodeState(), getIndex(), bucket.getBucketId()); } |