aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-02-19 13:51:45 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-02-19 14:13:19 +0000
commitb206dd0a2b7610618079162cff55c9ed68a81920 (patch)
tree40503cd6fbcf9f06e22550f8fe1481410a0d5ae6 /searchcore
parentf124b885f64530ff3167512b12fb3ffc98818415 (diff)
Use a trinary to also handle temporary mismatching bucket used bits.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/documentdb/clusterstatehandler/clusterstatehandler_test.cpp8
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp8
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/buckethandler.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp31
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/bucketmovejob.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/bucketmovejobv2.cpp26
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/bucketmovejobv2.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/clusterstatehandler.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp23
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/combiningfeedview.h8
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentdb.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentdb.h16
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/ibucketstatecalculator.h5
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/iclusterstatechangedhandler.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job_base.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job_base.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/test/bucketstatecalculator.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/test/clusterstatehandler.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/test/clusterstatehandler.h25
19 files changed, 96 insertions, 79 deletions
diff --git a/searchcore/src/tests/proton/documentdb/clusterstatehandler/clusterstatehandler_test.cpp b/searchcore/src/tests/proton/documentdb/clusterstatehandler/clusterstatehandler_test.cpp
index dc4e88ae005..57bab0607d3 100644
--- a/searchcore/src/tests/proton/documentdb/clusterstatehandler/clusterstatehandler_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/clusterstatehandler/clusterstatehandler_test.cpp
@@ -18,9 +18,9 @@ using storage::spi::Result;
struct MyClusterStateChangedHandler : public IClusterStateChangedHandler
{
- IBucketStateCalculator::SP _calc;
- virtual void
- notifyClusterStateChanged(const IBucketStateCalculator::SP &newCalc) override {
+ std::shared_ptr<IBucketStateCalculator> _calc;
+ void
+ notifyClusterStateChanged(const std::shared_ptr<IBucketStateCalculator> &newCalc) override {
_calc = newCalc;
}
};
@@ -61,7 +61,7 @@ TEST_F("require that cluster state change is notified", Fixture)
{
f._stateHandler.handleSetClusterState(clusterState, f._genericHandler);
f._exec.sync();
- EXPECT_TRUE(f._changedHandler._calc.get() != NULL);
+ EXPECT_TRUE(f._changedHandler._calc);
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp b/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp
index b639ae17bde..bedaea3fe75 100644
--- a/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp
@@ -66,7 +66,7 @@ BucketHandler::BucketHandler(vespalib::Executor &executor)
: IClusterStateChangedHandler(),
IBucketStateChangedNotifier(),
_executor(executor),
- _ready(NULL),
+ _ready(nullptr),
_changedHandlers(),
_nodeUp(false)
{
@@ -139,13 +139,11 @@ BucketHandler::handlePopulateActiveBuckets(document::BucketId::List &buckets,
}
void
-BucketHandler::notifyClusterStateChanged(const IBucketStateCalculator::SP & newCalc)
+BucketHandler::notifyClusterStateChanged(const std::shared_ptr<IBucketStateCalculator> & newCalc)
{
bool oldNodeUp = _nodeUp;
_nodeUp = newCalc->nodeUp();
- LOG(spam, "notifyClusterStateChanged: %s -> %s",
- oldNodeUp ? "up" : "down",
- _nodeUp ? "up" : "down");
+ LOG(spam, "notifyClusterStateChanged: %s -> %s", oldNodeUp ? "up" : "down", _nodeUp ? "up" : "down");
if (oldNodeUp && !_nodeUp) {
deactivateAllActiveBuckets();
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/buckethandler.h b/searchcore/src/vespa/searchcore/proton/server/buckethandler.h
index 1732a6cdd54..ec23447c3ac 100644
--- a/searchcore/src/vespa/searchcore/proton/server/buckethandler.h
+++ b/searchcore/src/vespa/searchcore/proton/server/buckethandler.h
@@ -63,7 +63,7 @@ public:
IGenericResultHandler &resultHandler);
// Implements IClusterStateChangedHandler
- void notifyClusterStateChanged(const IBucketStateCalculator::SP &newCalc) override;
+ void notifyClusterStateChanged(const std::shared_ptr<IBucketStateCalculator> &newCalc) override;
// Implement IBucketStateChangedNotifier
void addBucketStateChangedHandler(IBucketStateChangedHandler *handler) override;
diff --git a/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp b/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp
index 30b1e8b623c..1ca4c307bfb 100644
--- a/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp
@@ -16,12 +16,21 @@ LOG_SETUP(".proton.server.bucketmovejob");
using document::BucketId;
using storage::spi::BucketInfo;
+using vespalib::Trinary;
namespace proton {
namespace {
-const char * bool2str(bool v) { return (v ? "T" : "F"); }
+const char *
+toStr(bool v) {
+ return (v ? "T" : "F");
+}
+
+const char *
+toStr(Trinary v) {
+ return (v == Trinary::True) ? "T" : ((v == Trinary::False) ? "F" : "U");
+}
}
@@ -42,10 +51,13 @@ BucketMoveJob::checkBucket(const BucketId &bucket,
if (_calc->nodeRetired() && !isActive) {
return;
}
- const bool shouldBeReady = _calc->shouldBeReady(document::Bucket(_bucketSpace, bucket));
- const bool wantReady = shouldBeReady || isActive;
+ Trinary shouldBeReady = _calc->shouldBeReady(document::Bucket(_bucketSpace, bucket));
+ if (shouldBeReady == vespalib::Trinary::Undefined) {
+ return;
+ }
+ const bool wantReady = (shouldBeReady == Trinary::True) || isActive;
LOG(spam, "checkBucket(): bucket(%s), shouldBeReady(%s), active(%s)",
- bucket.toString().c_str(), bool2str(shouldBeReady), bool2str(isActive));
+ bucket.toString().c_str(), toStr(shouldBeReady), toStr(isActive));
if (wantReady) {
if (!hasNotReadyDocs)
return; // No notready bucket to make ready
@@ -115,7 +127,7 @@ BucketMoveJob::moveDocuments(DocumentBucketMover &mover,
namespace {
bool
-blockedDueToClusterState(const IBucketStateCalculator::SP &calc)
+blockedDueToClusterState(const std::shared_ptr<IBucketStateCalculator> &calc)
{
bool clusterUp = calc.get() != nullptr && calc->clusterUp();
bool nodeUp = calc.get() != nullptr && calc->nodeUp();
@@ -126,7 +138,7 @@ blockedDueToClusterState(const IBucketStateCalculator::SP &calc)
}
BucketMoveJob::
-BucketMoveJob(const IBucketStateCalculator::SP &calc,
+BucketMoveJob(const std::shared_ptr<IBucketStateCalculator> &calc,
IDocumentMoveHandler &moveHandler,
IBucketModifiedHandler &modifiedHandler,
const MaintenanceDocumentSubDB &ready,
@@ -191,8 +203,11 @@ BucketMoveJob::maybeCancelMover(DocumentBucketMover &mover)
// Cancel bucket if moving in wrong direction
if (!mover.bucketDone()) {
bool ready = mover.getSource() == &_ready;
+ Trinary shouldBeReady = _calc->shouldBeReady(document::Bucket(_bucketSpace, mover.getBucket()));
if (isBlocked() ||
- _calc->shouldBeReady(document::Bucket(_bucketSpace, mover.getBucket())) == ready) {
+ (shouldBeReady == Trinary::Undefined) ||
+ (ready == (shouldBeReady == Trinary::True)))
+ {
mover.cancel();
}
}
@@ -319,7 +334,7 @@ BucketMoveJob::run()
}
void
-BucketMoveJob::notifyClusterStateChanged(const IBucketStateCalculator::SP &newCalc)
+BucketMoveJob::notifyClusterStateChanged(const std::shared_ptr<IBucketStateCalculator> &newCalc)
{
// Called by master write thread
_calc = newCalc;
diff --git a/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.h b/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.h
index 0a2af6e1535..7ef1a491667 100644
--- a/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.h
+++ b/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.h
@@ -95,7 +95,7 @@ private:
void activateBucket(document::BucketId bucket);
public:
- BucketMoveJob(const IBucketStateCalculator::SP &calc,
+ BucketMoveJob(const std::shared_ptr<IBucketStateCalculator> &calc,
IDocumentMoveHandler &moveHandler,
IBucketModifiedHandler &modifiedHandler,
const MaintenanceDocumentSubDB &ready,
@@ -127,7 +127,7 @@ public:
bool run() override;
// IClusterStateChangedHandler API
- void notifyClusterStateChanged(const IBucketStateCalculator::SP &newCalc) override;
+ void notifyClusterStateChanged(const std::shared_ptr<IBucketStateCalculator> &newCalc) override;
// IBucketFreezeListener API
void notifyThawedBucket(const document::BucketId &bucket) override;
diff --git a/searchcore/src/vespa/searchcore/proton/server/bucketmovejobv2.cpp b/searchcore/src/vespa/searchcore/proton/server/bucketmovejobv2.cpp
index 81e903097c2..1bbfe91c223 100644
--- a/searchcore/src/vespa/searchcore/proton/server/bucketmovejobv2.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/bucketmovejobv2.cpp
@@ -26,15 +26,24 @@ using storage::spi::Bucket;
using storage::spi::makeBucketTask;
using proton::bucketdb::BucketMover;
using vespalib::makeLambdaTask;
+using vespalib::Trinary;
namespace proton {
namespace {
-const char * bool2str(bool v) { return (v ? "T" : "F"); }
+const char *
+toStr(bool v) {
+ return (v ? "T" : "F");
+}
+
+const char *
+toStr(Trinary v) {
+ return (v == Trinary::True) ? "T" : ((v == Trinary::False) ? "F" : "U");
+}
bool
-blockedDueToClusterState(const IBucketStateCalculator::SP &calc)
+blockedDueToClusterState(const std::shared_ptr<IBucketStateCalculator> &calc)
{
bool clusterUp = calc && calc->clusterUp();
bool nodeUp = calc && calc->nodeUp();
@@ -44,7 +53,7 @@ blockedDueToClusterState(const IBucketStateCalculator::SP &calc)
}
-BucketMoveJobV2::BucketMoveJobV2(const IBucketStateCalculator::SP &calc,
+BucketMoveJobV2::BucketMoveJobV2(const std::shared_ptr<IBucketStateCalculator> &calc,
IDocumentMoveHandler &moveHandler,
IBucketModifiedHandler &modifiedHandler,
IThreadService & master,
@@ -116,10 +125,13 @@ BucketMoveJobV2::needMove(const ScanIterator &itr) const {
if (!_calc || (_calc->nodeRetired() && !isActive)) {
return noMove;
}
- const bool shouldBeReady = _calc->shouldBeReady(document::Bucket(_bucketSpace, itr.getBucket()));
- const bool wantReady = shouldBeReady || isActive;
+ const Trinary shouldBeReady = _calc->shouldBeReady(document::Bucket(_bucketSpace, itr.getBucket()));
+ if (shouldBeReady == Trinary::Undefined) {
+ return noMove;
+ }
+ const bool wantReady = (shouldBeReady == Trinary::True) || isActive;
LOG(spam, "checkBucket(): bucket(%s), shouldBeReady(%s), active(%s)",
- itr.getBucket().toString().c_str(), bool2str(shouldBeReady), bool2str(isActive));
+ itr.getBucket().toString().c_str(), toStr(shouldBeReady), toStr(isActive));
if (wantReady) {
if (!hasNotReadyDocs) {
return noMove; // No notready bucket to make ready
@@ -328,7 +340,7 @@ BucketMoveJobV2::backFillMovers() {
}
}
void
-BucketMoveJobV2::notifyClusterStateChanged(const IBucketStateCalculator::SP &newCalc)
+BucketMoveJobV2::notifyClusterStateChanged(const std::shared_ptr<IBucketStateCalculator> &newCalc)
{
// Called by master write thread
_calc = newCalc;
diff --git a/searchcore/src/vespa/searchcore/proton/server/bucketmovejobv2.h b/searchcore/src/vespa/searchcore/proton/server/bucketmovejobv2.h
index 714f24b6ff6..e20e6eeaf42 100644
--- a/searchcore/src/vespa/searchcore/proton/server/bucketmovejobv2.h
+++ b/searchcore/src/vespa/searchcore/proton/server/bucketmovejobv2.h
@@ -86,7 +86,7 @@ private:
void cancelMovesForBucket(BucketId bucket);
bool moveDocs(size_t maxDocsToMove);
public:
- BucketMoveJobV2(const IBucketStateCalculator::SP &calc,
+ BucketMoveJobV2(const std::shared_ptr<IBucketStateCalculator> &calc,
IDocumentMoveHandler &moveHandler,
IBucketModifiedHandler &modifiedHandler,
IThreadService & master,
@@ -109,7 +109,7 @@ public:
bool inSync() const;
bool run() override;
- void notifyClusterStateChanged(const IBucketStateCalculator::SP &newCalc) override;
+ void notifyClusterStateChanged(const std::shared_ptr<IBucketStateCalculator> &newCalc) override;
void notifyBucketStateChanged(const BucketId &bucketId, ActiveState newState) override;
void notifyDiskMemUsage(DiskMemUsageState state) override;
void notifyCreateBucket(const bucketdb::Guard & guard, const BucketId &bucket) override;
diff --git a/searchcore/src/vespa/searchcore/proton/server/clusterstatehandler.cpp b/searchcore/src/vespa/searchcore/proton/server/clusterstatehandler.cpp
index 577bd32ca1f..49baa73fa43 100644
--- a/searchcore/src/vespa/searchcore/proton/server/clusterstatehandler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/clusterstatehandler.cpp
@@ -37,7 +37,7 @@ public:
_nodeRetired(_calc.nodeRetired())
{
}
- bool shouldBeReady(const document::Bucket &bucket) const override {
+ vespalib::Trinary shouldBeReady(const document::Bucket &bucket) const override {
return _calc.shouldBeReady(Bucket(bucket));
}
bool clusterUp() const override { return _clusterUp; }
diff --git a/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp b/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp
index 309704958a8..c5e32494fe3 100644
--- a/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp
@@ -13,6 +13,7 @@ LOG_SETUP(".proton.server.combiningfeedview");
using document::DocumentTypeRepo;
using document::DocumentId;
using vespalib::IDestructorCallback;
+using vespalib::Trinary;
namespace proton {
@@ -29,11 +30,16 @@ getRepo(const std::vector<IFeedView::SP> &views)
LOG_ABORT("should not be reached");
}
-};
+const char *
+toStr(Trinary v) {
+ return (v == Trinary::True) ? "true" : ((v == Trinary::False) ? "false" : "undefined");
+}
+
+}
CombiningFeedView::CombiningFeedView(const std::vector<IFeedView::SP> &views,
document::BucketSpace bucketSpace,
- const IBucketStateCalculator::SP &calc)
+ const std::shared_ptr<IBucketStateCalculator> &calc)
: _repo(getRepo(views)),
_views(views),
_metaStores(),
@@ -99,7 +105,7 @@ CombiningFeedView::getDocumentTypeRepo() const
void
CombiningFeedView::preparePut(PutOperation &putOp)
{
- if (shouldBeReady(putOp.getBucketId())) {
+ if (shouldBeReady(putOp.getBucketId()) == Trinary::True) {
getReadyFeedView()->preparePut(putOp);
} else {
getNotReadyFeedView()->preparePut(putOp);
@@ -250,7 +256,7 @@ CombiningFeedView::handleCompactLidSpace(const CompactLidSpaceOperation &op)
}
void
-CombiningFeedView::setCalculator(const IBucketStateCalculator::SP &newCalc)
+CombiningFeedView::setCalculator(const std::shared_ptr<IBucketStateCalculator> &newCalc)
{
// Called by document db executor
_calc = newCalc;
@@ -258,7 +264,7 @@ CombiningFeedView::setCalculator(const IBucketStateCalculator::SP &newCalc)
_forceReady = !_clusterUp || !hasNotReadyFeedView();
}
-bool
+Trinary
CombiningFeedView::shouldBeReady(const document::BucketId &bucket) const
{
document::Bucket dbucket(_bucketSpace, bucket);
@@ -267,11 +273,10 @@ CombiningFeedView::shouldBeReady(const document::BucketId &bucket) const
bucket.toString().c_str(),
(_forceReady ? "true" : "false"),
(_clusterUp ? "true" : "false"),
- (_calc ? (_calc->shouldBeReady(dbucket) ? "true" : "false") : "null"));
- const documentmetastore::IBucketHandler *readyMetaStore =
- _metaStores[getReadyFeedViewId()];
+ (_calc ? toStr(_calc->shouldBeReady(dbucket)) : "null"));
+ const documentmetastore::IBucketHandler *readyMetaStore = _metaStores[getReadyFeedViewId()];
bool isActive = readyMetaStore->getBucketDB().takeGuard()->isActiveBucket(bucket);
- return _forceReady || isActive || _calc->shouldBeReady(dbucket);
+ return (_forceReady || isActive) ? Trinary::True : _calc->shouldBeReady(dbucket);
}
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.h b/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.h
index 6ae32757073..1e91aab0107 100644
--- a/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.h
+++ b/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.h
@@ -20,7 +20,7 @@ private:
const std::shared_ptr<const document::DocumentTypeRepo> _repo;
std::vector<IFeedView::SP> _views;
std::vector<const ISimpleDocumentMetaStore *> _metaStores;
- IBucketStateCalculator::SP _calc;
+ std::shared_ptr<IBucketStateCalculator> _calc;
bool _clusterUp;
bool _forceReady;
document::BucketSpace _bucketSpace;
@@ -48,14 +48,14 @@ private:
return _views.size() > getNotReadyFeedViewId();
}
- bool shouldBeReady(const document::BucketId &bucket) const;
+ vespalib::Trinary shouldBeReady(const document::BucketId &bucket) const;
void forceCommit(search::SerialNum serialNum, DoneCallback onDone) override;
public:
typedef std::shared_ptr<CombiningFeedView> SP;
CombiningFeedView(const std::vector<IFeedView::SP> &views,
document::BucketSpace bucketSpace,
- const IBucketStateCalculator::SP &calc);
+ const std::shared_ptr<IBucketStateCalculator> &calc);
~CombiningFeedView() override;
@@ -81,7 +81,7 @@ public:
void handleCompactLidSpace(const CompactLidSpaceOperation &op) override;
// Called by document db executor
- void setCalculator(const IBucketStateCalculator::SP &newCalc);
+ void setCalculator(const std::shared_ptr<IBucketStateCalculator> &newCalc);
};
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
index 8899162d66d..55ce842e0cf 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
@@ -986,7 +986,7 @@ DocumentDB::forwardMaintenanceConfig()
}
void
-DocumentDB::notifyClusterStateChanged(const IBucketStateCalculator::SP &newCalc)
+DocumentDB::notifyClusterStateChanged(const std::shared_ptr<IBucketStateCalculator> &newCalc)
{
// Called by executor thread
_calc = newCalc; // Save for maintenance job injection
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.h b/searchcore/src/vespa/searchcore/proton/server/documentdb.h
index b5d975884a3..3fec997d1bc 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentdb.h
+++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.h
@@ -120,13 +120,13 @@ private:
DiskMemUsageForwarder _dmUsageForwarder;
AttributeUsageFilter _writeFilter;
std::shared_ptr<TransientMemoryUsageProvider> _transient_memory_usage_provider;
- std::unique_ptr<FeedHandler> _feedHandler;
- DocumentSubDBCollection _subDBs;
- MaintenanceController _maintenanceController;
- ILidSpaceCompactionHandler::Vector _lidSpaceCompactionHandlers;
- DocumentDBJobTrackers _jobTrackers;
- IBucketStateCalculator::SP _calc;
- DocumentDBMetricsUpdater _metricsUpdater;
+ std::unique_ptr<FeedHandler> _feedHandler;
+ DocumentSubDBCollection _subDBs;
+ MaintenanceController _maintenanceController;
+ ILidSpaceCompactionHandler::Vector _lidSpaceCompactionHandlers;
+ DocumentDBJobTrackers _jobTrackers;
+ std::shared_ptr<IBucketStateCalculator> _calc;
+ DocumentDBMetricsUpdater _metricsUpdater;
void registerReference();
void setActiveConfig(const DocumentDBConfig::SP &config, int64_t generation);
@@ -190,7 +190,7 @@ private:
/**
* Implements IClusterStateChangedHandler
*/
- void notifyClusterStateChanged(const IBucketStateCalculator::SP &newCalc) override;
+ void notifyClusterStateChanged(const std::shared_ptr<IBucketStateCalculator> &newCalc) override;
void notifyAllBucketsChanged();
/*
diff --git a/searchcore/src/vespa/searchcore/proton/server/ibucketstatecalculator.h b/searchcore/src/vespa/searchcore/proton/server/ibucketstatecalculator.h
index 15211c8ceb7..1ef3c00b2c9 100644
--- a/searchcore/src/vespa/searchcore/proton/server/ibucketstatecalculator.h
+++ b/searchcore/src/vespa/searchcore/proton/server/ibucketstatecalculator.h
@@ -2,7 +2,7 @@
#pragma once
-#include <memory>
+#include <vespa/vespalib/util/trinary.h>
namespace document { class Bucket; }
@@ -10,8 +10,7 @@ namespace proton {
struct IBucketStateCalculator
{
- typedef std::shared_ptr<IBucketStateCalculator> SP;
- virtual bool shouldBeReady(const document::Bucket &bucket) const = 0;
+ virtual vespalib::Trinary shouldBeReady(const document::Bucket &bucket) const = 0;
virtual bool clusterUp() const = 0;
virtual bool nodeUp() const = 0;
virtual bool nodeInitializing() const = 0;
diff --git a/searchcore/src/vespa/searchcore/proton/server/iclusterstatechangedhandler.h b/searchcore/src/vespa/searchcore/proton/server/iclusterstatechangedhandler.h
index 16c98054a11..4664403f5cf 100644
--- a/searchcore/src/vespa/searchcore/proton/server/iclusterstatechangedhandler.h
+++ b/searchcore/src/vespa/searchcore/proton/server/iclusterstatechangedhandler.h
@@ -3,6 +3,7 @@
#pragma once
#include "ibucketstatecalculator.h"
+#include <memory>
namespace proton {
diff --git a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job_base.cpp b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job_base.cpp
index bf93ceca6d8..99efc3d4e41 100644
--- a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job_base.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job_base.cpp
@@ -162,7 +162,7 @@ LidSpaceCompactionJobBase::notifyDiskMemUsage(DiskMemUsageState state)
}
void
-LidSpaceCompactionJobBase::notifyClusterStateChanged(const IBucketStateCalculator::SP &newCalc)
+LidSpaceCompactionJobBase::notifyClusterStateChanged(const std::shared_ptr<IBucketStateCalculator> &newCalc)
{
// Called by master write thread
bool nodeRetired = newCalc->nodeRetired();
diff --git a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job_base.h b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job_base.h
index e91502f766c..774d82a5d1d 100644
--- a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job_base.h
+++ b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job_base.h
@@ -64,7 +64,7 @@ public:
~LidSpaceCompactionJobBase() override;
void notifyDiskMemUsage(DiskMemUsageState state) override;
- void notifyClusterStateChanged(const IBucketStateCalculator::SP &newCalc) override;
+ void notifyClusterStateChanged(const std::shared_ptr<IBucketStateCalculator> &newCalc) override;
bool run() override;
};
diff --git a/searchcore/src/vespa/searchcore/proton/test/bucketstatecalculator.h b/searchcore/src/vespa/searchcore/proton/test/bucketstatecalculator.h
index 8a5a46946d8..de72220ffed 100644
--- a/searchcore/src/vespa/searchcore/proton/test/bucketstatecalculator.h
+++ b/searchcore/src/vespa/searchcore/proton/test/bucketstatecalculator.h
@@ -57,9 +57,9 @@ public:
void resetAsked() { _asked.clear(); }
// Implements IBucketStateCalculator
- bool shouldBeReady(const document::Bucket &bucket) const override {
+ vespalib::Trinary shouldBeReady(const document::Bucket &bucket) const override {
_asked.push_back(bucket.getBucketId());
- return _ready.count(bucket.getBucketId()) == 1;
+ return (_ready.count(bucket.getBucketId()) == 1) ? vespalib::Trinary::True : vespalib::Trinary::False;
}
bool clusterUp() const override { return _clusterUp; }
diff --git a/searchcore/src/vespa/searchcore/proton/test/clusterstatehandler.cpp b/searchcore/src/vespa/searchcore/proton/test/clusterstatehandler.cpp
index a35d2463da6..88d52afd612 100644
--- a/searchcore/src/vespa/searchcore/proton/test/clusterstatehandler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/test/clusterstatehandler.cpp
@@ -32,7 +32,7 @@ removeClusterStateChangedHandler(IClusterStateChangedHandler *handler)
void
ClusterStateHandler::
-notifyClusterStateChanged(const IBucketStateCalculator::SP &newCalc)
+notifyClusterStateChanged(const std::shared_ptr<IBucketStateCalculator> &newCalc)
{
for (auto &handler : _handlers) {
handler->notifyClusterStateChanged(newCalc);
diff --git a/searchcore/src/vespa/searchcore/proton/test/clusterstatehandler.h b/searchcore/src/vespa/searchcore/proton/test/clusterstatehandler.h
index 73d31913f85..29aad7e982e 100644
--- a/searchcore/src/vespa/searchcore/proton/test/clusterstatehandler.h
+++ b/searchcore/src/vespa/searchcore/proton/test/clusterstatehandler.h
@@ -6,11 +6,7 @@
#include <vespa/searchcore/proton/server/iclusterstatechangedhandler.h>
#include <set>
-namespace proton
-{
-
-namespace test
-{
+namespace proton::test {
/**
* Test cluster state handler that forwards cluster state change
@@ -21,21 +17,12 @@ class ClusterStateHandler : public IClusterStateChangedNotifier
std::set<IClusterStateChangedHandler *> _handlers;
public:
ClusterStateHandler();
+ ~ClusterStateHandler() override;
- virtual
- ~ClusterStateHandler();
-
- virtual void
- addClusterStateChangedHandler(IClusterStateChangedHandler *handler) override;
-
- virtual void
- removeClusterStateChangedHandler(IClusterStateChangedHandler *handler) override;
-
- void
- notifyClusterStateChanged(const IBucketStateCalculator::SP &newCalc);
+ void addClusterStateChangedHandler(IClusterStateChangedHandler *handler) override;
+ void removeClusterStateChangedHandler(IClusterStateChangedHandler *handler) override;
+ void notifyClusterStateChanged(const std::shared_ptr<IBucketStateCalculator> &newCalc);
};
-} // namespace test
-
-} // namespace proton
+}