protected SyncListResponse<E> _listEntries(final KeyRange inRange,
final long since, final int maxCount)
throws InterruptedException, StoreException
{
final StorableStore store = _stores.getEntryStore();
final ArrayList<E> result = new ArrayList<E>(Math.min(100, maxCount));
long lastSeenTimestamp = 0L;
long clientWait = 0L; // we may instruct client to do bit of waiting before retry
// let's only allow single wait; hence two rounds
long upTo0 = 0;
for (int round = 0; round < 2; ++round) {
upTo0 = _timeMaster.currentTimeMillis() - _cfgSyncGracePeriodMsecs;
/* 19-Sep-2012, tatu: Alas, it is difficult to make this work with virtual time,
* tests; so for now we will use actual real system time and not virtual time.
* May need to revisit in future.
*/
final long realStartTime = _timeMaster.realSystemTimeMillis();
if (upTo0 >= realStartTime) { // sanity check (better safe than sorry)
throw new IllegalStateException("Argument 'upTo' too high ("+upTo0+"): can not exceed current time ("
+realStartTime);
}
/* one more thing: need to make sure we can skip entries that
* have been updated concurrently (rare, but possible).
*/
long oldestInFlight = store.getOldestInFlightTimestamp();
if (oldestInFlight != 0L) {
if (upTo0 > oldestInFlight) {
// since it's rare, add INFO logging to see if ever encounter this
LOG.info("Oldest in-flight ({}) higher than upTo ({}), use former as limit",
oldestInFlight, upTo0);