Search in sources :

Example 1 with ManagedLedgerInfoCallback

use of org.apache.bookkeeper.mledger.AsyncCallbacks.ManagedLedgerInfoCallback in project incubator-pulsar by apache.

the class PersistentTopicsBase method internalGetManagedLedgerInfo.

protected void internalGetManagedLedgerInfo(AsyncResponse asyncResponse) {
    validateAdminAccessOnProperty(topicName.getProperty());
    if (topicName.isGlobal()) {
        validateGlobalNamespaceOwnership(namespaceName);
    }
    String managedLedger = topicName.getPersistenceNamingEncoding();
    pulsar().getManagedLedgerFactory().asyncGetManagedLedgerInfo(managedLedger, new ManagedLedgerInfoCallback() {

        @Override
        public void getInfoComplete(ManagedLedgerInfo info, Object ctx) {
            asyncResponse.resume((StreamingOutput) output -> {
                jsonMapper().writer().writeValue(output, info);
            });
        }

        @Override
        public void getInfoFailed(ManagedLedgerException exception, Object ctx) {
            asyncResponse.resume(exception);
        }
    }, null);
}
Also used : ManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException) ManagedLedgerInfoCallback(org.apache.bookkeeper.mledger.AsyncCallbacks.ManagedLedgerInfoCallback) StreamingOutput(javax.ws.rs.core.StreamingOutput) ManagedLedgerInfo(org.apache.bookkeeper.mledger.ManagedLedgerInfo)

Example 2 with ManagedLedgerInfoCallback

use of org.apache.bookkeeper.mledger.AsyncCallbacks.ManagedLedgerInfoCallback in project incubator-pulsar by apache.

the class ManagedLedgerFactoryImpl method getManagedLedgerInfo.

@Override
public ManagedLedgerInfo getManagedLedgerInfo(String name) throws InterruptedException, ManagedLedgerException {
    class Result {

        ManagedLedgerInfo info = null;

        ManagedLedgerException e = null;
    }
    final Result r = new Result();
    final CountDownLatch latch = new CountDownLatch(1);
    asyncGetManagedLedgerInfo(name, new ManagedLedgerInfoCallback() {

        @Override
        public void getInfoComplete(ManagedLedgerInfo info, Object ctx) {
            r.info = info;
            latch.countDown();
        }

        @Override
        public void getInfoFailed(ManagedLedgerException exception, Object ctx) {
            r.e = exception;
            latch.countDown();
        }
    }, null);
    latch.await();
    if (r.e != null) {
        throw r.e;
    }
    return r.info;
}
Also used : ManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException) ManagedLedgerException.getManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException.getManagedLedgerException) ManagedLedgerInfoCallback(org.apache.bookkeeper.mledger.AsyncCallbacks.ManagedLedgerInfoCallback) CountDownLatch(java.util.concurrent.CountDownLatch) ManagedLedgerInfo(org.apache.bookkeeper.mledger.ManagedLedgerInfo)

Aggregations

ManagedLedgerInfoCallback (org.apache.bookkeeper.mledger.AsyncCallbacks.ManagedLedgerInfoCallback)2 ManagedLedgerException (org.apache.bookkeeper.mledger.ManagedLedgerException)2 ManagedLedgerInfo (org.apache.bookkeeper.mledger.ManagedLedgerInfo)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 StreamingOutput (javax.ws.rs.core.StreamingOutput)1 ManagedLedgerException.getManagedLedgerException (org.apache.bookkeeper.mledger.ManagedLedgerException.getManagedLedgerException)1