Hi Guys,
I am experimenting the managed-ledger implementation (
https://github.com/merlimat/managed-ledger ). It works good in one session,
but if I add some entries to managed ledger and shutdown the first session
and then start a new session. Managed cursor no longer give right number of
entries. Here's what I did with managed-legers (I paly with managed-ledger
with scala repl )
Start a new scala repl and input the following code:
import org.apache.bookkeeper.mledger._
import org.apache.bookkeeper.mledger.impl._
val factory = new ManagedLedgerFactoryImpl("127.0.0.1:2181")
val ledger = factory.open("my_test_ledger")
val cursor = ledger.openCursor("c1");
ledger.addEntry("dummy-entry-1".getBytes()) // add one entry to managed ledger
scala> cursor.getNumberOfEntries // # of entries are correct in the same session
res1: Long = 1
scala> cursor.hasMoreEntries //# there's one entry added but not
consumed yet, so hasMoreEntires is true.
res2: Boolean = true
Then I quit the scala repl and start a new one with the following code ( I
expect for the same cursor "c1" the number of entries should be 1 and
hasMoreEntries should be true but it's not)
import org.apache.bookkeeper.mledger._
import org.apache.bookkeeper.mledger.impl._
val factory = new ManagedLedgerFactoryImpl("127.0.0.1:2181")
val ledger = factory.open("my_test_ledger")
val cursor = ledger.openCursor("c1");
scala> cursor.getNumberOfEntries
res0: Long = 1 // this number is correct and wrong
sometimes. I noticed it return 11 once but I only added 1 entry in the last
session.
scala> cursor.hasMoreEntries // this is inconsistent with
cursor.getNumberOfEntries,
there's 1 entry not consumed so cursor.hasMoreEntries should return true
not false.
res1: Boolean = false
Any suggestions ?
Best Regards,
Stone