Address review comments, improve performance

This commit is contained in:
Xiaoge Su 2020-08-08 23:17:14 -07:00 committed by Xiaoge Su
parent 49968b8200
commit ceeade7334
3 changed files with 14 additions and 16 deletions

View File

@ -8,6 +8,7 @@ Release Notes
===== =====
* Fix an issue where ``fdbcli --exec 'exclude no_wait ...'`` would incorrectly report that processes can safely be removed from the cluster. `(PR #3566) <https://github.com/apple/foundationdb/pull/3566>`_ * Fix an issue where ``fdbcli --exec 'exclude no_wait ...'`` would incorrectly report that processes can safely be removed from the cluster. `(PR #3566) <https://github.com/apple/foundationdb/pull/3566>`_
* When a configuration key is changed, it will always be included in ``status json`` output, even the value is reverted back to the default value. `(PR #3610) <https://github.com/apple/foundationdb/pull/3610>`_
6.3.4 6.3.4
===== =====

View File

@ -562,25 +562,21 @@ void DatabaseConfiguration::fromKeyValues(Standalone<VectorRef<KeyValueRef>> raw
setDefaultReplicationPolicy(); setDefaultReplicationPolicy();
} }
bool DatabaseConfiguration::isOverridden(const std::string& key) const { bool DatabaseConfiguration::isOverridden(std::string key) const {
key = configKeysPrefix.toString() + key;
if (mutableConfiguration.present() && mutableConfiguration.get().find(key) != mutableConfiguration.get().end()) {
return true;
}
const int keyLen = key.size();
for (auto iter = rawConfiguration.begin(); iter != rawConfiguration.end(); ++iter) { for (auto iter = rawConfiguration.begin(); iter != rawConfiguration.end(); ++iter) {
auto confKey = iter->key.removePrefix(configKeysPrefix).toString(); const auto& rawConfKey = iter->key;
if (key == confKey) { if (keyLen == rawConfKey.size() &&
strncmp(key.c_str(), reinterpret_cast<const char*>(rawConfKey.begin()), keyLen) == 0) {
return true; return true;
} }
} }
if (!mutableConfiguration.present()) {
return false;
}
for (auto iter = mutableConfiguration.get().begin(); iter != mutableConfiguration.get().end(); ++iter) {
UNSTOPPABLE_ASSERT(iter->first.size() >= configKeysPrefix.size() &&
iter->first.substr(0, configKeysPrefix.size()) == configKeysPrefix.toString());
auto confKey = iter->first.substr(configKeysPrefix.size());
if (key == confKey) {
return true;
}
}
return false; return false;
} }

View File

@ -231,7 +231,8 @@ private:
void resetInternal(); void resetInternal();
void setDefaultReplicationPolicy(); void setDefaultReplicationPolicy();
bool isOverridden(const std::string& key) const; /// Check if the key is overridden by either mutableConfiguration or rawConfiguration
bool isOverridden(std::string key) const;
}; };
#endif #endif