rdhabalia commented on a change in pull request #2041: Added ReadOnlyCursor to 
ManagedLedger
URL: https://github.com/apache/incubator-pulsar/pull/2041#discussion_r199384750
 
 

 ##########
 File path: 
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryImpl.java
 ##########
 @@ -255,6 +260,64 @@ public void initializeFailed(ManagedLedgerException e) {
         });
     }
 
+
+
+    @Override
+    public ReadOnlyCursor openReadOnlyCursor(String managedLedgerName, 
Position startPosition, ManagedLedgerConfig config)
+            throws InterruptedException, ManagedLedgerException {
+        class Result {
+            ReadOnlyCursor c = null;
+            ManagedLedgerException e = null;
+        }
+        final Result r = new Result();
+        final CountDownLatch latch = new CountDownLatch(1);
+        asyncOpenReadOnlyCursor(managedLedgerName, startPosition, config, new 
OpenReadOnlyCursorCallback() {
+            @Override
+            public void openReadOnlyCursorComplete(ReadOnlyCursor cursor, 
Object ctx) {
+                r.c = cursor;
+                latch.countDown();
+            }
+
+            @Override
+            public void openReadOnlyCursorFailed(ManagedLedgerException 
exception, Object ctx) {
+                r.e = exception;
+                latch.countDown();
+            }
+        }, null);
+
+        latch.await();
+
+        if (r.e != null) {
+            throw r.e;
+        }
+        return r.c;
+    }
+
+    @Override
+    public void asyncOpenReadOnlyCursor(String managedLedgerName, Position 
startPosition, ManagedLedgerConfig config,
+            OpenReadOnlyCursorCallback callback, Object ctx) {
+        checkArgument(startPosition instanceof PositionImpl);
 
 Review comment:
   is it possible to avoid throwing runtime-exception and complete the callback 
with failure.

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