2222import static org .apache .hadoop .hbase .ipc .IPCUtil .wrapException ;
2323
2424import java .io .IOException ;
25- import java .net .InetSocketAddress ;
2625import java .net .SocketAddress ;
27- import java .net .UnknownHostException ;
2826import java .util .Collection ;
2927import java .util .concurrent .Executors ;
3028import java .util .concurrent .ScheduledExecutorService ;
@@ -320,7 +318,7 @@ private int nextCallId() {
320318 * @return A pair with the Message response and the Cell data (if any).
321319 */
322320 private Message callBlockingMethod (Descriptors .MethodDescriptor md , HBaseRpcController hrc ,
323- Message param , Message returnType , final User ticket , final InetSocketAddress isa )
321+ Message param , Message returnType , final User ticket , final Address isa )
324322 throws ServiceException {
325323 BlockingRpcCallback <Message > done = new BlockingRpcCallback <>();
326324 callMethod (md , hrc , param , returnType , ticket , isa , done );
@@ -392,7 +390,7 @@ private void onCallFinished(Call call, HBaseRpcController hrc, Address addr,
392390
393391 Call callMethod (final Descriptors .MethodDescriptor md , final HBaseRpcController hrc ,
394392 final Message param , Message returnType , final User ticket ,
395- final InetSocketAddress inetAddr , final RpcCallback <Message > callback ) {
393+ final Address addr , final RpcCallback <Message > callback ) {
396394 final MetricsConnection .CallStats cs = MetricsConnection .newCallStats ();
397395 cs .setStartTime (EnvironmentEdgeManager .currentTime ());
398396
@@ -406,7 +404,6 @@ Call callMethod(final Descriptors.MethodDescriptor md, final HBaseRpcController
406404 cs .setNumActionsPerServer (numActions );
407405 }
408406
409- final Address addr = Address .fromSocketAddress (inetAddr );
410407 final AtomicInteger counter = concurrentCounterCache .getUnchecked (addr );
411408 Call call = new Call (nextCallId (), md , param , hrc .cellScanner (), returnType ,
412409 hrc .getCallTimeout (), hrc .getPriority (), new RpcCallback <Call >() {
@@ -520,13 +517,6 @@ private static class AbstractRpcChannel {
520517
521518 protected final Address addr ;
522519
523- // We cache the resolved InetSocketAddress for the channel so we do not do a DNS lookup
524- // per method call on the channel. If the remote target is removed or reprovisioned and
525- // its identity changes a new channel with a newly resolved InetSocketAddress will be
526- // created as part of retry, so caching here is fine.
527- // Normally, caching an InetSocketAddress is an anti-pattern.
528- protected InetSocketAddress isa ;
529-
530520 protected final AbstractRpcClient <?> rpcClient ;
531521
532522 protected final User ticket ;
@@ -576,23 +566,9 @@ protected BlockingRpcChannelImplementation(AbstractRpcClient<?> rpcClient,
576566
577567 @ Override
578568 public Message callBlockingMethod (Descriptors .MethodDescriptor md , RpcController controller ,
579- Message param , Message returnType ) throws ServiceException {
580- // Look up remote address upon first call
581- if (isa == null ) {
582- if (this .rpcClient .metrics != null ) {
583- this .rpcClient .metrics .incrNsLookups ();
584- }
585- isa = Address .toSocketAddress (addr );
586- if (isa .isUnresolved ()) {
587- if (this .rpcClient .metrics != null ) {
588- this .rpcClient .metrics .incrNsLookupsFailed ();
589- }
590- isa = null ;
591- throw new ServiceException (new UnknownHostException (addr + " could not be resolved" ));
592- }
593- }
594- return rpcClient .callBlockingMethod (md , configureRpcController (controller ),
595- param , returnType , ticket , isa );
569+ Message param , Message returnType ) throws ServiceException {
570+ return rpcClient .callBlockingMethod (md , configureRpcController (controller ), param , returnType ,
571+ ticket , addr );
596572 }
597573 }
598574
@@ -608,29 +584,13 @@ protected RpcChannelImplementation(AbstractRpcClient<?> rpcClient, Address addr,
608584 }
609585
610586 @ Override
611- public void callMethod (Descriptors .MethodDescriptor md , RpcController controller ,
612- Message param , Message returnType , RpcCallback <Message > done ) {
613- HBaseRpcController configuredController =
614- configureRpcController (Preconditions .checkNotNull (controller ,
615- "RpcController can not be null for async rpc call" ));
616- // Look up remote address upon first call
617- if (isa == null || isa .isUnresolved ()) {
618- if (this .rpcClient .metrics != null ) {
619- this .rpcClient .metrics .incrNsLookups ();
620- }
621- isa = Address .toSocketAddress (addr );
622- if (isa .isUnresolved ()) {
623- if (this .rpcClient .metrics != null ) {
624- this .rpcClient .metrics .incrNsLookupsFailed ();
625- }
626- isa = null ;
627- controller .setFailed (addr + " could not be resolved" );
628- return ;
629- }
630- }
587+ public void callMethod (Descriptors .MethodDescriptor md , RpcController controller , Message param ,
588+ Message returnType , RpcCallback <Message > done ) {
589+ HBaseRpcController configuredController = configureRpcController (
590+ Preconditions .checkNotNull (controller , "RpcController can not be null for async rpc call" ));
631591 // This method does not throw any exceptions, so the caller must provide a
632592 // HBaseRpcController which is used to pass the exceptions.
633- this .rpcClient .callMethod (md , configuredController , param , returnType , ticket , isa , done );
593+ this .rpcClient .callMethod (md , configuredController , param , returnType , ticket , addr , done );
634594 }
635595 }
636596}
0 commit comments