sijie commented on a change in pull request #1088: ISSUE #1086 (@bug 
W-4146427@) Client-side backpressure in netty (Fixes: 
io.netty.util.internal.OutOfDirectMemoryError under continuous heavy load)
URL: https://github.com/apache/bookkeeper/pull/1088#discussion_r170852965
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/DefaultPerChannelBookieClientPool.java
 ##########
 @@ -84,14 +84,22 @@ public void intialize() {
         }
     }
 
-    @Override
-    public void obtain(GenericCallback<PerChannelBookieClient> callback, long 
key) {
+    private PerChannelBookieClient getClient(long key) {
         if (1 == clients.length) {
-            clients[0].connectIfNeededAndDoOp(callback);
-            return;
+            return clients[0];
         }
         int idx = MathUtils.signSafeMod(key, clients.length);
-        clients[idx].connectIfNeededAndDoOp(callback);
+        return clients[idx];
+    }
+
+    @Override
+    public void obtain(GenericCallback<PerChannelBookieClient> callback, long 
key) {
+        getClient(key).connectIfNeededAndDoOp(callback);
 
 Review comment:
   Can we do smarter here?
   
   randomly pickup a channel, if the channel is not writable, do iteration 
start this randomly picked channel to pick next writable channel?
   
   so the logic here would work for multiple connections case.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to