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%2Fmessages%2FDatastoreSnapshotList.java;fp=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fmessages%2FDatastoreSnapshotList.java;h=42f3129728aae62f9a34527c1888c10a21501de2;hp=8400e0c3e236fb2eaf6f8be67932c48b01e1064e;hb=95c296a7c1e8e186a88a0a0dc82e080b2185db33;hpb=aafb8cb044e992dd784d1f4f66508599cc4cd588 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshotList.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshotList.java index 8400e0c3e2..42f3129728 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshotList.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshotList.java @@ -13,6 +13,7 @@ import java.io.ObjectInputStream; import java.util.ArrayList; import java.util.List; import org.opendaylight.controller.cluster.datastore.persisted.ShardDataTreeSnapshot; +import org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot; import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState; import org.opendaylight.controller.cluster.raft.Snapshot; import org.opendaylight.controller.cluster.raft.persisted.EmptyState; @@ -38,25 +39,37 @@ public class DatastoreSnapshotList extends ArrayList { new ArrayList<>(size()); for (DatastoreSnapshot legacy: this) { snapshots.add(new org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot( - legacy.getType(), legacy.getShardManagerSnapshot(), fromLegacy(legacy.getShardSnapshots()))); + legacy.getType(), deserializeShardManagerSnapshot(legacy.getShardManagerSnapshot()), + fromLegacy(legacy.getShardSnapshots()))); } return new org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshotList(snapshots); } + private static org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot + deserializeShardManagerSnapshot(byte [] bytes) throws IOException, ClassNotFoundException { + if (bytes == null) { + return null; + } + + try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes))) { + return (ShardManagerSnapshot) ois.readObject(); + } + } + private static List fromLegacy(List from) throws IOException, ClassNotFoundException { List snapshots = new ArrayList<>(from.size()); for (DatastoreSnapshot.ShardSnapshot legacy: from) { snapshots.add(new org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot( - legacy.getName(), deserialize(legacy.getSnapshot()))); + legacy.getName(), deserializeShardSnapshot(legacy.getSnapshot()))); } return snapshots; } - private static org.opendaylight.controller.cluster.raft.persisted.Snapshot deserialize(byte[] bytes) + private static org.opendaylight.controller.cluster.raft.persisted.Snapshot deserializeShardSnapshot(byte[] bytes) throws IOException, ClassNotFoundException { try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes))) { Snapshot legacy = (Snapshot) ois.readObject();