use of org.apache.bookkeeper.mledger.Position in project pulsar by yahoo.
the class ManagedCursorTest method testFindNewestMatchingEdgeCase9.
@Test(timeOut = 20000)
void testFindNewestMatchingEdgeCase9() throws Exception {
ManagedLedger ledger = factory.open("testFindNewestMatchingEdgeCase9");
ManagedCursorImpl c1 = (ManagedCursorImpl) ledger.openCursor("c1");
ledger.addEntry("expired".getBytes(Encoding));
ledger.addEntry("expired".getBytes(Encoding));
ledger.addEntry("expired".getBytes(Encoding));
ledger.addEntry("expired".getBytes(Encoding));
ledger.addEntry("expired".getBytes(Encoding));
ledger.addEntry("expired".getBytes(Encoding));
Position lastPosition = ledger.addEntry("expired".getBytes(Encoding));
ledger.addEntry("not-expired".getBytes(Encoding));
List<Entry> entries = c1.readEntries(5);
c1.delete(entries.get(1).getPosition());
c1.delete(entries.get(3).getPosition());
entries.forEach(e -> e.release());
assertEquals(c1.findNewestMatching(entry -> Arrays.equals(entry.getDataAndRelease(), "expired".getBytes(Encoding))), lastPosition);
}
use of org.apache.bookkeeper.mledger.Position in project pulsar by yahoo.
the class ManagedCursorTest method testFindNewestMatchingEven3.
@Test(timeOut = 20000)
void testFindNewestMatchingEven3() throws Exception {
ManagedLedger ledger = factory.open("my_test_ledger");
ManagedCursorImpl c1 = (ManagedCursorImpl) ledger.openCursor("c1");
ledger.addEntry("expired".getBytes(Encoding));
ledger.addEntry("expired".getBytes(Encoding));
Position p3 = ledger.addEntry("expired".getBytes(Encoding));
ledger.addEntry("not-expired".getBytes(Encoding));
assertEquals(c1.findNewestMatching(entry -> Arrays.equals(entry.getDataAndRelease(), "expired".getBytes(Encoding))), p3);
}
use of org.apache.bookkeeper.mledger.Position in project pulsar by yahoo.
the class ManagedCursorTest method testReadingAllFilteredEntries.
@Test(timeOut = 20000)
void testReadingAllFilteredEntries() throws Exception {
ManagedLedger ledger = factory.open("my_test_ledger", new ManagedLedgerConfig().setMaxEntriesPerLedger(3));
ledger.openCursor("c1");
ManagedCursor c2 = ledger.openCursor("c2");
ledger.addEntry("entry1".getBytes());
Position p2 = ledger.addEntry("entry2".getBytes());
Position p3 = ledger.addEntry("entry3".getBytes());
Position p4 = ledger.addEntry("entry4".getBytes());
Position p5 = ledger.addEntry("entry5".getBytes());
c2.readEntries(1).get(0).release();
c2.delete(p2);
c2.delete(p3);
List<Entry> entries = c2.readEntries(2);
assertEquals(entries.size(), 2);
assertEquals(entries.get(0).getPosition(), p4);
assertEquals(entries.get(1).getPosition(), p5);
entries.forEach(e -> e.release());
}
use of org.apache.bookkeeper.mledger.Position in project pulsar by yahoo.
the class ManagedCursorTest method testFindNewestMatchingOdd3.
@Test(timeOut = 20000)
void testFindNewestMatchingOdd3() throws Exception {
ManagedLedger ledger = factory.open("my_test_ledger");
ManagedCursorImpl c1 = (ManagedCursorImpl) ledger.openCursor("c1");
ledger.addEntry("expired".getBytes(Encoding));
ledger.addEntry("expired".getBytes(Encoding));
Position p3 = ledger.addEntry("expired".getBytes(Encoding));
ledger.addEntry("not-expired".getBytes(Encoding));
ledger.addEntry("not-expired".getBytes(Encoding));
assertEquals(c1.findNewestMatching(entry -> Arrays.equals(entry.getDataAndRelease(), "expired".getBytes(Encoding))), p3);
}
use of org.apache.bookkeeper.mledger.Position in project pulsar by yahoo.
the class ManagedCursorTest method testReopenMultipleTimes.
@Test(timeOut = 20000)
public void testReopenMultipleTimes() throws Exception {
ManagedLedger ledger = factory.open("testReopenMultipleTimes");
ManagedCursor c1 = ledger.openCursor("c1");
Position mdPosition = c1.getMarkDeletedPosition();
c1.close();
ledger.close();
ledger = factory.open("testReopenMultipleTimes");
c1 = ledger.openCursor("c1");
// since the empty data ledger will be deleted, the cursor position should also be updated
assertNotEquals(c1.getMarkDeletedPosition(), mdPosition);
c1.close();
ledger.close();
ledger = factory.open("testReopenMultipleTimes");
c1 = ledger.openCursor("c1");
}
Aggregations