| 62 | } |
| 63 | |
| 64 | Status ThriftClientImpl::Open() { |
| 65 | RETURN_IF_ERROR(init_status_); |
| 66 | try { |
| 67 | if (!transport_->isOpen()) { |
| 68 | transport_->open(); |
| 69 | } |
| 70 | } catch (const TException& e) { |
| 71 | try { |
| 72 | transport_->close(); |
| 73 | } catch (const TException& e) { |
| 74 | VLOG(1) << "Error closing socket to: " << TNetworkAddressToString(address_) |
| 75 | << ", ignoring (" << e.what() << ")"; |
| 76 | } |
| 77 | // In certain cases in which the remote host is overloaded, this failure can |
| 78 | // happen quite frequently. Let's print this error message without the stack |
| 79 | // trace as there aren't many callers of this function. |
| 80 | const string& err_msg = Substitute("Couldn't open transport for $0 ($1)", |
| 81 | TNetworkAddressToString(address_), e.what()); |
| 82 | VLOG(1) << err_msg; |
| 83 | return Status::Expected(err_msg); |
| 84 | } |
| 85 | return Status::OK(); |
| 86 | } |
| 87 | |
| 88 | Status ThriftClientImpl::OpenWithRetry(uint32_t num_tries, uint64_t wait_ms) { |
| 89 | // Socket creation failures are not recoverable. |