+ long numberOfEntriesToReplicate = lastEntryId - firstEntryId;
should be (lastEntryId - firstEntryId) + 1
You are right, both side entries has to be considered. Thank a lot for noticing it.
In general, I think this splitting should be in LedgerFragmentReplicator, rather than BookKeeperAdmin. This way you could avoid the need to expose the update of ledger metadata. It will make control flow a little more complex as you'll have to initiate replication on the next subfragment from the callback of the current, but i think it would encapsulate things a bit better.
Yes, in general, all the split logic should be in LFR. I might pushed that code to BKAdmin because, I don't want to disturb admin key flow much, which will go through LFR.
Now anyway, I moved that logic, still not disturbing BKAdmin key flows in anyway.
Attached a patch, which addresses the comments.
Also to give more confidence on split fragment scenarios, I have added multiple boundary cases for FragmentSplit.
Thanks a lot, Ivan for your nice reviews!