diff options
author | Geir Storli <geirst@verizonmedia.com> | 2021-03-15 10:10:40 +0000 |
---|---|---|
committer | Geir Storli <geirst@verizonmedia.com> | 2021-03-17 15:26:11 +0000 |
commit | 598de7a03d1ea51a9deb77b4c57a8e3cc888204b (patch) | |
tree | 633f5c3eb5dd47be7dfd63d44ffd77d04a4bec4b /storage | |
parent | 7729ac06e11fc6952b8d48e2af22b9676de3ee93 (diff) |
Use make_shared and auto.
Diffstat (limited to 'storage')
3 files changed, 13 insertions, 16 deletions
diff --git a/storage/src/vespa/storage/distributor/bucketdbupdater.cpp b/storage/src/vespa/storage/distributor/bucketdbupdater.cpp index 17a9b4f5127..9241024f24f 100644 --- a/storage/src/vespa/storage/distributor/bucketdbupdater.cpp +++ b/storage/src/vespa/storage/distributor/bucketdbupdater.cpp @@ -124,8 +124,7 @@ BucketDBUpdater::sendRequestBucketInfo( std::vector<document::BucketId> buckets; buckets.push_back(bucket.getBucketId()); - std::shared_ptr<api::RequestBucketInfoCommand> msg( - new api::RequestBucketInfoCommand(bucket.getBucketSpace(), buckets)); + auto msg = std::make_shared<api::RequestBucketInfoCommand>(bucket.getBucketSpace(), buckets); LOG(debug, "Sending request bucket info command %" PRIu64 " for " @@ -295,10 +294,10 @@ BucketDBUpdater::storageDistributionChanged() removeSuperfluousBuckets(_distributorComponent.getClusterStateBundle(), true); - ClusterInformation::CSP clusterInfo(new SimpleClusterInformation( + auto clusterInfo = std::make_shared<const SimpleClusterInformation>( _distributorComponent.getIndex(), _distributorComponent.getClusterStateBundle(), - _distributorComponent.getDistributor().getStorageNodeUpStates())); + _distributorComponent.getDistributor().getStorageNodeUpStates()); _pendingClusterState = PendingClusterState::createForDistributionChange( _distributorComponent.getClock(), std::move(clusterInfo), @@ -406,12 +405,11 @@ BucketDBUpdater::onSetSystemState( update_read_snapshot_after_db_pruning(bundle); replyToPreviousPendingClusterStateIfAny(); - ClusterInformation::CSP clusterInfo( - new SimpleClusterInformation( + auto clusterInfo = std::make_shared<const SimpleClusterInformation>( _distributorComponent.getIndex(), _distributorComponent.getClusterStateBundle(), _distributorComponent.getDistributor() - .getStorageNodeUpStates())); + .getStorageNodeUpStates()); _pendingClusterState = PendingClusterState::createForClusterStateChange( _distributorComponent.getClock(), std::move(clusterInfo), @@ -476,8 +474,7 @@ bool BucketDBUpdater::onMergeBucketReply( const std::shared_ptr<api::MergeBucketReply>& reply) { - std::shared_ptr<MergeReplyGuard> replyGuard( - new MergeReplyGuard(*this, reply)); + auto replyGuard = std::make_shared<MergeReplyGuard>(*this, reply); // In case the merge was unsuccessful somehow, or some nodes weren't // actually merged (source-only nodes?) we request the bucket info of the @@ -523,8 +520,7 @@ BucketDBUpdater::onNotifyBucketChange( const std::shared_ptr<api::NotifyBucketChangeCommand>& cmd) { // Immediately schedule reply to ensure it is sent. - _sender.sendReply(std::shared_ptr<api::StorageReply>( - new api::NotifyBucketChangeReply(*cmd))); + _sender.sendReply(std::make_shared<api::NotifyBucketChangeReply>(*cmd)); if (!cmd->getBucketInfo().valid()) { LOG(error, @@ -606,7 +602,9 @@ BucketDBUpdater::resendDelayedMessages() if (_pendingClusterState) { _pendingClusterState->resendDelayedMessages(); } - if (_delayedRequests.empty()) return; // Don't fetch time if not needed + if (_delayedRequests.empty()) { + return; // Don't fetch time if not needed + } framework::MilliSecTime currentTime(_distributorComponent.getClock()); while (!_delayedRequests.empty() && currentTime >= _delayedRequests.front().first) diff --git a/storage/src/vespa/storage/distributor/bucketdbupdater.h b/storage/src/vespa/storage/distributor/bucketdbupdater.h index d70a4fe3409..35ac70416f1 100644 --- a/storage/src/vespa/storage/distributor/bucketdbupdater.h +++ b/storage/src/vespa/storage/distributor/bucketdbupdater.h @@ -81,7 +81,7 @@ private: DistributorComponent _distributorComponent; class MergeReplyGuard { public: - MergeReplyGuard(BucketDBUpdater& updater, const std::shared_ptr<api::MergeBucketReply>& reply) + MergeReplyGuard(BucketDBUpdater& updater, const std::shared_ptr<api::MergeBucketReply>& reply) noexcept : _updater(updater), _reply(reply) {} ~MergeReplyGuard(); diff --git a/storage/src/vespa/storage/distributor/pendingclusterstate.cpp b/storage/src/vespa/storage/distributor/pendingclusterstate.cpp index 175c7d27033..ce5ac98c70a 100644 --- a/storage/src/vespa/storage/distributor/pendingclusterstate.cpp +++ b/storage/src/vespa/storage/distributor/pendingclusterstate.cpp @@ -222,12 +222,11 @@ PendingClusterState::requestNode(BucketSpaceAndNode bucketSpaceAndNode) _newClusterStateBundle.getDerivedClusterState(bucketSpaceAndNode.bucketSpace)->toString().c_str(), distributionHash.c_str()); - std::shared_ptr<api::RequestBucketInfoCommand> cmd( - new api::RequestBucketInfoCommand( + auto cmd = std::make_shared<api::RequestBucketInfoCommand>( bucketSpaceAndNode.bucketSpace, _sender.getDistributorIndex(), *_newClusterStateBundle.getDerivedClusterState(bucketSpaceAndNode.bucketSpace), - distributionHash)); + distributionHash); cmd->setPriority(api::StorageMessage::HIGH); cmd->setTimeout(vespalib::duration::max()); |