bookkeeper-distributedlog-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject incubator-distributedlog git commit: DL-90: Don't use stack and codec together for configuring thriftmux
Date Sat, 17 Dec 2016 07:55:41 GMT
Repository: incubator-distributedlog
Updated Branches:
  refs/heads/master 132dadc80 -> 53f7b5821


DL-90: Don't use stack and codec together for configuring thriftmux

merge Twitter's change on thriftmux

Author: Sijie Guo <sijieg@twitter.com>
Author: Jordan Bull <jbull@twitter.com>
Author: Sijie Guo <sijie@apache.org>
Author: Leigh Stewart <lstewart@twitter.com>
Author: Dave Rusek <dave.rusek@gmail.com>
Author: Dave Rusek <drusek@twitter.com>

Reviewers: Leigh Stewart <lstewart@apache.org>

Closes #62 from sijie/merge/DL-90


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

Branch: refs/heads/master
Commit: 53f7b582167d8fe58c7ee63eaebccde72e3601a4
Parents: 132dadc
Author: Dave Rusek <drusek@apache.org>
Authored: Fri Dec 16 23:55:48 2016 -0800
Committer: Sijie Guo <sijie@apache.org>
Committed: Fri Dec 16 23:55:48 2016 -0800

----------------------------------------------------------------------
 .../client/proxy/ProxyClient.java               | 28 ++++++++++++--------
 .../distributedlog/DistributedLogConstants.java |  2 +-
 2 files changed, 18 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/53f7b582/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

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/53f7b582/distributedlog-core/src/main/java/com/twitter/distributedlog/DistributedLogConstants.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/main/java/com/twitter/distributedlog/DistributedLogConstants.java
b/distributedlog-core/src/main/java/com/twitter/distributedlog/DistributedLogConstants.java
index 32def94..e798a0f 100644
--- a/distributedlog-core/src/main/java/com/twitter/distributedlog/DistributedLogConstants.java
+++ b/distributedlog-core/src/main/java/com/twitter/distributedlog/DistributedLogConstants.java
@@ -58,7 +58,7 @@ public class DistributedLogConstants {
     public static final String COMPLETED_LOGSEGMENT_PREFIX = "logrecs";
     public static final String DISALLOW_PLACEMENT_IN_REGION_FEATURE_NAME = "disallow_bookie_placement";
     static final byte[] CONTROL_RECORD_CONTENT = "control".getBytes(UTF_8);
-    public static final byte[] KEEPALIVE_RECORD_CONTENT = "keepalive".getBytes(UTF_8);
+    static final byte[] KEEPALIVE_RECORD_CONTENT = "keepalive".getBytes(UTF_8);
 
     // An ACL that gives all permissions to node creators and read permissions only to everyone
else.
     public static final List<ACL> EVERYONE_READ_CREATOR_ALL =


Mime
View raw message