You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/03/29 01:29:44 UTC

[GitHub] merlimat commented on a change in pull request #1292: Avoid acquiring closeLock.readLock() on every add/read operation

merlimat commented on a change in pull request #1292: Avoid acquiring closeLock.readLock() on every add/read operation
URL: https://github.com/apache/bookkeeper/pull/1292#discussion_r177933573
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieClient.java
 ##########
 @@ -189,40 +189,35 @@ public PerChannelBookieClientPool lookupClient(BookieSocketAddress addr) {
 
     public void writeLac(final BookieSocketAddress addr, final long ledgerId, final byte[] masterKey,
             final long lac, final ByteBufList toSend, final WriteLacCallback cb, final Object ctx) {
-        closeLock.readLock().lock();
-        try {
-            final PerChannelBookieClientPool client = lookupClient(addr);
-            if (client == null) {
-                cb.writeLacComplete(getRc(BKException.Code.BookieHandleNotAvailableException),
-                                  ledgerId, addr, ctx);
-                return;
-            }
+        final PerChannelBookieClientPool client = lookupClient(addr);
+        if (client == null) {
+            cb.writeLacComplete(getRc(BKException.Code.BookieHandleNotAvailableException),
+                              ledgerId, addr, ctx);
+            return;
+        }
 
-            toSend.retain();
-            client.obtain(new GenericCallback<PerChannelBookieClient>() {
-                @Override
-                public void operationComplete(final int rc, PerChannelBookieClient pcbc) {
-                    if (rc != BKException.Code.OK) {
-                        try {
-                            executor.submitOrdered(ledgerId, new SafeRunnable() {
-                                @Override
-                                public void safeRun() {
-                                    cb.writeLacComplete(rc, ledgerId, addr, ctx);
-                                }
-                            });
-                        } catch (RejectedExecutionException re) {
-                            cb.writeLacComplete(getRc(BKException.Code.InterruptedException), ledgerId, addr, ctx);
-                        }
-                    } else {
-                        pcbc.writeLac(ledgerId, masterKey, lac, toSend, cb, ctx);
+        toSend.retain();
+        client.obtain(new GenericCallback<PerChannelBookieClient>() {
 
 Review comment:
   make sense, I didn't do it initially since I just removed try/finally and de-indented, but since it anyway looks like these lines are changed.. I might as well convert them.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services