introduce DDContext to store shared state

This commit is contained in:
Xiaoxi Wang 2022-08-01 12:22:21 -07:00
parent 647272afff
commit 6d8008ddc1
2 changed files with 29 additions and 1 deletions

View File

@ -404,6 +404,34 @@ struct IDDQueue {
virtual ~IDDQueue() = 0;
};
// The common info shared by all DD components. Normally the DD components should share the reference to the same
// context.
struct DDContext : public ReferenceCounted<DDContext> {
// FIXME(xwang) mark fields privates
// private:
std::shared_ptr<DDEnabledState> ddEnabledState; // Note: don't operate directly because it's shared with snapshot server
IDDTracker::Interface trackerInterface;
IDDQueue::Interface queueInterface;
// public:
UID ddId;
MoveKeysLock lock;
DatabaseConfiguration configuration;
Reference<ShardsAffectedByTeamFailure> shardsAffectedByTeamFailure;
Reference<AsyncVar<bool>> processingUnhealthy, processingWiggle;
DDContext() = default;
DDContext(UID id, std::shared_ptr<DDEnabledState> ddEnabledState)
: ddEnabledState(std::move(ddEnabledState)), ddId(id), shardsAffectedByTeamFailure(new ShardsAffectedByTeamFailure),
processingUnhealthy(new AsyncVar<bool>(false)), processingWiggle(new AsyncVar<bool>(false)) {}
void initTeamCollectionStates();
void proposeRelocation(const RelocateShard& rs) const { return queueInterface.relocationProducer.send(rs); }
void restartShardTrackerAsync(KeyRange keys) const { return trackerInterface.restartShardTracker.send(keys); }
};
#ifndef __INTEL_COMPILER
#pragma endregion
#endif

View File

@ -42,7 +42,7 @@ struct MoveKeysLock {
}
};
class DDEnabledState: ReferenceCounted<DDEnabledState> {
class DDEnabledState {
// in-memory flag to disable DD
bool ddEnabled = true;
UID ddEnabledStatusUID;