use of org.apache.bookkeeper.mledger.ManagedLedger 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();
}
use of org.apache.bookkeeper.mledger.ManagedLedger in project pulsar by yahoo.
the class ManagedLedgerErrorsTest method removingCursor.
@Test
public void removingCursor() throws Exception {
ManagedLedger ledger = factory.open("my_test_ledger");
ManagedCursor c1 = ledger.openCursor("c1");
assertEquals(zkc.exists("/managed-ledgers/my_test_ledger/c1", false) != null, true);
zkc.failNow(Code.BADVERSION);
try {
c1.close();
fail("should fail");
} catch (ManagedLedgerException e) {
// ok
}
bkc.failNow(BKException.Code.NoSuchLedgerExistsException);
// Cursor ledger deletion will fail, but that should not prevent the deleteCursor to fail
ledger.deleteCursor("c1");
assertEquals(zkc.exists("/managed-ledgers/my_test_ledger/c1", false) != null, false);
assertEquals(bkc.getLedgers().size(), 2);
}
use of org.apache.bookkeeper.mledger.ManagedLedger in project pulsar by yahoo.
the class ManagedLedgerErrorsTest method errorInUpdatingLedgersList.
@Test(timeOut = 20000, invocationCount = 1, skipFailedInvocations = true, enabled = false)
public void errorInUpdatingLedgersList() throws Exception {
ManagedLedger ledger = factory.open("my_test_ledger", new ManagedLedgerConfig().setMaxEntriesPerLedger(1));
final CountDownLatch latch = new CountDownLatch(1);
zkc.failAfter(0, Code.CONNECTIONLOSS);
ledger.asyncAddEntry("entry".getBytes(), new AddEntryCallback() {
public void addFailed(ManagedLedgerException exception, Object ctx) {
// not-ok
}
public void addComplete(Position position, Object ctx) {
// ok
}
}, null);
ledger.asyncAddEntry("entry".getBytes(), new AddEntryCallback() {
public void addFailed(ManagedLedgerException exception, Object ctx) {
latch.countDown();
}
public void addComplete(Position position, Object ctx) {
fail("should have failed");
}
}, null);
latch.await();
}
use of org.apache.bookkeeper.mledger.ManagedLedger in project pulsar by yahoo.
the class ManagedLedgerErrorsTest method errorInRecovering.
@Test
public void errorInRecovering() throws Exception {
ManagedLedger ledger = factory.open("my_test_ledger");
ledger.addEntry("entry".getBytes());
ledger.close();
factory = new ManagedLedgerFactoryImpl(bkc, zkc);
bkc.failNow(BKException.Code.LedgerFencedException);
try {
ledger = factory.open("my_test_ledger");
fail("should fail");
} catch (ManagedLedgerException e) {
// ok
}
// It should be fine now
ledger = factory.open("my_test_ledger");
}
use of org.apache.bookkeeper.mledger.ManagedLedger in project pulsar by yahoo.
the class ManagedLedgerErrorsTest method errorInRecovering3.
@Test
public void errorInRecovering3() throws Exception {
ManagedLedger ledger = factory.open("my_test_ledger");
ledger.addEntry("entry".getBytes());
ledger.close();
factory = new ManagedLedgerFactoryImpl(bkc, zkc);
bkc.failAfter(1, BKException.Code.LedgerFencedException);
try {
ledger = factory.open("my_test_ledger");
fail("should fail");
} catch (ManagedLedgerException e) {
// ok
}
// It should be fine now
ledger = factory.open("my_test_ledger");
}
Aggregations