[ 
https://issues.apache.org/jira/browse/TAJO-1860?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14759985#comment-14759985
 ] 

ASF GitHub Bot commented on TAJO-1860:
--------------------------------------

Github user jinossy commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/763#discussion_r39621292
  
    --- Diff: 
tajo-rpc/tajo-rpc-protobuf/src/main/java/org/apache/tajo/rpc/AsyncRpcClient.java
 ---
    @@ -18,56 +18,53 @@
     
     package org.apache.tajo.rpc;
     
    -import com.google.common.annotations.VisibleForTesting;
     import com.google.protobuf.Descriptors.MethodDescriptor;
     import com.google.protobuf.*;
     import io.netty.channel.ChannelHandler;
     import io.netty.channel.EventLoopGroup;
    -import org.apache.tajo.rpc.RpcClientManager.RpcConnectionKey;
     import org.apache.tajo.rpc.RpcProtos.RpcResponse;
     
     import java.lang.reflect.Method;
    +import java.util.Properties;
     import java.util.concurrent.TimeUnit;
     import java.util.concurrent.atomic.AtomicInteger;
     
    +import static org.apache.tajo.rpc.RpcConstants.CLIENT_SOCKET_TIMEOUT;
    +import static 
org.apache.tajo.rpc.RpcConstants.CLIENT_SOCKET_TIMEOUT_DEFAULT;
    +
     public class AsyncRpcClient extends 
NettyClientBase<AsyncRpcClient.ResponseCallback> {
     
       private final Method stubMethod;
       private final ProxyRpcChannel rpcChannel;
       private final NettyChannelInboundHandler handler;
     
    -  @VisibleForTesting
    -  AsyncRpcClient(RpcConnectionKey rpcConnectionKey, int retries)
    -      throws ClassNotFoundException, NoSuchMethodException {
    -    this(rpcConnectionKey, retries, 0, TimeUnit.NANOSECONDS, false, 
NettyUtils.getDefaultEventLoopGroup());
    -  }
     
       /**
        * Intentionally make this method package-private, avoiding user directly
        * new an instance through this constructor.
        *
    -   * @param rpcConnectionKey
    -   * @param retries          retry operation number of times
    -   * @param timeout          disable ping, it trigger timeout event on 
idle-state.
    -   *                         otherwise it is request timeout on 
active-state
    -   * @param timeUnit         TimeUnit
    -   * @param enablePing       enable to detect remote peer hangs
    -   * @param eventLoopGroup   thread pool of netty's
    +   * @param rpcConnectionKey  RpcConnectionKey
    +   * @param eventLoopGroup    Thread pool of netty's
    +   * @param connectionParameters Connection parameters (see RpcConstants)
    +   *
        * @throws ClassNotFoundException
        * @throws NoSuchMethodException
        */
    -  AsyncRpcClient(RpcConnectionKey rpcConnectionKey, int retries, long 
timeout, TimeUnit timeUnit, boolean enablePing,
    -                 EventLoopGroup eventLoopGroup)
    +  AsyncRpcClient(EventLoopGroup eventLoopGroup,
    +                 RpcConnectionKey rpcConnectionKey,
    +                 Properties connectionParameters)
           throws ClassNotFoundException, NoSuchMethodException {
    -    super(rpcConnectionKey, retries);
    +    super(rpcConnectionKey, connectionParameters);
     
         this.stubMethod = getServiceClass().getMethod("newStub", 
RpcChannel.class);
         this.rpcChannel = new ProxyRpcChannel();
         this.handler = new ClientChannelInboundHandler();
    -    init(new ProtoClientChannelInitializer(handler,
    -        RpcResponse.getDefaultInstance(),
    -        timeUnit.toNanos(timeout),
    -        enablePing), eventLoopGroup);
    +
    +    final long socketTimeoutMills = Long.parseLong(
    +        connectionParameters.getProperty(CLIENT_SOCKET_TIMEOUT, 
String.valueOf(CLIENT_SOCKET_TIMEOUT_DEFAULT)));
    +
    +    init(new ProtoClientChannelInitializer(handler, 
RpcResponse.getDefaultInstance(),
    +        TimeUnit.MILLISECONDS.toNanos(socketTimeoutMills)),eventLoopGroup);
    --- End diff --
    
    You should remove toNanos()


> Refactor Rpc clients to take Connection Parameters
> --------------------------------------------------
>
>                 Key: TAJO-1860
>                 URL: https://issues.apache.org/jira/browse/TAJO-1860
>             Project: Tajo
>          Issue Type: Improvement
>          Components: RPC
>            Reporter: Hyunsik Choi
>            Assignee: Hyunsik Choi
>             Fix For: 0.11.0
>
>
> Currently, Rpc client implementations only takes few parameters. This 
> refactoring allows rpc clients to take flexible parameters. I also add 
> connection timeout and cleaned up some routines.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to