Defines the mapping between configuration names (as exposed by fdbcli, buildConfiguration()) and actual configuration parameters
| 57 | // Defines the mapping between configuration names (as exposed by fdbcli, buildConfiguration()) and actual configuration |
| 58 | // parameters |
| 59 | std::map<std::string, std::string> configForToken(std::string const& mode) { |
| 60 | std::map<std::string, std::string> out; |
| 61 | std::string p = configKeysPrefix.toString(); |
| 62 | |
| 63 | if (mode == "new") { |
| 64 | out[p + "initialized"] = "1"; |
| 65 | return out; |
| 66 | } |
| 67 | |
| 68 | if (mode == "tss") { |
| 69 | // Set temporary marker in config map to mark that this is a tss configuration and not a normal storage/log |
| 70 | // configuration. A bit of a hack but reuses the parsing code nicely. |
| 71 | out[p + "istss"] = "1"; |
| 72 | return out; |
| 73 | } |
| 74 | |
| 75 | if (mode == "locked") { |
| 76 | // Setting this key is interpreted as an instruction to use the normal version-stamp-based mechanism for locking |
| 77 | // the database. |
| 78 | out[databaseLockedKey.toString()] = deterministicRandom()->randomUniqueID().toString(); |
| 79 | return out; |
| 80 | } |
| 81 | |
| 82 | size_t pos; |
| 83 | |
| 84 | // key:=value is unvalidated and unchecked |
| 85 | pos = mode.find(":="); |
| 86 | if (pos != std::string::npos) { |
| 87 | out[p + mode.substr(0, pos)] = mode.substr(pos + 2); |
| 88 | return out; |
| 89 | } |
| 90 | |
| 91 | // key=value is constrained to a limited set of options and basic validation is performed |
| 92 | pos = mode.find("="); |
| 93 | if (pos != std::string::npos) { |
| 94 | std::string key = mode.substr(0, pos); |
| 95 | std::string value = mode.substr(pos + 1); |
| 96 | |
| 97 | if (key == "proxies" && isInteger(value)) { |
| 98 | printf("Warning: Proxy role is being split into GRV Proxy and Commit Proxy, now prefer configuring " |
| 99 | "'grv_proxies' and 'commit_proxies' separately. Generally we should follow that 'commit_proxies'" |
| 100 | " is three times of 'grv_proxies' count and 'grv_proxies' should be not more than 4.\n"); |
| 101 | int proxiesCount = atoi(value.c_str()); |
| 102 | if (proxiesCount == -1) { |
| 103 | proxiesCount = CLIENT_KNOBS->DEFAULT_AUTO_GRV_PROXIES + CLIENT_KNOBS->DEFAULT_AUTO_COMMIT_PROXIES; |
| 104 | ASSERT_WE_THINK(proxiesCount >= 2); |
| 105 | } |
| 106 | |
| 107 | if (proxiesCount < 2) { |
| 108 | printf("Error: At least 2 proxies (1 GRV proxy and 1 Commit proxy) are required.\n"); |
| 109 | return out; |
| 110 | } |
| 111 | |
| 112 | int grvProxyCount = std::max(1, |
| 113 | std::min(CLIENT_KNOBS->DEFAULT_MAX_GRV_PROXIES, |
| 114 | proxiesCount / (CLIENT_KNOBS->DEFAULT_COMMIT_GRV_PROXIES_RATIO + 1))); |
| 115 | int commitProxyCount = proxiesCount - grvProxyCount; |
| 116 | ASSERT_WE_THINK(grvProxyCount >= 1 && commitProxyCount >= 1); |
no test coverage detected