[
https://issues.apache.org/jira/browse/TAJO-1860?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14760998#comment-14760998
]
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_r39621315
--- Diff:
tajo-rpc/tajo-rpc-protobuf/src/main/java/org/apache/tajo/rpc/BlockingRpcClient.java
---
@@ -18,56 +18,54 @@
package org.apache.tajo.rpc;
-import com.google.common.annotations.VisibleForTesting;
import com.google.protobuf.*;
import com.google.protobuf.Descriptors.MethodDescriptor;
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.net.InetSocketAddress;
+import java.util.Properties;
import java.util.concurrent.*;
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 BlockingRpcClient extends
NettyClientBase<BlockingRpcClient.ProtoCallFuture> {
private final Method stubMethod;
private final ProxyRpcChannel rpcChannel;
private final NettyChannelInboundHandler handler;
- @VisibleForTesting
- BlockingRpcClient(RpcConnectionKey rpcConnectionKey, int retries)
- throws NoSuchMethodException, ClassNotFoundException {
- 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
+ * @see RpcConstants
*/
- BlockingRpcClient(RpcConnectionKey rpcConnectionKey, int retries, long
timeout, TimeUnit timeUnit, boolean enablePing,
- EventLoopGroup eventLoopGroup) throws
ClassNotFoundException, NoSuchMethodException {
- super(rpcConnectionKey, retries);
+ public BlockingRpcClient(EventLoopGroup eventLoopGroup,
+ RpcConnectionKey rpcConnectionKey,
+ Properties connectionParameters)
+ throws ClassNotFoundException, NoSuchMethodException {
+ super(rpcConnectionKey, connectionParameters);
this.stubMethod = getServiceClass().getMethod("newBlockingStub",
BlockingRpcChannel.class);
this.rpcChannel = new ProxyRpcChannel();
this.handler = new ClientChannelInboundHandler();
- init(new ProtoClientChannelInitializer(handler,
- RpcResponse.getDefaultInstance(),
- timeUnit.toNanos(timeout),
- enablePing), eventLoopGroup);
+
+ 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)