use of akka.persistence.SnapshotProtocol.LoadSnapshotResult in project controller by opendaylight.
the class LocalSnapshotStoreTest method testDoLoadAsync.
@Test
public void testDoLoadAsync() throws IOException {
createSnapshotFile(PERSISTENCE_ID, "one", 0, 1000);
createSnapshotFile(PERSISTENCE_ID, "two", 1, 2000);
createSnapshotFile(PERSISTENCE_ID, "three", 1, 3000);
createSnapshotFile(PREFIX_BASED_SHARD_PERSISTENCE_ID, "foo", 0, 1000);
createSnapshotFile(PREFIX_BASED_SHARD_PERSISTENCE_ID, "bar", 1, 2000);
createSnapshotFile(PREFIX_BASED_SHARD_PERSISTENCE_ID, "foobar", 1, 3000);
createSnapshotFile("member-1-shard-default-oper", "foo", 0, 1000);
createSnapshotFile("member-1-shard-toaster-oper", "foo", 0, 1000);
new File(SNAPSHOT_DIR, "other").createNewFile();
new File(SNAPSHOT_DIR, "other-1485349217290").createNewFile();
SnapshotMetadata metadata3 = new SnapshotMetadata(PERSISTENCE_ID, 1, 3000);
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", metadata3, possibleSnapshot.get().metadata());
assertEquals("SelectedSnapshot snapshot", "three", possibleSnapshot.get().snapshot());
snapshotStore.tell(new LoadSnapshot(PREFIX_BASED_SHARD_PERSISTENCE_ID, SnapshotSelectionCriteria.latest(), Long.MAX_VALUE), probe.getRef());
result = probe.expectMsgClass(LoadSnapshotResult.class);
possibleSnapshot = result.snapshot();
SnapshotMetadata prefixBasedShardMetada3 = new SnapshotMetadata(PREFIX_BASED_SHARD_PERSISTENCE_ID, 1, 3000);
assertEquals("SelectedSnapshot present", TRUE, possibleSnapshot.nonEmpty());
assertEquals("SelectedSnapshot metadata", prefixBasedShardMetada3, possibleSnapshot.get().metadata());
assertEquals("SelectedSnapshot snapshot", "foobar", possibleSnapshot.get().snapshot());
}
use of akka.persistence.SnapshotProtocol.LoadSnapshotResult in project controller by opendaylight.
the class LocalSnapshotStoreTest method testDoLoadAsyncWithRetry.
@Test
public void testDoLoadAsyncWithRetry() throws IOException {
createSnapshotFile(PERSISTENCE_ID, "one", 0, 1000);
createSnapshotFile(PERSISTENCE_ID, null, 1, 2000);
SnapshotMetadata metadata = new SnapshotMetadata(PERSISTENCE_ID, 0, 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());
}
use of akka.persistence.SnapshotProtocol.LoadSnapshotResult 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());
}
use of akka.persistence.SnapshotProtocol.LoadSnapshotResult 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());
}
Aggregations