sijie commented on a change in pull request #1436: BP-14 force() API - client 
side implementation
URL: https://github.com/apache/bookkeeper/pull/1436#discussion_r193180806
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
 ##########
 @@ -1100,6 +1100,68 @@ public void asyncAddEntry(final long entryId, final 
byte[] data, final int offse
         cb.addCompleteWithLatency(BKException.Code.IllegalOpException, 
LedgerHandle.this, entryId, 0, ctx);
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public CompletableFuture<Void> force() {
+        CompletableFuture<Void> result = new CompletableFuture<>();
+        ForceLedgerOp op = new ForceLedgerOp(this, result);
+        boolean wasClosed = false;
+        synchronized (this) {
+            // synchronized on this to ensure that
+            // the ledger isn't closed between checking and
+            // updating lastAddPushed
+            if (metadata.isClosed()) {
+                wasClosed = true;
+            }
+        }
+
+        if (wasClosed) {
+            // make sure the callback is triggered in main worker pool
+            try {
+                bk.getMainWorkerPool().submit(new SafeRunnable() {
 
 Review comment:
   better use `executeOrdered`

----------------------------------------------------------------
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