Calculate replicated log data size on recovery 09/17309/2
authorTom Pantelis <tpanteli@brocade.com>
Sat, 28 Mar 2015 14:23:40 +0000 (10:23 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 8 Apr 2015 05:22:27 +0000 (01:22 -0400)
We maintain the replicated log data size at runtme but we should also
calculate the data size for recovered entries on startup.

I changed the AbstractReplicatedLogImpl#append method to also add to the
dataSize. Previously dataSize was adjusted in ReplicatedLogImpl#appendAndPersist
after it was persisted. I'm not sure why it was done this way but if
persistence failed then the entry would've been added to the in-memory
log without increasing the dataSize. This seems inconsistent - if we add
to the log we should always increase the dataSize.

The same with removing entries from the log - ReplicatedLogImpl re-calculated
the dataSize after it was persisted. So I changed removeFrom to adjust
dataSize and changed ReplicatedLogImpl#removeFromAndPersist to call
AbstractReplicatedLogImpl#removeFrom (code was duplicated).

To avoid out-of-band changes to dataSize I made it private. Same with
journal. I think this is safer - these should be owned by
AbstractReplicatedLogImpl and derived classes shouldn't modify these
directly.

Change-Id: I114cbac1d6a450bc0a1c8c6ee60042ad28a89bf4
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>

No differences found