X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fpersisted%2FAbstractVersionedShardDataTreeSnapshot.java;h=21d018df12da01b24cd2191491c139318b0cec6d;hp=6d1c8caf69b55989cf8bbf0c78089c396cfe0363;hb=refs%2Fchanges%2F14%2F82314%2F25;hpb=9d6b18257717db4f6f722422ee3224154150cbf7 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractVersionedShardDataTreeSnapshot.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractVersionedShardDataTreeSnapshot.java index 6d1c8caf69..21d018df12 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractVersionedShardDataTreeSnapshot.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractVersionedShardDataTreeSnapshot.java @@ -27,27 +27,30 @@ abstract class AbstractVersionedShardDataTreeSnapshot extends ShardDataTreeSnaps private static final Logger LOG = LoggerFactory.getLogger(AbstractVersionedShardDataTreeSnapshot.class); @SuppressWarnings("checkstyle:FallThrough") - static ShardDataTreeSnapshot versionedDeserialize(final ObjectInput in) throws IOException { + static @NonNull ShardSnapshotState versionedDeserialize(final ObjectInput in) throws IOException { final PayloadVersion version = PayloadVersion.readFrom(in); switch (version) { case BORON: - // Boron snapshots use Java Serialization - try { - return (ShardDataTreeSnapshot) in.readObject(); - } catch (ClassNotFoundException e) { - LOG.error("Failed to serialize data tree snapshot", e); - throw new IOException("Snapshot failed to deserialize", e); - } + return new ShardSnapshotState(readSnapshot(in), true); + case SODIUM: + return new ShardSnapshotState(readSnapshot(in), false); case TEST_FUTURE_VERSION: case TEST_PAST_VERSION: // These versions are never returned and this code is effectively dead - break; default: - throw new IOException("Invalid payload version in snapshot"); + // Not included as default in above switch to ensure we get warnings when new versions are added + throw new IOException("Encountered unhandled version" + version); } + } - // Not included as default in above switch to ensure we get warnings when new versions are added - throw new IOException("Encountered unhandled version" + version); + // Boron and Sodium snapshots use Java Serialization, but differ in stream format + private static @NonNull ShardDataTreeSnapshot readSnapshot(final ObjectInput in) throws IOException { + try { + return (ShardDataTreeSnapshot) in.readObject(); + } catch (ClassNotFoundException e) { + LOG.error("Failed to serialize data tree snapshot", e); + throw new IOException("Snapshot failed to deserialize", e); + } } @Override @@ -72,7 +75,8 @@ abstract class AbstractVersionedShardDataTreeSnapshot extends ShardDataTreeSnaps private void versionedSerialize(final ObjectOutput out, final PayloadVersion version) throws IOException { switch (version) { case BORON: - // Boron snapshots use Java Serialization + case SODIUM: + // Boron and Sodium snapshots use Java Serialization, but differ in stream format out.writeObject(this); return; case TEST_FUTURE_VERSION: