distributedlog-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject [08/29] incubator-distributedlog git commit: Don't use stack and codec together for configuring thriftmux
Date Wed, 21 Dec 2016 08:00:16 GMT
Don't use stack and codec together for configuring thriftmux

- Don't use stack and codec together for configuring thriftmux
- Remove codec if the thriftmux is disabled


Project: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/commit/800b867b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/tree/800b867b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/diff/800b867b

Branch: refs/heads/merge/DL-98
Commit: 800b867b705a786094b9a591e0ebc64fa934f632
Parents: d3a97bc
Author: Dave Rusek <dave.rusek@gmail.com>
Authored: Mon Dec 12 16:41:47 2016 -0800
Committer: Sijie Guo <sijieg@twitter.com>
Committed: Mon Dec 12 16:41:47 2016 -0800

----------------------------------------------------------------------
 .../client/proxy/ProxyClient.java               | 28 ++++++++++++--------
 1 file changed, 17 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/800b867b/distributedlog-client/src/main/java/com/twitter/distributedlog/client/proxy/ProxyClient.java
----------------------------------------------------------------------
diff --git a/distributedlog-client/src/main/java/com/twitter/distributedlog/client/proxy/ProxyClient.java
b/distributedlog-client/src/main/java/com/twitter/distributedlog/client/proxy/ProxyClient.java
index 03dd3c2..4c79327 100644
--- a/distributedlog-client/src/main/java/com/twitter/distributedlog/client/proxy/ProxyClient.java
+++ b/distributedlog-client/src/main/java/com/twitter/distributedlog/client/proxy/ProxyClient.java
@@ -75,30 +75,36 @@ public class ProxyClient {
             this.clientId = clientId;
             this.clientStats = clientStats;
             // client builder
-            ClientBuilder builder = setDefaultSettings(null == clientBuilder ? getDefaultClientBuilder()
: clientBuilder);
-            if (clientConfig.getThriftMux()) {
-                builder = enableThriftMux(builder, clientId);
-            }
-            this.clientBuilder = builder;
+            ClientBuilder builder = setDefaultSettings(
+                    null == clientBuilder ? getDefaultClientBuilder(clientConfig) : clientBuilder);
+            this.clientBuilder = configureThriftMux(builder, clientId, clientConfig);
         }
 
         @SuppressWarnings("unchecked")
-        private ClientBuilder enableThriftMux(ClientBuilder builder, ClientId clientId) {
-            return builder.stack(ThriftMux.client().withClientId(clientId));
+        private ClientBuilder configureThriftMux(ClientBuilder builder,
+                                                 ClientId clientId,
+                                                 ClientConfig clientConfig) {
+            if (clientConfig.getThriftMux()) {
+                return builder.stack(ThriftMux.client().withClientId(clientId));
+            } else {
+                return builder.codec(ThriftClientFramedCodec.apply(Option.apply(clientId)));
+            }
         }
 
-        private ClientBuilder getDefaultClientBuilder() {
-            return ClientBuilder.get()
-                .hostConnectionLimit(1)
+        private ClientBuilder getDefaultClientBuilder(ClientConfig clientConfig) {
+            ClientBuilder builder = ClientBuilder.get()
                 .tcpConnectTimeout(Duration.fromMilliseconds(200))
                 .connectTimeout(Duration.fromMilliseconds(200))
                 .requestTimeout(Duration.fromSeconds(1));
+            if (!clientConfig.getThriftMux()) {
+                builder = builder.hostConnectionLimit(1);
+            }
+            return builder;
         }
 
         @SuppressWarnings("unchecked")
         private ClientBuilder setDefaultSettings(ClientBuilder builder) {
             return builder.name(clientName)
-                   .codec(ThriftClientFramedCodec.apply(Option.apply(clientId)))
                    .failFast(false)
                    .noFailureAccrual()
                    // disable retries on finagle client builder, as there is only one host
per finagle client


Mime
View raw message