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);
}
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;
}
Aggregations