LocalJournal implements ChangeJournal { @Override public Records recordsNewerThan( LocalDateTime changeSetTime, boolean inclusive, boolean descendingOrder ) { if (stopped) { return Records.EMPTY; } long changeSetMillisUTC = -1; long searchBound = -1; if (changeSetTime != null) { changeSetMillisUTC = changeSetTime.toInstant(ZoneOffset.UTC).toEpochMilli(); searchBound = TIME_BASED_KEYS.getCounterStartingAt(changeSetMillisUTC - searchTimeDelta); } NavigableMap<Long, JournalRecord> subMap = records.tailMap(searchBound, true); if (subMap.isEmpty()) { return Records.EMPTY; } long startKeyInSubMap = -1; for (Iterator<Long> timeBasedKeysIterator = subMap.keySet().iterator(); timeBasedKeysIterator.hasNext();) { Long timeBasedKey = timeBasedKeysIterator.next(); JournalRecord record = subMap.get(timeBasedKey); long recordChangeTimeMillisUTC = record.getChangeTimeMillis(); if (((recordChangeTimeMillisUTC == changeSetMillisUTC) && inclusive) || recordChangeTimeMillisUTC > changeSetMillisUTC) { startKeyInSubMap = timeBasedKey; break; } } return startKeyInSubMap != -1 ? recordsFrom(subMap.tailMap(startKeyInSubMap, true), descendingOrder) : Records.EMPTY; } LocalJournal( String journalLocation,
                         boolean asyncWritesEnabled,
                         int maxDaysToKeepEntries ); protected  LocalJournal( String journalLocation ); @Override boolean started(); @SuppressWarnings( "rawtypes" ) @Override synchronized void start(); @Override synchronized void shutdown(); @Override void notify( ChangeSet changeSet ); @Override synchronized void addRecords( JournalRecord... records ); @Override synchronized void removeOldRecords(); @Override Records allRecords( boolean descendingOrder ); @Override JournalRecord lastRecord(); @Override Records recordsNewerThan( LocalDateTime changeSetTime,
                                     boolean inclusive,
                                     boolean descendingOrder ); @Override Iterator<NodeKey> changedNodesSince( final long timestamp ); @Override String journalId();  }
@Test public void shouldSearchRecordsBasedOnTimestamp() throws Exception { assertEquals(8, journal.recordsNewerThan(timestamp1.toLocalDateTime().minusDays(1), true, false).size()); assertEquals(5, journal.recordsNewerThan(timestamp1.toLocalDateTime(), true, false).size()); assertEquals(4, journal.recordsNewerThan(timestamp1.toLocalDateTime(), false, false).size()); assertEquals(2, journal.recordsNewerThan(timestamp2.toLocalDateTime(), false, false).size()); assertEquals(0, journal.recordsNewerThan(timestamp3.toLocalDateTime(), false, false).size()); assertEquals(1, journal.recordsNewerThan(timestamp3.toLocalDateTime(), true, false).size()); assertEquals(0, journal.recordsNewerThan(timestamp3.toLocalDateTime().plusDays(1), true, false).size()); }