diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index 375e37c5c4..3c57a12ece 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -924,7 +924,12 @@ DatabaseContext::DatabaseContext(Reference( - KeyRangeRef(LiteralStringRef("class/"), LiteralStringRef("class0")) + KeyRangeRef(LiteralStringRef("process/class_type/"), LiteralStringRef("process/class_type0")) + .withPrefix(SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::CONFIGURATION).begin))); + registerSpecialKeySpaceModule( + SpecialKeySpace::MODULE::CONFIGURATION, SpecialKeySpace::IMPLTYPE::READONLY, + std::make_unique( + KeyRangeRef(LiteralStringRef("process/class_source/"), LiteralStringRef("process/class_source0")) .withPrefix(SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::CONFIGURATION).begin))); } if (apiVersionAtLeast(630)) { diff --git a/fdbclient/SpecialKeySpace.actor.cpp b/fdbclient/SpecialKeySpace.actor.cpp index 46ab97b5d9..f1bad698e6 100644 --- a/fdbclient/SpecialKeySpace.actor.cpp +++ b/fdbclient/SpecialKeySpace.actor.cpp @@ -972,7 +972,7 @@ ACTOR Future> getProcessClassActor(ReadYourWritesTran KeyRangeRef kr) { vector _workers = wait(getWorkers(&ryw->getTransaction())); auto workers = _workers; // strip const - // TODO : the sort by string is anti intuition, ex. 1.1.1.1:11 < 1.1.1.1:5 + // Note : the sort by string is anti intuition, ex. 1.1.1.1:11 < 1.1.1.1:5 std::sort(workers.begin(), workers.end(), [](const ProcessData& lhs, const ProcessData& rhs) { return formatIpPort(lhs.address.ip, lhs.address.port) < formatIpPort(rhs.address.ip, rhs.address.port); }); @@ -1087,3 +1087,32 @@ void ProcessClassRangeImpl::clear(ReadYourWritesTransaction* ryw, const KeyRange void ProcessClassRangeImpl::clear(ReadYourWritesTransaction* ryw, const KeyRef& key) { return throwNotAllowedError(ryw); } + +ACTOR Future> getProcessClassSourceActor(ReadYourWritesTransaction* ryw, KeyRef prefix, + KeyRangeRef kr) { + vector _workers = wait(getWorkers(&ryw->getTransaction())); + auto workers = _workers; // strip const + // Note : the sort by string is anti intuition, ex. 1.1.1.1:11 < 1.1.1.1:5 + std::sort(workers.begin(), workers.end(), [](const ProcessData& lhs, const ProcessData& rhs) { + return formatIpPort(lhs.address.ip, lhs.address.port) < formatIpPort(rhs.address.ip, rhs.address.port); + }); + Standalone result; + for (auto& w : workers) { + // exclude :tls in keys even the network addresss is TLS + Key k(prefix.withSuffix(formatIpPort(w.address.ip, w.address.port))); + if (kr.contains(k)) { + Value v(w.processClass.sourceString()); + result.push_back(result.arena(), KeyValueRef(k, v)); + result.arena().dependsOn(k.arena()); + result.arena().dependsOn(v.arena()); + } + } + return result; +} + +ProcessClassSourceRangeImpl::ProcessClassSourceRangeImpl(KeyRangeRef kr) : SpecialKeyRangeReadImpl(kr) {} + +Future> ProcessClassSourceRangeImpl::getRange(ReadYourWritesTransaction* ryw, + KeyRangeRef kr) const { + return getProcessClassSourceActor(ryw, getKeyRange().begin, kr); +} \ No newline at end of file diff --git a/fdbclient/SpecialKeySpace.actor.h b/fdbclient/SpecialKeySpace.actor.h index c9fad65cad..39f868d312 100644 --- a/fdbclient/SpecialKeySpace.actor.h +++ b/fdbclient/SpecialKeySpace.actor.h @@ -289,5 +289,11 @@ public: void clear(ReadYourWritesTransaction* ryw, const KeyRef& key) override; }; +class ProcessClassSourceRangeImpl : public SpecialKeyRangeReadImpl { +public: + explicit ProcessClassSourceRangeImpl(KeyRangeRef kr); + Future> getRange(ReadYourWritesTransaction* ryw, KeyRangeRef kr) const override; +}; + #include "flow/unactorcompiler.h" #endif diff --git a/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp b/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp index e0e5b0b916..7f81f765ab 100644 --- a/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp +++ b/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp @@ -591,7 +591,7 @@ struct SpecialKeySpaceCorrectnessWorkload : TestWorkload { tx->setOption(FDBTransactionOptions::SPECIAL_KEY_SPACE_ENABLE_WRITES); // test getRange state Standalone result = wait(tx->getRange( - KeyRangeRef(LiteralStringRef("class/"), LiteralStringRef("class0")) + KeyRangeRef(LiteralStringRef("process/class_type/"), LiteralStringRef("process/class_type0")) .withPrefix(SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::CONFIGURATION).begin), CLIENT_KNOBS->TOO_MANY)); ASSERT(!result.more && result.size() < CLIENT_KNOBS->TOO_MANY); @@ -600,7 +600,7 @@ struct SpecialKeySpaceCorrectnessWorkload : TestWorkload { vector workers = wait(getWorkers(&tx->getTransaction())); for (const auto& worker : workers) { Key addr = - Key("class/" + formatIpPort(worker.address.ip, worker.address.port)) + Key("process/class_type/" + formatIpPort(worker.address.ip, worker.address.port)) .withPrefix(SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::CONFIGURATION).begin); bool found = false; for (const auto& kv : result) { @@ -615,7 +615,7 @@ struct SpecialKeySpaceCorrectnessWorkload : TestWorkload { } state ProcessData worker = deterministicRandom()->randomChoice(workers); state Key addr = - Key("class/" + formatIpPort(worker.address.ip, worker.address.port)) + Key("process/class_type/" + formatIpPort(worker.address.ip, worker.address.port)) .withPrefix(SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::CONFIGURATION).begin); tx->set(addr, LiteralStringRef("InvalidProcessType")); // test ryw