Search in sources :

Example 1 with SnapshotSelectionCriteria

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);
}
Also used : SimpleReplicatedLogEntry(org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEntry) SnapshotSelectionCriteria(akka.persistence.SnapshotSelectionCriteria) Test(org.junit.Test)

Example 2 with SnapshotSelectionCriteria

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));
}
Also used : SnapshotSelectionCriteria(akka.persistence.SnapshotSelectionCriteria)

Aggregations

SnapshotSelectionCriteria (akka.persistence.SnapshotSelectionCriteria)2 Test (org.junit.Test)1 SimpleReplicatedLogEntry (org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEntry)1