| 86 | } |
| 87 | |
| 88 | Status ThriftClientImpl::OpenWithRetry(uint32_t num_tries, uint64_t wait_ms) { |
| 89 | // Socket creation failures are not recoverable. |
| 90 | RETURN_IF_ERROR(init_status_); |
| 91 | |
| 92 | uint32_t try_count = 0L; |
| 93 | while (true) { |
| 94 | ++try_count; |
| 95 | Status status = Open(); |
| 96 | if (status.ok()) return status; |
| 97 | |
| 98 | LOG(INFO) << "Unable to connect to " << TNetworkAddressToString(address_); |
| 99 | if (num_tries == 0) { |
| 100 | LOG(INFO) << "(Attempt " << try_count << ", will retry indefinitely)"; |
| 101 | } else { |
| 102 | if (num_tries != 1) { |
| 103 | // No point logging 'attempt 1 of 1' |
| 104 | LOG(INFO) << "(Attempt " << try_count << " of " << num_tries << ")"; |
| 105 | } |
| 106 | if (try_count == num_tries) return status; |
| 107 | } |
| 108 | SleepForMs(wait_ms); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | void ThriftClientImpl::Close() { |
| 113 | try { |
no test coverage detected