bookkeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matteo Merli <mme...@yahoo-inc.com>
Subject Re: ManagedCursor gives wrong number of entries (sometimes) when reestablish connection after shutdown
Date Mon, 11 Jun 2012 22:48:16 GMT
Hi Stone,

you are right, there's a problem in the ManagedCursor.hasMoreEntries() when the cursor hasn't
been "initialized" (ie: read from) and it's opened in a new session.
I fixed that and added a new test case in http://github.com/merlimat/managed-ledger/commit/60fa8a93f09715cb64a9d02f4e4430122e50d48a

On the other hand I cannot reproduce the problem with cursor.getNumberOfEntries(), I consistently
get the right value.

Thank you for catching and pointing out this bug.

Matteo

On Jun 10, 2012, at 11:19 PM, Stone wrote:

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<http://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<http://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


matteo
merli

technical yahoo!

mmerli@yahoo-inc.com<mailto:mmerli@yahoo-inc.com>
direct 408-336-6035

701 first avenue, sunnyvale, ca, 94089-0703, us
phone (408) 349 3300    fax (408) 349 3301

[cid:DF0C4C0F-53B5-433E-BD38-901D3506823B]


Mime
View raw message