| 370 | } |
| 371 | |
| 372 | std::pair<int, std::string> fetchCDCReplicas( |
| 373 | const std::string& addr, uint16_t port, Duration timeout, std::array<AddrsInfo, 5>& replicas |
| 374 | ) { |
| 375 | const auto [sock, errStr] = registrySock(addr, port, timeout); |
| 376 | if (sock.error()) { |
| 377 | return {sock.getErrno(), errStr}; |
| 378 | } |
| 379 | |
| 380 | RegistryReqContainer reqContainer; |
| 381 | auto& req = reqContainer.setCdcReplicasDEPRECATED(); |
| 382 | |
| 383 | { |
| 384 | const auto [err, errStr] = writeRegistryRequest(sock.get(), reqContainer, timeout); |
| 385 | if (err) { return {err, errStr}; } |
| 386 | } |
| 387 | |
| 388 | RegistryRespContainer respContainer; |
| 389 | { |
| 390 | const auto [err, errStr] = readRegistryResponse(sock.get(), respContainer, timeout); |
| 391 | if (err) { return {err, errStr}; } |
| 392 | } |
| 393 | |
| 394 | if (respContainer.getCdcReplicasDEPRECATED().replicas.els.size() != replicas.size()) { |
| 395 | throw TERN_EXCEPTION("expecting %s replicas, got %s", replicas.size(), respContainer.getCdcReplicasDEPRECATED().replicas.els.size()); |
| 396 | } |
| 397 | for (int i = 0; i < replicas.size(); i++) { |
| 398 | replicas[i] = respContainer.getCdcReplicasDEPRECATED().replicas.els[i]; |
| 399 | } |
| 400 | |
| 401 | return {}; |
| 402 | } |
| 403 | |
| 404 | std::pair<int, std::string> fetchLocalShards(const std::string& host, uint16_t port, Duration timeout, std::array<ShardInfo, 256>& shards) { |
| 405 | const auto [sock, errStr] = registrySock(host, port, timeout); |
no test coverage detected