X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fpersisted%2FShardManagerSnapshot.java;h=0bacbd0dbc03a9873215eeb5e85708bc6bdb6497;hb=55a9b9f42a14c56060f74b38f84d444c0fbfecc4;hp=f6be1b808f648efb915edd6aa5264b55d1831937;hpb=a66b0a0f12639e4cfb43bb92602407f09b849c3f;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardManagerSnapshot.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardManagerSnapshot.java index f6be1b808f..0bacbd0dbc 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardManagerSnapshot.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardManagerSnapshot.java @@ -8,14 +8,19 @@ package org.opendaylight.controller.cluster.datastore.persisted; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.Serializable; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; -import javax.annotation.Nonnull; +import java.util.Map; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.controller.cluster.datastore.config.PrefixShardConfiguration; +import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; /** * Represents the persisted snapshot state for the ShardManager. @@ -42,22 +47,35 @@ public class ShardManagerSnapshot implements Serializable { } @Override - public void writeExternal(ObjectOutput out) throws IOException { + public void writeExternal(final ObjectOutput out) throws IOException { out.writeInt(snapshot.shardList.size()); for (String shard: snapshot.shardList) { out.writeObject(shard); } + + out.writeInt(snapshot.prefixShardConfiguration.size()); + for (Map.Entry prefixShardConfigEntry : snapshot.prefixShardConfiguration.entrySet()) { + out.writeObject(prefixShardConfigEntry.getKey()); + out.writeObject(prefixShardConfigEntry.getValue()); + } } @Override - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { int size = in.readInt(); - List shardList = new ArrayList<>(size); + List localShardList = new ArrayList<>(size); + for (int i = 0; i < size; i++) { + localShardList.add((String) in.readObject()); + } + + size = in.readInt(); + Map localPrefixShardConfiguration = new HashMap<>(size); for (int i = 0; i < size; i++) { - shardList.add((String) in.readObject()); + localPrefixShardConfiguration.put((DOMDataTreeIdentifier) in.readObject(), + (PrefixShardConfiguration) in.readObject()); } - snapshot = new ShardManagerSnapshot(shardList); + snapshot = new ShardManagerSnapshot(localShardList, localPrefixShardConfiguration); } private Object readResolve() { @@ -66,9 +84,12 @@ public class ShardManagerSnapshot implements Serializable { } private final List shardList; + private final Map prefixShardConfiguration; - public ShardManagerSnapshot(@Nonnull final List shardList) { + public ShardManagerSnapshot(final @NonNull List shardList, + final Map prefixShardConfiguration) { this.shardList = ImmutableList.copyOf(shardList); + this.prefixShardConfiguration = ImmutableMap.copyOf(prefixShardConfiguration); } public List getShardList() {