aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-10-20 04:50:06 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-10-20 04:50:06 +0000
commit973f3537f85d197cec229308fbe970950f4978fc (patch)
tree95ef83dda7f795da3d91df0ac09013f644074875
parent6d2863fd9c341d3f576336d87198568933e8c364 (diff)
Make component menber const
-rw-r--r--storage/src/vespa/storage/persistence/bucketownershipnotifier.cpp23
-rw-r--r--storage/src/vespa/storage/persistence/bucketownershipnotifier.h51
-rw-r--r--storage/src/vespa/storage/persistence/persistenceutil.cpp10
-rw-r--r--storage/src/vespa/storage/persistence/persistenceutil.h10
4 files changed, 31 insertions, 63 deletions
diff --git a/storage/src/vespa/storage/persistence/bucketownershipnotifier.cpp b/storage/src/vespa/storage/persistence/bucketownershipnotifier.cpp
index a0f05a70f4e..76547dc83a8 100644
--- a/storage/src/vespa/storage/persistence/bucketownershipnotifier.cpp
+++ b/storage/src/vespa/storage/persistence/bucketownershipnotifier.cpp
@@ -17,8 +17,7 @@ using document::BucketSpace;
namespace storage {
uint16_t
-BucketOwnershipNotifier::getOwnerDistributorForBucket(
- const document::Bucket &bucket) const
+BucketOwnershipNotifier::getOwnerDistributorForBucket(const document::Bucket &bucket) const
{
try {
auto distribution(_component.getBucketSpaceRepo().get(bucket.getBucketSpace()).getDistribution());
@@ -28,24 +27,19 @@ BucketOwnershipNotifier::getOwnerDistributorForBucket(
// If we get exceptions there aren't any distributors, so they'll have
// to explicitly fetch all bucket info eventually anyway.
} catch (lib::TooFewBucketBitsInUseException& e) {
- LOGBP(debug, "Too few bucket bits used for %s to be assigned "
- "to a distributor. Not notifying any distributor of "
- "bucket change.",
- bucket.toString().c_str());
+ LOGBP(debug, "Too few bucket bits used for %s to be assigned to a distributor."
+ " Not notifying any distributor of bucket change.",
+ bucket.toString().c_str());
} catch (lib::NoDistributorsAvailableException& e) {
- LOGBP(debug, "No distributors available. Not notifying any "
- "distributor of bucket change.");
+ LOGBP(debug, "No distributors available. Not notifying any distributor of bucket change.");
} catch (const std::exception& e) {
- LOG(error,
- "Got unknown exception while resolving distributor: %s",
- e.what());
+ LOG(error, "Got unknown exception while resolving distributor: %s", e.what());
}
return FAILED_TO_RESOLVE;
}
bool
-BucketOwnershipNotifier::distributorOwns(uint16_t distributor,
- const document::Bucket &bucket) const
+BucketOwnershipNotifier::distributorOwns(uint16_t distributor, const document::Bucket &bucket) const
{
return (distributor == getOwnerDistributorForBucket(bucket));
}
@@ -64,8 +58,7 @@ BucketOwnershipNotifier::sendNotifyBucketToDistributor(
vespalib::getStackTrace(0).c_str());
return;
}
- api::NotifyBucketChangeCommand::SP notifyCmd(
- new api::NotifyBucketChangeCommand(bucket, infoToSend));
+ auto notifyCmd = std::make_shared<api::NotifyBucketChangeCommand>(bucket, infoToSend);
notifyCmd->setAddress(api::StorageMessageAddress(
_component.getClusterName(),
diff --git a/storage/src/vespa/storage/persistence/bucketownershipnotifier.h b/storage/src/vespa/storage/persistence/bucketownershipnotifier.h
index 06faa2ed583..948fc54726f 100644
--- a/storage/src/vespa/storage/persistence/bucketownershipnotifier.h
+++ b/storage/src/vespa/storage/persistence/bucketownershipnotifier.h
@@ -12,40 +12,30 @@ namespace storage {
class BucketOwnershipNotifier
{
- ServiceLayerComponent& _component;
- MessageSender& _sender;
+ const ServiceLayerComponent & _component;
+ MessageSender & _sender;
public:
- BucketOwnershipNotifier(ServiceLayerComponent& component,
- MessageSender& sender)
+ BucketOwnershipNotifier(const ServiceLayerComponent& component, MessageSender& sender)
: _component(component),
_sender(sender)
{}
- bool distributorOwns(uint16_t distributor,
- const document::Bucket &bucket) const;
-
- void notifyIfOwnershipChanged(const document::Bucket &bucket,
- uint16_t sourceIndex,
- const api::BucketInfo& infoToSend);
-
- void sendNotifyBucketToCurrentOwner(const document::Bucket &bucket,
- const api::BucketInfo& infoToSend);
+ bool distributorOwns(uint16_t distributor, const document::Bucket &bucket) const;
+ void notifyIfOwnershipChanged(const document::Bucket &bucket, uint16_t sourceIndex, const api::BucketInfo& infoToSend);
+ void sendNotifyBucketToCurrentOwner(const document::Bucket &bucket, const api::BucketInfo& infoToSend);
private:
enum IndexMeta {
FAILED_TO_RESOLVE = 0xffff
};
- void sendNotifyBucketToDistributor(uint16_t distributorIndex,
- const document::Bucket &bucket,
+ void sendNotifyBucketToDistributor(uint16_t distributorIndex, const document::Bucket &bucket,
const api::BucketInfo& infoToSend);
// Returns either index or FAILED_TO_RESOLVE
uint16_t getOwnerDistributorForBucket(const document::Bucket &bucket) const;
- void logNotification(const document::Bucket &bucket,
- uint16_t sourceIndex,
- uint16_t currentOwnerIndex,
- const api::BucketInfo& newInfo);
+ void logNotification(const document::Bucket &bucket, uint16_t sourceIndex,
+ uint16_t currentOwnerIndex, const api::BucketInfo& newInfo);
};
/**
@@ -56,9 +46,7 @@ class NotificationGuard
{
struct BucketToCheck
{
- BucketToCheck(const document::Bucket& _bucket,
- uint16_t _sourceIndex,
- const api::BucketInfo& _info)
+ BucketToCheck(const document::Bucket& _bucket, uint16_t _sourceIndex, const api::BucketInfo& _info)
: bucket(_bucket),
info(_info),
sourceIndex(_sourceIndex),
@@ -66,29 +54,24 @@ class NotificationGuard
{}
document::Bucket bucket;
- api::BucketInfo info;
- uint16_t sourceIndex;
- bool alwaysSend;
+ api::BucketInfo info;
+ uint16_t sourceIndex;
+ bool alwaysSend;
};
BucketOwnershipNotifier& _notifier;
std::vector<BucketToCheck> _bucketsToCheck;
-
- NotificationGuard(const NotificationGuard&);
- NotificationGuard& operator=(const NotificationGuard&);
public:
NotificationGuard(BucketOwnershipNotifier& notifier)
: _notifier(notifier),
_bucketsToCheck()
{}
+ NotificationGuard(const NotificationGuard&) = delete;
+ NotificationGuard& operator=(const NotificationGuard&) = delete;
~NotificationGuard();
- void notifyIfOwnershipChanged(const document::Bucket &bucket,
- uint16_t sourceIndex,
- const api::BucketInfo& infoToSend);
-
- void notifyAlways(const document::Bucket &bucket,
- const api::BucketInfo& infoToSend);
+ void notifyIfOwnershipChanged(const document::Bucket &bucket, uint16_t sourceIndex, const api::BucketInfo& infoToSend);
+ void notifyAlways(const document::Bucket &bucket, const api::BucketInfo& infoToSend);
};
} // storage
diff --git a/storage/src/vespa/storage/persistence/persistenceutil.cpp b/storage/src/vespa/storage/persistence/persistenceutil.cpp
index 90339108272..a8b8cfa1f8c 100644
--- a/storage/src/vespa/storage/persistence/persistenceutil.cpp
+++ b/storage/src/vespa/storage/persistence/persistenceutil.cpp
@@ -158,11 +158,8 @@ MessageTracker::generateReply(api::StorageCommand& cmd)
}
}
-PersistenceUtil::PersistenceUtil(
- ServiceLayerComponent& component,
- FileStorHandler& fileStorHandler,
- FileStorThreadMetrics& metrics,
- spi::PersistenceProvider& provider)
+PersistenceUtil::PersistenceUtil(const ServiceLayerComponent& component, FileStorHandler& fileStorHandler,
+ FileStorThreadMetrics& metrics, spi::PersistenceProvider& provider)
: _component(component),
_fileStorHandler(fileStorHandler),
_metrics(metrics),
@@ -196,8 +193,7 @@ PersistenceUtil::updateBucketDatabase(const document::Bucket &bucket, const api:
}
PersistenceUtil::LockResult
-PersistenceUtil::lockAndGetDisk(const document::Bucket &bucket,
- StorBucketDatabase::Flag flags)
+PersistenceUtil::lockAndGetDisk(const document::Bucket &bucket, StorBucketDatabase::Flag flags)
{
// To lock the bucket, we need to ensure that we don't conflict with
// bucket disk move command. First we fetch current disk index from
diff --git a/storage/src/vespa/storage/persistence/persistenceutil.h b/storage/src/vespa/storage/persistence/persistenceutil.h
index 6a3d08a7e95..2dbd7b2a263 100644
--- a/storage/src/vespa/storage/persistence/persistenceutil.h
+++ b/storage/src/vespa/storage/persistence/persistenceutil.h
@@ -102,12 +102,8 @@ public:
bool bucketExisted() const { return bool(lock); }
};
- PersistenceUtil(
- ServiceLayerComponent&,
- FileStorHandler& fileStorHandler,
- FileStorThreadMetrics& metrics,
- spi::PersistenceProvider& provider);
-
+ PersistenceUtil(const ServiceLayerComponent&, FileStorHandler& fileStorHandler,
+ FileStorThreadMetrics& metrics, spi::PersistenceProvider& provider);
~PersistenceUtil();
StorBucketDatabase& getBucketDatabase(document::BucketSpace bucketSpace) const {
@@ -122,7 +118,7 @@ public:
static api::BucketInfo convertBucketInfo(const spi::BucketInfo&);
static uint32_t convertErrorCode(const spi::Result& response);
public:
- ServiceLayerComponent &_component;
+ const ServiceLayerComponent &_component;
FileStorHandler &_fileStorHandler;
FileStorThreadMetrics &_metrics; // Needs a better solution for speed and thread safety
uint16_t _nodeIndex;