MCPcopy Create free account
hub / github.com/apple/foundationdb / applyChanges

Method applyChanges

fdbclient/GlobalConfig.actor.cpp:42–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40GlobalConfig::GlobalConfig(DatabaseContext* cx) : cx(cx), lastUpdate(0) {}
41
42void 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
69Key GlobalConfig::prefixedKey(KeyRef key) {
70 return key.withPrefix(SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::GLOBALCONFIG).begin);

Callers

nothing calls this directly

Calls 10

MutationRefClass · 0.85
addVersionStampAtEndFunction · 0.85
IncludeVersionFunction · 0.85
setMethod · 0.65
clearMethod · 0.65
KeyRangeRefClass · 0.50
withPrefixMethod · 0.45
serializeMethod · 0.45
atomicOpMethod · 0.45
toStringRefMethod · 0.45

Tested by

no test coverage detected