Bug 7521: Add custom local snapshot store 78/51078/16
authorTom Pantelis <tpanteli@brocade.com>
Thu, 26 Jan 2017 16:49:43 +0000 (11:49 -0500)
committerTom Pantelis <tpanteli@brocade.com>
Tue, 28 Feb 2017 21:01:55 +0000 (16:01 -0500)
commited6ec368fa9aa9b4cd770769e264c19ddc7549ea
treea2619a59d939d9613ef1ae024075c657b034aa79
parent8002139af5e8da4643ae203031184793a60087b3
Bug 7521: Add custom local snapshot store

Akka's LocalSnapshotStore serializes to a byte[] before persisting
to the file so we need to write our LocalSnapshotStore that serializes
directly to the file. I patterned the code after akka's LocalSnapshotStore,
mainly translated from scala.

Akka's LocalSnapshotStore wraps the payload data in a Snapshot class
and uses the SnapshotSerializer which locates the serializer for the payload
class and writes some header data before delegating to the payload
serializer. To handle backwards compatibility for a snapshot previously
serialized with akka's format, java de-serialization will detect and fail
with an invalid stream header, in which case we fall back and try
de-serialization via the SnapshotSerializer.

Akka has a standard test suite in SnapshotStoreSpec for testing custom
snapshot store plugins. I derived a LocalSnapshotStoreSpecTest class
that does the setup and teardown with SnapshotStoreSpec doing the rest.
SnapshotStoreSpec uses ScalaTest stuff so need to be run with scala's
JUnitRunner.

I also added a regular LocalSnapshotStoreTest class to cover a few cases
that SnapshotStoreSpec doesn't.

Change-Id: I1ca11682f37aa39d60d3ce57c874c299627e8ca6
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-clustering-commons/pom.xml
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStoreSpecTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStoreTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/test/resources/LocalSnapshotStoreTest.conf [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/factory-akka.conf