Cleanup DatabaseConfiguration::toJSON
This commit is contained in:
parent
6b8843ad18
commit
49968b8200
|
@ -224,111 +224,123 @@ bool DatabaseConfiguration::isValid() const {
|
|||
StatusObject DatabaseConfiguration::toJSON(bool noPolicies) const {
|
||||
StatusObject result;
|
||||
|
||||
if( initialized ) {
|
||||
std::string tlogInfo = tLogPolicy->info();
|
||||
std::string storageInfo = storagePolicy->info();
|
||||
bool customRedundancy = false;
|
||||
if( tLogWriteAntiQuorum == 0 ) {
|
||||
if( tLogReplicationFactor == 1 && storageTeamSize == 1 ) {
|
||||
result["redundancy_mode"] = "single";
|
||||
} else if( tLogReplicationFactor == 2 && storageTeamSize == 2 ) {
|
||||
result["redundancy_mode"] = "double";
|
||||
} else if( tLogReplicationFactor == 4 && storageTeamSize == 6 && tlogInfo == "dcid^2 x zoneid^2 x 1" && storageInfo == "dcid^3 x zoneid^2 x 1" ) {
|
||||
result["redundancy_mode"] = "three_datacenter";
|
||||
} else if( tLogReplicationFactor == 4 && storageTeamSize == 4 && tlogInfo == "dcid^2 x zoneid^2 x 1" && storageInfo == "dcid^2 x zoneid^2 x 1" ) {
|
||||
result["redundancy_mode"] = "three_datacenter_fallback";
|
||||
} else if( tLogReplicationFactor == 3 && storageTeamSize == 3 ) {
|
||||
result["redundancy_mode"] = "triple";
|
||||
} else if( tLogReplicationFactor == 4 && storageTeamSize == 3 && tlogInfo == "data_hall^2 x zoneid^2 x 1" && storageInfo == "data_hall^3 x 1" ) {
|
||||
result["redundancy_mode"] = "three_data_hall";
|
||||
} else if( tLogReplicationFactor == 4 && storageTeamSize == 2 && tlogInfo == "data_hall^2 x zoneid^2 x 1" && storageInfo == "data_hall^2 x 1" ) {
|
||||
result["redundancy_mode"] = "three_data_hall_fallback";
|
||||
} else {
|
||||
customRedundancy = true;
|
||||
}
|
||||
if (!initialized) {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string tlogInfo = tLogPolicy->info();
|
||||
std::string storageInfo = storagePolicy->info();
|
||||
bool customRedundancy = false;
|
||||
if (tLogWriteAntiQuorum == 0) {
|
||||
if (tLogReplicationFactor == 1 && storageTeamSize == 1) {
|
||||
result["redundancy_mode"] = "single";
|
||||
} else if (tLogReplicationFactor == 2 && storageTeamSize == 2) {
|
||||
result["redundancy_mode"] = "double";
|
||||
} else if (tLogReplicationFactor == 4 && storageTeamSize == 6 && tlogInfo == "dcid^2 x zoneid^2 x 1" &&
|
||||
storageInfo == "dcid^3 x zoneid^2 x 1") {
|
||||
result["redundancy_mode"] = "three_datacenter";
|
||||
} else if (tLogReplicationFactor == 4 && storageTeamSize == 4 && tlogInfo == "dcid^2 x zoneid^2 x 1" &&
|
||||
storageInfo == "dcid^2 x zoneid^2 x 1") {
|
||||
result["redundancy_mode"] = "three_datacenter_fallback";
|
||||
} else if (tLogReplicationFactor == 3 && storageTeamSize == 3) {
|
||||
result["redundancy_mode"] = "triple";
|
||||
} else if (tLogReplicationFactor == 4 && storageTeamSize == 3 && tlogInfo == "data_hall^2 x zoneid^2 x 1" &&
|
||||
storageInfo == "data_hall^3 x 1") {
|
||||
result["redundancy_mode"] = "three_data_hall";
|
||||
} else if (tLogReplicationFactor == 4 && storageTeamSize == 2 && tlogInfo == "data_hall^2 x zoneid^2 x 1" &&
|
||||
storageInfo == "data_hall^2 x 1") {
|
||||
result["redundancy_mode"] = "three_data_hall_fallback";
|
||||
} else {
|
||||
customRedundancy = true;
|
||||
}
|
||||
|
||||
if(customRedundancy) {
|
||||
result["storage_replicas"] = storageTeamSize;
|
||||
result["log_replicas"] = tLogReplicationFactor;
|
||||
result["log_anti_quorum"] = tLogWriteAntiQuorum;
|
||||
if(!noPolicies) result["storage_replication_policy"] = storagePolicy->info();
|
||||
if(!noPolicies) result["log_replication_policy"] = tLogPolicy->info();
|
||||
}
|
||||
|
||||
if (tLogVersion > TLogVersion::DEFAULT || isOverridden("log_version")) {
|
||||
result["log_version"] = (int)tLogVersion;
|
||||
}
|
||||
|
||||
if( tLogDataStoreType == KeyValueStoreType::SSD_BTREE_V1 && storageServerStoreType == KeyValueStoreType::SSD_BTREE_V1) {
|
||||
result["storage_engine"] = "ssd-1";
|
||||
} else if (tLogDataStoreType == KeyValueStoreType::SSD_BTREE_V2 && storageServerStoreType == KeyValueStoreType::SSD_BTREE_V2) {
|
||||
result["storage_engine"] = "ssd-2";
|
||||
} else if( tLogDataStoreType == KeyValueStoreType::SSD_BTREE_V2 && storageServerStoreType == KeyValueStoreType::SSD_REDWOOD_V1 ) {
|
||||
result["storage_engine"] = "ssd-redwood-experimental";
|
||||
} else if (tLogDataStoreType == KeyValueStoreType::SSD_BTREE_V2 && storageServerStoreType == KeyValueStoreType::SSD_ROCKSDB_V1) {
|
||||
result["storage_engine"] = "ssd-rocksdb-experimental";
|
||||
} else if( tLogDataStoreType == KeyValueStoreType::MEMORY && storageServerStoreType == KeyValueStoreType::MEMORY ) {
|
||||
result["storage_engine"] = "memory-1";
|
||||
} else if( tLogDataStoreType == KeyValueStoreType::SSD_BTREE_V2 && storageServerStoreType == KeyValueStoreType::MEMORY_RADIXTREE ) {
|
||||
result["storage_engine"] = "memory-radixtree-beta";
|
||||
} else if( tLogDataStoreType == KeyValueStoreType::SSD_BTREE_V2 && storageServerStoreType == KeyValueStoreType::MEMORY ) {
|
||||
result["storage_engine"] = "memory-2";
|
||||
} else {
|
||||
result["storage_engine"] = "custom";
|
||||
}
|
||||
|
||||
result["log_spill"] = (int)tLogSpillType;
|
||||
|
||||
if( remoteTLogReplicationFactor == 1 ) {
|
||||
result["remote_redundancy_mode"] = "remote_single";
|
||||
} else if( remoteTLogReplicationFactor == 2 ) {
|
||||
result["remote_redundancy_mode"] = "remote_double";
|
||||
} else if( remoteTLogReplicationFactor == 3 ) {
|
||||
result["remote_redundancy_mode"] = "remote_triple";
|
||||
} else if( remoteTLogReplicationFactor > 3 ) {
|
||||
result["remote_log_replicas"] = remoteTLogReplicationFactor;
|
||||
if(noPolicies && remoteTLogPolicy) result["remote_log_policy"] = remoteTLogPolicy->info();
|
||||
}
|
||||
result["usable_regions"] = usableRegions;
|
||||
|
||||
if(regions.size()) {
|
||||
result["regions"] = getRegionJSON();
|
||||
}
|
||||
|
||||
if (desiredTLogCount != -1 || isOverridden("logs")) {
|
||||
result["logs"] = desiredTLogCount;
|
||||
}
|
||||
if (masterProxyCount != -1 || isOverridden("proxies")) {
|
||||
result["proxies"] = masterProxyCount;
|
||||
}
|
||||
if (resolverCount != -1 || isOverridden("resolvers")) {
|
||||
result["resolvers"] = resolverCount;
|
||||
}
|
||||
if (desiredLogRouterCount != -1 || isOverridden("log_routers")) {
|
||||
result["log_routers"] = desiredLogRouterCount;
|
||||
}
|
||||
if (remoteDesiredTLogCount != -1 || isOverridden("remote_logs")) {
|
||||
result["remote_logs"] = remoteDesiredTLogCount;
|
||||
}
|
||||
if (repopulateRegionAntiQuorum != 0 || isOverridden("repopulate_anti_quorum")) {
|
||||
result["repopulate_anti_quorum"] = repopulateRegionAntiQuorum;
|
||||
}
|
||||
if (autoMasterProxyCount != CLIENT_KNOBS->DEFAULT_AUTO_PROXIES || isOverridden("auto_proxies")) {
|
||||
result["auto_proxies"] = autoMasterProxyCount;
|
||||
}
|
||||
if (autoResolverCount != CLIENT_KNOBS->DEFAULT_AUTO_RESOLVERS || isOverridden("auto_resolvers")) {
|
||||
result["auto_resolvers"] = autoResolverCount;
|
||||
}
|
||||
if (autoDesiredTLogCount != CLIENT_KNOBS->DEFAULT_AUTO_LOGS || isOverridden("auto_logs")) {
|
||||
result["auto_logs"] = autoDesiredTLogCount;
|
||||
}
|
||||
|
||||
result["backup_worker_enabled"] = (int32_t)backupWorkerEnabled;
|
||||
} else {
|
||||
customRedundancy = true;
|
||||
}
|
||||
|
||||
if (customRedundancy) {
|
||||
result["storage_replicas"] = storageTeamSize;
|
||||
result["log_replicas"] = tLogReplicationFactor;
|
||||
result["log_anti_quorum"] = tLogWriteAntiQuorum;
|
||||
if (!noPolicies) result["storage_replication_policy"] = storagePolicy->info();
|
||||
if (!noPolicies) result["log_replication_policy"] = tLogPolicy->info();
|
||||
}
|
||||
|
||||
if (tLogVersion > TLogVersion::DEFAULT || isOverridden("log_version")) {
|
||||
result["log_version"] = (int)tLogVersion;
|
||||
}
|
||||
|
||||
if (tLogDataStoreType == KeyValueStoreType::SSD_BTREE_V1 &&
|
||||
storageServerStoreType == KeyValueStoreType::SSD_BTREE_V1) {
|
||||
result["storage_engine"] = "ssd-1";
|
||||
} else if (tLogDataStoreType == KeyValueStoreType::SSD_BTREE_V2 &&
|
||||
storageServerStoreType == KeyValueStoreType::SSD_BTREE_V2) {
|
||||
result["storage_engine"] = "ssd-2";
|
||||
} else if (tLogDataStoreType == KeyValueStoreType::SSD_BTREE_V2 &&
|
||||
storageServerStoreType == KeyValueStoreType::SSD_REDWOOD_V1) {
|
||||
result["storage_engine"] = "ssd-redwood-experimental";
|
||||
} else if (tLogDataStoreType == KeyValueStoreType::SSD_BTREE_V2 &&
|
||||
storageServerStoreType == KeyValueStoreType::SSD_ROCKSDB_V1) {
|
||||
result["storage_engine"] = "ssd-rocksdb-experimental";
|
||||
} else if (tLogDataStoreType == KeyValueStoreType::MEMORY && storageServerStoreType == KeyValueStoreType::MEMORY) {
|
||||
result["storage_engine"] = "memory-1";
|
||||
} else if (tLogDataStoreType == KeyValueStoreType::SSD_BTREE_V2 &&
|
||||
storageServerStoreType == KeyValueStoreType::MEMORY_RADIXTREE) {
|
||||
result["storage_engine"] = "memory-radixtree-beta";
|
||||
} else if (tLogDataStoreType == KeyValueStoreType::SSD_BTREE_V2 &&
|
||||
storageServerStoreType == KeyValueStoreType::MEMORY) {
|
||||
result["storage_engine"] = "memory-2";
|
||||
} else {
|
||||
result["storage_engine"] = "custom";
|
||||
}
|
||||
|
||||
result["log_spill"] = (int)tLogSpillType;
|
||||
|
||||
if (remoteTLogReplicationFactor == 1) {
|
||||
result["remote_redundancy_mode"] = "remote_single";
|
||||
} else if (remoteTLogReplicationFactor == 2) {
|
||||
result["remote_redundancy_mode"] = "remote_double";
|
||||
} else if (remoteTLogReplicationFactor == 3) {
|
||||
result["remote_redundancy_mode"] = "remote_triple";
|
||||
} else if (remoteTLogReplicationFactor > 3) {
|
||||
result["remote_log_replicas"] = remoteTLogReplicationFactor;
|
||||
if (noPolicies && remoteTLogPolicy) result["remote_log_policy"] = remoteTLogPolicy->info();
|
||||
}
|
||||
result["usable_regions"] = usableRegions;
|
||||
|
||||
if (regions.size()) {
|
||||
result["regions"] = getRegionJSON();
|
||||
}
|
||||
|
||||
if (desiredTLogCount != -1 || isOverridden("logs")) {
|
||||
result["logs"] = desiredTLogCount;
|
||||
}
|
||||
if (masterProxyCount != -1 || isOverridden("proxies")) {
|
||||
result["proxies"] = masterProxyCount;
|
||||
}
|
||||
if (resolverCount != -1 || isOverridden("resolvers")) {
|
||||
result["resolvers"] = resolverCount;
|
||||
}
|
||||
if (desiredLogRouterCount != -1 || isOverridden("log_routers")) {
|
||||
result["log_routers"] = desiredLogRouterCount;
|
||||
}
|
||||
if (remoteDesiredTLogCount != -1 || isOverridden("remote_logs")) {
|
||||
result["remote_logs"] = remoteDesiredTLogCount;
|
||||
}
|
||||
if (repopulateRegionAntiQuorum != 0 || isOverridden("repopulate_anti_quorum")) {
|
||||
result["repopulate_anti_quorum"] = repopulateRegionAntiQuorum;
|
||||
}
|
||||
if (autoMasterProxyCount != CLIENT_KNOBS->DEFAULT_AUTO_PROXIES || isOverridden("auto_proxies")) {
|
||||
result["auto_proxies"] = autoMasterProxyCount;
|
||||
}
|
||||
if (autoResolverCount != CLIENT_KNOBS->DEFAULT_AUTO_RESOLVERS || isOverridden("auto_resolvers")) {
|
||||
result["auto_resolvers"] = autoResolverCount;
|
||||
}
|
||||
if (autoDesiredTLogCount != CLIENT_KNOBS->DEFAULT_AUTO_LOGS || isOverridden("auto_logs")) {
|
||||
result["auto_logs"] = autoDesiredTLogCount;
|
||||
}
|
||||
|
||||
result["backup_worker_enabled"] = (int32_t)backupWorkerEnabled;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue