@Test public void testSnapshotCommit() { replicatedLogImpl.snapshotPreCommit(1, 1); replicatedLogImpl.snapshotCommit(); assertEquals("size", 2, replicatedLogImpl.size()); assertEquals("dataSize", 2, replicatedLogImpl.dataSize()); assertEquals("getSnapshotIndex", 1, replicatedLogImpl.getSnapshotIndex()); assertEquals("getSnapshotTerm", 1, replicatedLogImpl.getSnapshotTerm()); assertEquals("lastIndex", 3, replicatedLogImpl.lastIndex()); assertEquals("lastTerm", 2, replicatedLogImpl.lastTerm()); Assert.assertNull("get(0)", replicatedLogImpl.get(0)); Assert.assertNull("get(1)", replicatedLogImpl.get(1)); Assert.assertNotNull("get(2)", replicatedLogImpl.get(2)); Assert.assertNotNull("get(3)", replicatedLogImpl.get(3)); }
@Override public void snapshotCommit() { snapshottedJournal = null; previousSnapshotIndex = -1; previousSnapshotTerm = -1; dataSize = 0; for (ReplicatedLogEntry logEntry : journal) { dataSize += logEntry.size(); } }
AbstractReplicatedLogImpl implements ReplicatedLog { @Override public void snapshotCommit() { snapshottedJournal = null; previousSnapshotIndex = -1; previousSnapshotTerm = -1; dataSize = 0; for (ReplicatedLogEntry logEntry : journal) { dataSize += logEntry.size(); } } }
AbstractReplicatedLogImpl implements ReplicatedLog { @Override public void snapshotCommit() { snapshottedJournal = null; previousSnapshotIndex = -1; previousSnapshotTerm = -1; dataSize = 0; for (ReplicatedLogEntry logEntry : journal) { dataSize += logEntry.size(); } } protected  AbstractReplicatedLogImpl(long snapshotIndex, long snapshotTerm,
            List<ReplicatedLogEntry> unAppliedEntries, String logContext); protected  AbstractReplicatedLogImpl(); }
AbstractReplicatedLogImpl implements ReplicatedLog { @Override public void snapshotCommit() { snapshottedJournal = null; previousSnapshotIndex = -1; previousSnapshotTerm = -1; dataSize = 0; for (ReplicatedLogEntry logEntry : journal) { dataSize += logEntry.size(); } } protected  AbstractReplicatedLogImpl(long snapshotIndex, long snapshotTerm,
            List<ReplicatedLogEntry> unAppliedEntries, String logContext); protected  AbstractReplicatedLogImpl(); @Override ReplicatedLogEntry get(long logEntryIndex); @Override ReplicatedLogEntry last(); @Override long lastIndex(); @Override long lastTerm(); @Override long removeFrom(long logEntryIndex); @Override boolean append(ReplicatedLogEntry replicatedLogEntry); @Override void increaseJournalLogCapacity(int amount); @Override List<ReplicatedLogEntry> getFrom(long logEntryIndex); @Override List<ReplicatedLogEntry> getFrom(long logEntryIndex, int maxEntries, long maxDataSize); @Override long size(); @Override int dataSize(); @Override boolean isPresent(long logEntryIndex); @Override boolean isInSnapshot(long logEntryIndex); @Override long getSnapshotIndex(); @Override long getSnapshotTerm(); @Override void setSnapshotIndex(long snapshotIndex); @Override void setSnapshotTerm(long snapshotTerm); @Override void clear(int startIndex, int endIndex); @Override void snapshotPreCommit(long snapshotCapturedIndex, long snapshotCapturedTerm); @Override void snapshotCommit(); @Override void snapshotRollback(); }
AbstractReplicatedLogImpl implements ReplicatedLog { @Override public void snapshotCommit() { snapshottedJournal = null; previousSnapshotIndex = -1; previousSnapshotTerm = -1; dataSize = 0; for (ReplicatedLogEntry logEntry : journal) { dataSize += logEntry.size(); } } protected  AbstractReplicatedLogImpl(long snapshotIndex, long snapshotTerm,
            List<ReplicatedLogEntry> unAppliedEntries, String logContext); protected  AbstractReplicatedLogImpl(); @Override ReplicatedLogEntry get(long logEntryIndex); @Override ReplicatedLogEntry last(); @Override long lastIndex(); @Override long lastTerm(); @Override long removeFrom(long logEntryIndex); @Override boolean append(ReplicatedLogEntry replicatedLogEntry); @Override void increaseJournalLogCapacity(int amount); @Override List<ReplicatedLogEntry> getFrom(long logEntryIndex); @Override List<ReplicatedLogEntry> getFrom(long logEntryIndex, int maxEntries, long maxDataSize); @Override long size(); @Override int dataSize(); @Override boolean isPresent(long logEntryIndex); @Override boolean isInSnapshot(long logEntryIndex); @Override long getSnapshotIndex(); @Override long getSnapshotTerm(); @Override void setSnapshotIndex(long snapshotIndex); @Override void setSnapshotTerm(long snapshotTerm); @Override void clear(int startIndex, int endIndex); @Override void snapshotPreCommit(long snapshotCapturedIndex, long snapshotCapturedTerm); @Override void snapshotCommit(); @Override void snapshotRollback();  }