| 34 | namespace fdb_cli { |
| 35 | |
| 36 | Optional<std::pair<Optional<ClusterConnectionString>, Optional<DataClusterEntry>>> |
| 37 | parseClusterConfiguration(std::vector<StringRef> const& tokens, DataClusterEntry const& defaults, int startIndex) { |
| 38 | Optional<DataClusterEntry> entry; |
| 39 | Optional<ClusterConnectionString> connectionString; |
| 40 | |
| 41 | std::set<std::string> usedParams; |
| 42 | for (int tokenNum = startIndex; tokenNum < tokens.size(); ++tokenNum) { |
| 43 | StringRef token = tokens[tokenNum]; |
| 44 | bool foundEquals; |
| 45 | StringRef param = token.eat("=", &foundEquals); |
| 46 | if (!foundEquals) { |
| 47 | fmt::print(stderr, |
| 48 | "ERROR: invalid configuration string `{}'. String must specify a value using `='.\n", |
| 49 | param.toString().c_str()); |
| 50 | return {}; |
| 51 | } |
| 52 | std::string value = token.toString(); |
| 53 | if (!usedParams.insert(value).second) { |
| 54 | fmt::print( |
| 55 | stderr, "ERROR: configuration parameter `{}' specified more than once.\n", param.toString().c_str()); |
| 56 | return {}; |
| 57 | } |
| 58 | if (tokencmp(param, "max_tenant_groups")) { |
| 59 | entry = defaults; |
| 60 | |
| 61 | int n; |
| 62 | if (sscanf(value.c_str(), "%d%n", &entry.get().capacity.numTenantGroups, &n) != 1 || n != value.size() || |
| 63 | entry.get().capacity.numTenantGroups < 0) { |
| 64 | fmt::print(stderr, "ERROR: invalid number of tenant groups `{}'.\n", value.c_str()); |
| 65 | return {}; |
| 66 | } |
| 67 | } else if (tokencmp(param, "connection_string")) { |
| 68 | connectionString = ClusterConnectionString(value); |
| 69 | } else { |
| 70 | fmt::print(stderr, "ERROR: unrecognized configuration parameter `{}'.\n", param.toString().c_str()); |
| 71 | return {}; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | return std::make_pair(connectionString, entry); |
| 76 | } |
| 77 | |
| 78 | void printMetaclusterConfigureOptionsUsage() { |
| 79 | fmt::print("max_tenant_groups sets the maximum number of tenant groups that can be assigned\n" |
no test coverage detected