@Test public void processesTruncationRequestsByDelegatingThemToTheSuppliedPersistence() throws Exception { long entryAddress = 100; context.checking(new Expectations() {{ allowing(navigator).notifyTruncation(with(any(Long.class))); oneOf(navigator).getAddressOfEntry(seqNum(7)); will(returnValue(entryAddress)); oneOf(persistence).truncate(entryAddress); }}); log.truncate(seqNum(7)); }
@Override public void truncate(long seqNum) throws IOException, LogEntryNotFound { long truncationPos = persistenceNavigator.getAddressOfEntry(seqNum); persistence.truncate(truncationPos); persistenceNavigator.notifyTruncation(seqNum); }
EncodedSequentialLog implements SequentialLog<E> { @Override public void truncate(long seqNum) throws IOException, LogEntryNotFound { long truncationPos = persistenceNavigator.getAddressOfEntry(seqNum); persistence.truncate(truncationPos); persistenceNavigator.notifyTruncation(seqNum); } }
EncodedSequentialLog implements SequentialLog<E> { @Override public void truncate(long seqNum) throws IOException, LogEntryNotFound { long truncationPos = persistenceNavigator.getAddressOfEntry(seqNum); persistence.truncate(truncationPos); persistenceNavigator.notifyTruncation(seqNum); } EncodedSequentialLog(BytePersistence persistence,
                              SequentialEntryCodec<E> codec,
                              PersistenceNavigator persistenceNavigator); }
EncodedSequentialLog implements SequentialLog<E> { @Override public void truncate(long seqNum) throws IOException, LogEntryNotFound { long truncationPos = persistenceNavigator.getAddressOfEntry(seqNum); persistence.truncate(truncationPos); persistenceNavigator.notifyTruncation(seqNum); } EncodedSequentialLog(BytePersistence persistence,
                              SequentialEntryCodec<E> codec,
                              PersistenceNavigator persistenceNavigator); @Override void append(List<E> entries); @Override List<E> subSequence(long start, long end); @Override boolean isEmpty(); @Override E getLastEntry(); @Override SequentialEntryIterator<E> iterator(); @Override void truncate(long seqNum); @Override void sync(); @Override void close(); }
EncodedSequentialLog implements SequentialLog<E> { @Override public void truncate(long seqNum) throws IOException, LogEntryNotFound { long truncationPos = persistenceNavigator.getAddressOfEntry(seqNum); persistence.truncate(truncationPos); persistenceNavigator.notifyTruncation(seqNum); } EncodedSequentialLog(BytePersistence persistence,
                              SequentialEntryCodec<E> codec,
                              PersistenceNavigator persistenceNavigator); @Override void append(List<E> entries); @Override List<E> subSequence(long start, long end); @Override boolean isEmpty(); @Override E getLastEntry(); @Override SequentialEntryIterator<E> iterator(); @Override void truncate(long seqNum); @Override void sync(); @Override void close();  }