Search in sources :

Example 6 with SelectedSnapshot

use of akka.persistence.SelectedSnapshot in project controller by opendaylight.

the class LocalSnapshotStoreTest method testDoLoadAsyncWithAkkaSerializedSnapshot.

@Test
public void testDoLoadAsyncWithAkkaSerializedSnapshot() throws IOException {
    SnapshotSerializer snapshotSerializer = new SnapshotSerializer((ExtendedActorSystem) system);
    String name = toSnapshotName(PERSISTENCE_ID, 1, 1000);
    try (FileOutputStream fos = new FileOutputStream(new File(SNAPSHOT_DIR, name))) {
        fos.write(snapshotSerializer.toBinary(new Snapshot("one")));
    }
    SnapshotMetadata metadata = new SnapshotMetadata(PERSISTENCE_ID, 1, 1000);
    TestKit probe = new TestKit(system);
    snapshotStore.tell(new LoadSnapshot(PERSISTENCE_ID, SnapshotSelectionCriteria.latest(), Long.MAX_VALUE), probe.getRef());
    LoadSnapshotResult result = probe.expectMsgClass(LoadSnapshotResult.class);
    Option<SelectedSnapshot> possibleSnapshot = result.snapshot();
    assertEquals("SelectedSnapshot present", TRUE, possibleSnapshot.nonEmpty());
    assertEquals("SelectedSnapshot metadata", metadata, possibleSnapshot.get().metadata());
    assertEquals("SelectedSnapshot snapshot", "one", possibleSnapshot.get().snapshot());
}
Also used : Snapshot(akka.persistence.serialization.Snapshot) LoadSnapshot(akka.persistence.SnapshotProtocol.LoadSnapshot) SelectedSnapshot(akka.persistence.SelectedSnapshot) LoadSnapshot(akka.persistence.SnapshotProtocol.LoadSnapshot) LoadSnapshotResult(akka.persistence.SnapshotProtocol.LoadSnapshotResult) SelectedSnapshot(akka.persistence.SelectedSnapshot) SnapshotMetadata(akka.persistence.SnapshotMetadata) FileOutputStream(java.io.FileOutputStream) SnapshotSerializer(akka.persistence.serialization.SnapshotSerializer) TestKit(akka.testkit.javadsl.TestKit) File(java.io.File) Test(org.junit.Test)

Example 7 with SelectedSnapshot

use of akka.persistence.SelectedSnapshot in project controller by opendaylight.

the class LocalSnapshotStoreTest method testDoLoadAsyncWithNoSnapshots.

@Test
public void testDoLoadAsyncWithNoSnapshots() throws IOException {
    TestKit probe = new TestKit(system);
    snapshotStore.tell(new LoadSnapshot(PERSISTENCE_ID, SnapshotSelectionCriteria.latest(), Long.MAX_VALUE), probe.getRef());
    LoadSnapshotResult result = probe.expectMsgClass(LoadSnapshotResult.class);
    Option<SelectedSnapshot> possibleSnapshot = result.snapshot();
    assertEquals("SelectedSnapshot present", FALSE, possibleSnapshot.nonEmpty());
}
Also used : LoadSnapshot(akka.persistence.SnapshotProtocol.LoadSnapshot) LoadSnapshotResult(akka.persistence.SnapshotProtocol.LoadSnapshotResult) SelectedSnapshot(akka.persistence.SelectedSnapshot) TestKit(akka.testkit.javadsl.TestKit) Test(org.junit.Test)

Aggregations

SelectedSnapshot (akka.persistence.SelectedSnapshot)7 Test (org.junit.Test)6 SnapshotMetadata (akka.persistence.SnapshotMetadata)5 LoadSnapshot (akka.persistence.SnapshotProtocol.LoadSnapshot)4 LoadSnapshotResult (akka.persistence.SnapshotProtocol.LoadSnapshotResult)4 TestKit (akka.testkit.javadsl.TestKit)4 File (java.io.File)3 Snapshot (akka.persistence.serialization.Snapshot)1 SnapshotSerializer (akka.persistence.serialization.SnapshotSerializer)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 ClientIdentifier (org.opendaylight.controller.cluster.access.concepts.ClientIdentifier)1 FrontendIdentifier (org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier)1