| 40 | GlobalConfig::GlobalConfig(DatabaseContext* cx) : cx(cx), lastUpdate(0) {} |
| 41 | |
| 42 | void GlobalConfig::applyChanges(Transaction& tr, |
| 43 | const VectorRef<KeyValueRef>& insertions, |
| 44 | const VectorRef<KeyRangeRef>& clears) { |
| 45 | VersionHistory vh{ 0 }; |
| 46 | for (const auto& kv : insertions) { |
| 47 | vh.mutations.emplace_back_deep(vh.mutations.arena(), MutationRef(MutationRef::SetValue, kv.key, kv.value)); |
| 48 | tr.set(kv.key.withPrefix(globalConfigKeysPrefix), kv.value); |
| 49 | } |
| 50 | for (const auto& range : clears) { |
| 51 | vh.mutations.emplace_back_deep(vh.mutations.arena(), |
| 52 | MutationRef(MutationRef::ClearRange, range.begin, range.end)); |
| 53 | tr.clear( |
| 54 | KeyRangeRef(range.begin.withPrefix(globalConfigKeysPrefix), range.end.withPrefix(globalConfigKeysPrefix))); |
| 55 | } |
| 56 | |
| 57 | // Record the mutations in this commit into the global configuration history. |
| 58 | Key historyKey = addVersionStampAtEnd(globalConfigHistoryPrefix); |
| 59 | ObjectWriter historyWriter(IncludeVersion()); |
| 60 | historyWriter.serialize(vh); |
| 61 | tr.atomicOp(historyKey, historyWriter.toStringRef(), MutationRef::SetVersionstampedKey); |
| 62 | |
| 63 | // Write version key to trigger update in cluster controller. |
| 64 | tr.atomicOp(globalConfigVersionKey, |
| 65 | LiteralStringRef("0123456789\x00\x00\x00\x00"), // versionstamp |
| 66 | MutationRef::SetVersionstampedValue); |
| 67 | } |
| 68 | |
| 69 | Key GlobalConfig::prefixedKey(KeyRef key) { |
| 70 | return key.withPrefix(SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::GLOBALCONFIG).begin); |
nothing calls this directly
no test coverage detected