Add LocalConfigurationMetrics logging
This commit is contained in:
parent
674b0e09f8
commit
5298d9b870
|
@ -98,18 +98,18 @@ Future<Void> runTestUpdates(ConfigStore* configStore, Version* version) {
|
|||
return Void();
|
||||
}
|
||||
|
||||
ACTOR Future<Void> runFirstLocalConfiguration(std::string configPath, UID uid) {
|
||||
state LocalConfiguration localConfiguration(configPath, "./", testManualKnobOverrides, uid);
|
||||
ACTOR Future<Void> runFirstLocalConfiguration(std::string configPath, UID id) {
|
||||
state LocalConfiguration localConfiguration(configPath, testManualKnobOverrides);
|
||||
state Version version = 1;
|
||||
wait(localConfiguration.initialize());
|
||||
wait(localConfiguration.initialize("./", id));
|
||||
wait(runTestUpdates(&localConfiguration, &version));
|
||||
ASSERT(localConfiguration.getTestKnobs() == getExpectedTestKnobsFinal());
|
||||
return Void();
|
||||
}
|
||||
|
||||
ACTOR Future<Void> runSecondLocalConfiguration(std::string configPath, UID uid, TestKnobs const* expectedTestKnobs) {
|
||||
state LocalConfiguration localConfiguration(configPath, "./", testManualKnobOverrides, uid);
|
||||
wait(localConfiguration.initialize());
|
||||
ACTOR Future<Void> runSecondLocalConfiguration(std::string configPath, UID id, TestKnobs const* expectedTestKnobs) {
|
||||
state LocalConfiguration localConfiguration(configPath, testManualKnobOverrides);
|
||||
wait(localConfiguration.initialize("./", id));
|
||||
ASSERT(localConfiguration.getTestKnobs() == *expectedTestKnobs);
|
||||
return Void();
|
||||
}
|
||||
|
@ -131,16 +131,16 @@ TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/Simple") {
|
|||
}
|
||||
|
||||
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/Restart") {
|
||||
state UID uid = deterministicRandom()->randomUniqueID();
|
||||
wait(runFirstLocalConfiguration("class-A/class-B", uid));
|
||||
wait(runSecondLocalConfiguration("class-A/class-B", uid, &getExpectedTestKnobsFinal()));
|
||||
state UID id = deterministicRandom()->randomUniqueID();
|
||||
wait(runFirstLocalConfiguration("class-A/class-B", id));
|
||||
wait(runSecondLocalConfiguration("class-A/class-B", id, &getExpectedTestKnobsFinal()));
|
||||
return Void();
|
||||
}
|
||||
|
||||
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/FreshRestart") {
|
||||
state UID uid = deterministicRandom()->randomUniqueID();
|
||||
wait(runFirstLocalConfiguration("class-A/class-B", uid));
|
||||
wait(runSecondLocalConfiguration("class-B/class-A", uid, &getExpectedTestKnobsEmptyConfig()));
|
||||
state UID id = deterministicRandom()->randomUniqueID();
|
||||
wait(runFirstLocalConfiguration("class-A/class-B", id));
|
||||
wait(runSecondLocalConfiguration("class-B/class-A", id, &getExpectedTestKnobsEmptyConfig()));
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
@ -148,10 +148,10 @@ TEST_CASE("/fdbserver/ConfigDB/ConfigBroadcaster/Simple") {
|
|||
state ConfigBroadcaster broadcaster(ConfigFollowerInterface{});
|
||||
state Reference<IDependentAsyncVar<ConfigFollowerInterface>> cfi =
|
||||
IDependentAsyncVar<ConfigFollowerInterface>::create(makeReference<AsyncVar<ConfigFollowerInterface>>());
|
||||
state LocalConfiguration localConfiguration("class-A/class-B", "./", {}, deterministicRandom()->randomUniqueID());
|
||||
state LocalConfiguration localConfiguration("class-A/class-B", testManualKnobOverrides);
|
||||
state Version version = 1;
|
||||
state ActorCollection actors(false);
|
||||
wait(localConfiguration.initialize());
|
||||
wait(localConfiguration.initialize("./", deterministicRandom()->randomUniqueID()));
|
||||
actors.add(broadcaster.serve(cfi->get()));
|
||||
actors.add(localConfiguration.consume(cfi));
|
||||
Future<Void> updater = runTestUpdates(&broadcaster, &version);
|
||||
|
|
|
@ -108,16 +108,24 @@ public:
|
|||
} // namespace
|
||||
|
||||
class LocalConfigurationImpl : public NonCopyable {
|
||||
IKeyValueStore* kvStore;
|
||||
IKeyValueStore* kvStore{ nullptr };
|
||||
Future<Void> initFuture;
|
||||
FlowKnobs flowKnobs;
|
||||
ClientKnobs clientKnobs;
|
||||
ServerKnobs serverKnobs;
|
||||
TestKnobs testKnobs;
|
||||
Version mostRecentVersion{ 0 };
|
||||
ManualKnobOverrides manualKnobOverrides;
|
||||
ConfigKnobOverrides configKnobOverrides;
|
||||
ActorCollection actors{ false };
|
||||
|
||||
CounterCollection cc;
|
||||
Counter broadcasterChanges;
|
||||
Counter snapshots;
|
||||
Counter changeRequestsFetched;
|
||||
Counter mutations;
|
||||
Future<Void> logger;
|
||||
|
||||
ACTOR static Future<Void> saveConfigPath(LocalConfigurationImpl* self) {
|
||||
self->kvStore->set(
|
||||
KeyValueRef(configPathKey, BinaryWriter::toValue(self->configKnobOverrides, IncludeVersion())));
|
||||
|
@ -144,7 +152,14 @@ class LocalConfigurationImpl : public NonCopyable {
|
|||
return result;
|
||||
}
|
||||
|
||||
ACTOR static Future<Void> initialize(LocalConfigurationImpl* self) {
|
||||
ACTOR static Future<Void> initialize(LocalConfigurationImpl* self, std::string dataFolder, UID id) {
|
||||
platform::createDirectory(dataFolder);
|
||||
self->kvStore = keyValueStoreMemory(joinPath(dataFolder, "localconf-" + id.toString()), id, 500e6);
|
||||
self->logger = traceCounters("LocalConfigurationMetrics",
|
||||
id,
|
||||
SERVER_KNOBS->WORKER_LOGGING_INTERVAL,
|
||||
&self->cc,
|
||||
"LocalConfigurationMetrics");
|
||||
wait(self->kvStore->init());
|
||||
state Optional<Value> storedConfigPathValue = wait(self->kvStore->readValue(configPathKey));
|
||||
if (!storedConfigPathValue.present()) {
|
||||
|
@ -197,6 +212,7 @@ class LocalConfigurationImpl : public NonCopyable {
|
|||
std::map<ConfigKey, Value> snapshot,
|
||||
Version lastCompactedVersion) {
|
||||
// TODO: Concurrency control?
|
||||
++self->snapshots;
|
||||
self->kvStore->clear(knobOverrideKeys);
|
||||
for (const auto& [configKey, knobValue] : snapshot) {
|
||||
self->configKnobOverrides.set(configKey.configClass, configKey.knobName, knobValue);
|
||||
|
@ -215,7 +231,9 @@ class LocalConfigurationImpl : public NonCopyable {
|
|||
Standalone<VectorRef<VersionedConfigMutationRef>> versionedMutations,
|
||||
Version mostRecentVersion) {
|
||||
// TODO: Concurrency control?
|
||||
++self->changeRequestsFetched;
|
||||
for (const auto& versionedMutation : versionedMutations) {
|
||||
++self->mutations;
|
||||
const auto &mutation = versionedMutation.mutation;
|
||||
auto serializedKey = BinaryWriter::toValue(mutation.getKey(), IncludeVersion());
|
||||
if (mutation.isSet()) {
|
||||
|
@ -240,7 +258,7 @@ class LocalConfigurationImpl : public NonCopyable {
|
|||
// state Version lastSeenVersion = wait(impl->getLastSeenVersion());
|
||||
state SimpleConfigConsumer consumer(broadcaster->get());
|
||||
choose {
|
||||
when(wait(broadcaster->onChange())) {}
|
||||
when(wait(broadcaster->onChange())) { ++impl->broadcasterChanges; }
|
||||
when(wait(brokenPromiseToNever(consumer.consume(*self)))) { ASSERT(false); }
|
||||
when(wait(impl->actors.getResult())) { ASSERT(false); }
|
||||
}
|
||||
|
@ -256,20 +274,20 @@ class LocalConfigurationImpl : public NonCopyable {
|
|||
|
||||
public:
|
||||
template <class ManualKnobOverrides>
|
||||
LocalConfigurationImpl(std::string const& configPath,
|
||||
std::string const& dataFolder,
|
||||
ManualKnobOverrides&& manualKnobOverrides,
|
||||
UID id)
|
||||
: configKnobOverrides(configPath), manualKnobOverrides(std::forward<ManualKnobOverrides>(manualKnobOverrides)) {
|
||||
platform::createDirectory(dataFolder);
|
||||
kvStore = keyValueStoreMemory(joinPath(dataFolder, "localconf-" + id.toString()), id, 500e6);
|
||||
LocalConfigurationImpl(std::string const& configPath, ManualKnobOverrides&& manualKnobOverrides)
|
||||
: cc("LocalConfiguration"), broadcasterChanges("BroadcasterChanges", cc), snapshots("Snapshots", cc),
|
||||
changeRequestsFetched("ChangeRequestsFetched", cc), mutations("Mutations", cc), configKnobOverrides(configPath),
|
||||
manualKnobOverrides(std::forward<ManualKnobOverrides>(manualKnobOverrides)) {}
|
||||
|
||||
~LocalConfigurationImpl() {
|
||||
if (kvStore) {
|
||||
kvStore->close();
|
||||
}
|
||||
}
|
||||
|
||||
~LocalConfigurationImpl() { kvStore->close(); }
|
||||
|
||||
Future<Void> initialize() {
|
||||
Future<Void> initialize(std::string const& dataFolder, UID id) {
|
||||
ASSERT(!initFuture.isValid());
|
||||
initFuture = initialize(this);
|
||||
initFuture = initialize(this, dataFolder, id);
|
||||
return initFuture;
|
||||
}
|
||||
|
||||
|
@ -308,22 +326,16 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
LocalConfiguration::LocalConfiguration(std::string const& configPath,
|
||||
std::string const& dataFolder,
|
||||
std::map<Key, Value>&& manualKnobOverrides,
|
||||
UID id)
|
||||
: impl(std::make_unique<LocalConfigurationImpl>(configPath, dataFolder, std::move(manualKnobOverrides), id)) {}
|
||||
LocalConfiguration::LocalConfiguration(std::string const& configPath, std::map<Key, Value>&& manualKnobOverrides)
|
||||
: impl(std::make_unique<LocalConfigurationImpl>(configPath, std::move(manualKnobOverrides))) {}
|
||||
|
||||
LocalConfiguration::LocalConfiguration(std::string const& configPath,
|
||||
std::string const& dataFolder,
|
||||
std::map<Key, Value> const& manualKnobOverrides,
|
||||
UID id)
|
||||
: impl(std::make_unique<LocalConfigurationImpl>(configPath, dataFolder, manualKnobOverrides, id)) {}
|
||||
LocalConfiguration::LocalConfiguration(std::string const& configPath, std::map<Key, Value> const& manualKnobOverrides)
|
||||
: impl(std::make_unique<LocalConfigurationImpl>(configPath, manualKnobOverrides)) {}
|
||||
|
||||
LocalConfiguration::~LocalConfiguration() = default;
|
||||
|
||||
Future<Void> LocalConfiguration::initialize() {
|
||||
return impl->initialize();
|
||||
Future<Void> LocalConfiguration::initialize(std::string const& dataFolder, UID id) {
|
||||
return impl->initialize(dataFolder, id);
|
||||
}
|
||||
|
||||
FlowKnobs const& LocalConfiguration::getFlowKnobs() const {
|
||||
|
|
|
@ -45,16 +45,10 @@ class LocalConfiguration {
|
|||
std::unique_ptr<class LocalConfigurationImpl> impl;
|
||||
|
||||
public:
|
||||
LocalConfiguration(std::string const& configPath,
|
||||
std::string const& dataFolder,
|
||||
std::map<Key, Value> const& manualKnobOverrides,
|
||||
UID id);
|
||||
LocalConfiguration(std::string const& configPath,
|
||||
std::string const& dataFolder,
|
||||
std::map<Key, Value>&& manualKnobOverrides,
|
||||
UID id);
|
||||
LocalConfiguration(std::string const& configPath, std::map<Key, Value> const& manualKnobOverrides);
|
||||
LocalConfiguration(std::string const& configPath, std::map<Key, Value>&& manualKnobOverrides);
|
||||
~LocalConfiguration();
|
||||
Future<Void> initialize();
|
||||
Future<Void> initialize(std::string const& dataFolder, UID id);
|
||||
FlowKnobs const& getFlowKnobs() const;
|
||||
ClientKnobs const& getClientKnobs() const;
|
||||
ServerKnobs const& getServerKnobs() const;
|
||||
|
|
|
@ -2023,8 +2023,8 @@ ACTOR Future<Void> fdbd(Reference<ClusterConnectionFile> connFile,
|
|||
std::string configPath) {
|
||||
state vector<Future<Void>> actors;
|
||||
state Promise<Void> recoveredDiskFiles;
|
||||
state LocalConfiguration localConfig(configPath, dataFolder, {}, UID{});
|
||||
wait(localConfig.initialize());
|
||||
state LocalConfiguration localConfig(configPath, {});
|
||||
wait(localConfig.initialize(dataFolder, deterministicRandom()->randomUniqueID()));
|
||||
|
||||
actors.push_back(serveProtocolInfo());
|
||||
|
||||
|
|
Loading…
Reference in New Issue