use of org.apache.bookkeeper.mledger.AsyncCallbacks.CloseCallback in project pulsar by yahoo.
the class ManagedLedgerTest method asyncCloseWithoutError.
@Test(timeOut = 20000)
public void asyncCloseWithoutError() throws Exception {
ManagedLedger ledger = factory.open("my_test_ledger");
ledger.openCursor("test-cursor");
ledger.addEntry("dummy-entry-1".getBytes(Encoding));
final CountDownLatch counter = new CountDownLatch(1);
ledger.asyncClose(new CloseCallback() {
@Override
public void closeComplete(Object ctx) {
assertNull(ctx);
counter.countDown();
}
@Override
public void closeFailed(ManagedLedgerException exception, Object ctx) {
fail(exception.getMessage());
}
}, null);
counter.await();
}
use of org.apache.bookkeeper.mledger.AsyncCallbacks.CloseCallback in project pulsar by yahoo.
the class ManagedLedgerErrorsTest method asyncClosingManagedLedger.
@Test
public void asyncClosingManagedLedger() throws Exception {
ManagedLedger ledger = factory.open("my_test_ledger");
ledger.openCursor("c1");
bkc.failNow(BKException.Code.NoSuchLedgerExistsException);
final CountDownLatch latch = new CountDownLatch(1);
ledger.asyncClose(new CloseCallback() {
public void closeFailed(ManagedLedgerException exception, Object ctx) {
latch.countDown();
}
public void closeComplete(Object ctx) {
fail("should have failed");
}
}, null);
latch.await();
}
Aggregations