Replace all \xff\xff/conf with managementApiRange.begin

This commit is contained in:
Chaoguang Lin 2020-07-17 11:56:27 -07:00
parent 4d993771e4
commit 96e5a4c827
4 changed files with 17 additions and 24 deletions

View File

@ -1286,8 +1286,8 @@ ACTOR Future<Void> excludeServers(Database cx, vector<AddressExclusion> servers,
: LiteralStringRef("\xff\xff/conf/options/exclude/force");
ryw.set(optionKey, ValueRef());
for(auto& s : servers) {
Key addr = failed ? SpecialKeySpace::getCommandPrefix("failed").withSuffix(s.toString())
: SpecialKeySpace::getCommandPrefix("exclude").withSuffix(s.toString());
Key addr = failed ? SpecialKeySpace::getManagementApiCommandPrefix("failed").withSuffix(s.toString())
: SpecialKeySpace::getManagementApiCommandPrefix("exclude").withSuffix(s.toString());
ryw.set(addr, ValueRef());
}
TraceEvent("ExcludeServersSpecialKeySpaceCommit").detail("Servers", describe(servers)).detail("ExcludeFailed", failed);
@ -1326,7 +1326,8 @@ ACTOR Future<Void> includeServers(Database cx, vector<AddressExclusion> servers,
ryw.clear(excludedServersKeys.withPrefix(normalKeys.end));
}
} else {
Key addr = failed ? SpecialKeySpace::getCommandPrefix("failed").withSuffix(s.toString()) : SpecialKeySpace::getCommandPrefix("exclude").withSuffix(s.toString());
Key addr = failed ? SpecialKeySpace::getManagementApiCommandPrefix("failed").withSuffix(s.toString())
: SpecialKeySpace::getManagementApiCommandPrefix("exclude").withSuffix(s.toString());
ryw.clear(addr);
// Eliminate both any ip-level exclusion (1.2.3.4) and any
// port-level exclusions (1.2.3.4:5)

View File

@ -908,20 +908,16 @@ DatabaseContext::DatabaseContext(Reference<AsyncVar<Reference<ClusterConnectionF
));
registerSpecialKeySpaceModule(SpecialKeySpace::MODULE::MANAGEMENT,
std::make_unique<ManagementCommandsOptionsImpl>(KeyRangeRef(
LiteralStringRef("\xff\xff/conf/options/"), LiteralStringRef("\xff\xff/conf/options0")
)), true);
LiteralStringRef("options/"), LiteralStringRef("options0")
).withPrefix(managementApiRange.begin)), true);
registerSpecialKeySpaceModule(SpecialKeySpace::MODULE::MANAGEMENT,
std::make_unique<ExcludeServersRangeImpl>(KeyRangeRef(
LiteralStringRef("\xff\xff/conf/excluded/"), LiteralStringRef("\xff\xff/conf/excluded0")
)), true);
std::make_unique<ExcludeServersRangeImpl>(SpecialKeySpace::getManamentApiCommandRange("exclude")), true);
registerSpecialKeySpaceModule(SpecialKeySpace::MODULE::MANAGEMENT,
std::make_unique<FailedServersRangeImpl>(KeyRangeRef(
LiteralStringRef("\xff\xff/conf/failed/"), LiteralStringRef("\xff\xff/conf/failed0")
)), true);
std::make_unique<FailedServersRangeImpl>(SpecialKeySpace::getManamentApiCommandRange("failed")), true);
registerSpecialKeySpaceModule(SpecialKeySpace::MODULE::MANAGEMENT,
std::make_unique<ExclusionInProgressRangeImpl>(KeyRangeRef(
LiteralStringRef("\xff\xff/conf/inProgressExclusion/"), LiteralStringRef("\xff\xff/conf/inProgressExclusion0")
)));
LiteralStringRef("inProgressExclusion/"), LiteralStringRef("inProgressExclusion0")
).withPrefix(managementApiRange.begin)));
}
if (apiVersionAtLeast(630)) {
registerSpecialKeySpaceModule(SpecialKeySpace::MODULE::TRANSACTION, std::make_unique<ConflictingKeysImpl>(conflictingKeysRange));

View File

@ -34,15 +34,13 @@ std::unordered_map<SpecialKeySpace::MODULE, KeyRange> SpecialKeySpace::moduleToB
{ SpecialKeySpace::MODULE::CLUSTERFILEPATH, singleKeyRange(LiteralStringRef("\xff\xff/cluster_file_path")) },
{ SpecialKeySpace::MODULE::METRICS,
KeyRangeRef(LiteralStringRef("\xff\xff/metrics/"), LiteralStringRef("\xff\xff/metrics0")) },
{ SpecialKeySpace::MODULE::MANAGEMENT,
KeyRangeRef(LiteralStringRef("\xff\xff/conf/"), LiteralStringRef("\xff\xff/conf0")) },
{ SpecialKeySpace::MODULE::MANAGEMENT, managementApiRange },
{ SpecialKeySpace::MODULE::FAILURE, singleKeyRange(LiteralStringRef("\xff\xff/failure")) }
};
std::unordered_map<std::string, Key> SpecialKeySpace::commandToPrefix = {
{ "exclude",
moduleToBoundary[SpecialKeySpace::MODULE::MANAGEMENT].begin.withSuffix(LiteralStringRef("excluded/")) },
{ "failed", moduleToBoundary[SpecialKeySpace::MODULE::MANAGEMENT].begin.withSuffix(LiteralStringRef("failed/")) }
std::unordered_map<std::string, KeyRange> SpecialKeySpace::managementApiCommandToRange = {
{ "exclude", KeyRangeRef(LiteralStringRef("excluded/"), LiteralStringRef("excluded0")).withPrefix(managementApiRange.begin) },
{ "failed", KeyRangeRef(LiteralStringRef("failed/"), LiteralStringRef("failed0")).withPrefix(managementApiRange.begin) }
};
// This function will move the given KeySelector as far as possible to the standard form:

View File

@ -154,7 +154,8 @@ public:
KeyRangeMap<SpecialKeyRangeRWImpl*>& getRWImpls() { return writeImpls; }
KeyRangeMap<SpecialKeySpace::MODULE>& getModules() { return modules; }
KeyRangeRef getKeyRange() const { return range; }
static Key getCommandPrefix(std::string command) { return commandToPrefix.at(command); }
static KeyRange getManamentApiCommandRange(std::string command) { return managementApiCommandToRange.at(command); }
static Key getManagementApiCommandPrefix(std::string command) { return managementApiCommandToRange.at(command).begin; }
private:
ACTOR static Future<Optional<Value>> getActor(SpecialKeySpace* sks, ReadYourWritesTransaction* ryw, KeyRef key);
@ -173,7 +174,7 @@ private:
KeyRange range; // key space range, (\xff\xff, \xff\xff\xff\xf) in prod and (, \xff) in test
static std::unordered_map<SpecialKeySpace::MODULE, KeyRange> moduleToBoundary;
static std::unordered_map<std::string, Key> commandToPrefix; // management command prefix for special keys
static std::unordered_map<std::string, KeyRange> managementApiCommandToRange; // management command to its special keys' range
// Initialize module boundaries, used to handle cross_module_read
void modulesBoundaryInit();
@ -217,9 +218,6 @@ public:
void clear(ReadYourWritesTransaction* ryw, const KeyRangeRef& range) override;
void clear(ReadYourWritesTransaction* ryw, const KeyRef& key) override;
Future<Optional<std::string>> commit(ReadYourWritesTransaction* ryw) override;
// // Given a command name and its option name, returns the special key we use to set.
// // No key will be returned if there is no such a mapping
// Optional<Key> getOptionSpecialKey(const std::string& command, const std::string& option);
private:
static std::unordered_set<std::string> options; // "<command>/<option>"