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()
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---