Search in sources :

Example 1 with SnapshotIndexSerde

use of org.apache.samza.storage.blobstore.index.serde.SnapshotIndexSerde in project samza by apache.

the class TestSnapshotIndexSerde method testSnapshotIndexSerde.

@Test
public void testSnapshotIndexSerde() throws IOException {
    // create local and remote snapshots
    String local = "[a, b, c/1, d/1/2]";
    String remote = "[a, b, z, c/1/2, e/1]";
    Path localSnapshot = BlobStoreTestUtil.createLocalDir(local);
    DirIndex dirIndex = BlobStoreTestUtil.createDirIndex(remote);
    SnapshotMetadata snapshotMetadata = new SnapshotMetadata(CheckpointId.create(), "job", "123", "task", "store");
    SnapshotIndex testRemoteSnapshot = new SnapshotIndex(System.currentTimeMillis(), snapshotMetadata, dirIndex, Optional.empty());
    SnapshotIndexSerde snapshotIndexSerde = new SnapshotIndexSerde();
    byte[] serialized = snapshotIndexSerde.toBytes(testRemoteSnapshot);
    SnapshotIndex deserialized = snapshotIndexSerde.fromBytes(serialized);
    Assert.assertNotNull(deserialized);
    Assert.assertEquals(deserialized, testRemoteSnapshot);
}
Also used : Path(java.nio.file.Path) SnapshotIndex(org.apache.samza.storage.blobstore.index.SnapshotIndex) SnapshotMetadata(org.apache.samza.storage.blobstore.index.SnapshotMetadata) SnapshotIndexSerde(org.apache.samza.storage.blobstore.index.serde.SnapshotIndexSerde) DirIndex(org.apache.samza.storage.blobstore.index.DirIndex) Test(org.junit.Test)

Aggregations

Path (java.nio.file.Path)1 DirIndex (org.apache.samza.storage.blobstore.index.DirIndex)1 SnapshotIndex (org.apache.samza.storage.blobstore.index.SnapshotIndex)1 SnapshotMetadata (org.apache.samza.storage.blobstore.index.SnapshotMetadata)1 SnapshotIndexSerde (org.apache.samza.storage.blobstore.index.serde.SnapshotIndexSerde)1 Test (org.junit.Test)1