| 36 | /// Always inline to avoid having to provide a definition for each use type P. |
| 37 | template <typename P> |
| 38 | Status RpcMgr::GetProxy(const NetworkAddressPB& address, const std::string& hostname, |
| 39 | std::unique_ptr<P>* proxy) { |
| 40 | DCHECK(proxy != nullptr); |
| 41 | DCHECK(is_inited()) << "Must call Init() before GetProxy()"; |
| 42 | DCHECK(IsResolvedAddress(address)); |
| 43 | NetworkAddressPB address_to_use = address; |
| 44 | // Talk to self via loopback. |
| 45 | if (FLAGS_rpc_use_loopback |
| 46 | && address_to_use.hostname() == ExecEnv::GetInstance()->krpc_address().hostname()) { |
| 47 | address_to_use.set_hostname(LOCALHOST_IP_STR); |
| 48 | } |
| 49 | kudu::Sockaddr sockaddr = kudu::Sockaddr::Wildcard(); |
| 50 | // Connect to KRPC server via Unix domain socket if krpc_use_uds_ is true. |
| 51 | RETURN_IF_ERROR(NetworkAddressPBToSockaddr(address_to_use, krpc_use_uds_, &sockaddr)); |
| 52 | proxy->reset(new P(messenger_, sockaddr, hostname)); |
| 53 | |
| 54 | // Always set the user credentials as Proxy ctor may fail in GetLoggedInUser(). |
| 55 | // An empty user name will result in SASL failure. See IMPALA-7585. |
| 56 | kudu::rpc::UserCredentials creds; |
| 57 | creds.set_real_user("impala"); |
| 58 | (*proxy)->set_user_credentials(creds); |
| 59 | |
| 60 | return Status::OK(); |
| 61 | } |
| 62 | |
| 63 | template <typename Proxy, typename ProxyMethod, typename Request, typename Response> |
| 64 | Status RpcMgr::DoRpcWithRetry(const std::unique_ptr<Proxy>& proxy, |