use of akka.persistence.SnapshotSelectionCriteria in project controller by opendaylight.
the class SnapshotManagerTest method testCommit.
@Test
public void testCommit() {
doReturn(50L).when(mockDataPersistenceProvider).getLastSequenceNumber();
// when replicatedToAllIndex = -1
snapshotManager.capture(new SimpleReplicatedLogEntry(9, 6, new MockRaftActorContext.MockPayload()), -1);
snapshotManager.persist(ByteState.empty(), Optional.empty(), Runtime.getRuntime().totalMemory());
assertEquals(true, snapshotManager.isCapturing());
snapshotManager.commit(100L, 1234L);
assertEquals(false, snapshotManager.isCapturing());
verify(mockReplicatedLog).snapshotCommit();
verify(mockDataPersistenceProvider).deleteMessages(50L);
ArgumentCaptor<SnapshotSelectionCriteria> criteriaCaptor = ArgumentCaptor.forClass(SnapshotSelectionCriteria.class);
verify(mockDataPersistenceProvider).deleteSnapshots(criteriaCaptor.capture());
assertEquals(100L, criteriaCaptor.getValue().maxSequenceNr());
assertEquals(1233L, criteriaCaptor.getValue().maxTimestamp());
MessageCollectorActor.expectFirstMatching(actorRef, SnapshotComplete.class);
}
use of akka.persistence.SnapshotSelectionCriteria in project controller by opendaylight.
the class ShardManager method onSaveSnapshotSuccess.
private void onSaveSnapshotSuccess(final SaveSnapshotSuccess successMessage) {
LOG.debug("{} saved ShardManager snapshot successfully. Deleting the prev snapshot if available", persistenceId());
deleteSnapshots(new SnapshotSelectionCriteria(scala.Long.MaxValue(), successMessage.metadata().timestamp() - 1, 0, 0));
}
Aggregations