X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2FSnapshot.java;h=93226ccab201aab0ed98214ae7e64251a98f0540;hb=200164de7246237ee45f761c4db15b8b51f6a93c;hp=a369c25ddf41bad10e788669b225e233dbff47ec;hpb=7873bfcd1735ce86a58c015b2865c7f3627fb121;p=controller.git diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/Snapshot.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/Snapshot.java index a369c25ddf..93226ccab2 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/Snapshot.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/Snapshot.java @@ -7,10 +7,20 @@ */ package org.opendaylight.controller.cluster.raft; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.Serializable; import java.util.List; +import org.opendaylight.controller.cluster.raft.persisted.ServerConfigurationPayload; - +/** + * Represents a snapshot of the raft data. + * + * @author Moiz Raja + * @author Thomas Pantelis + * + * @deprecated Use {@link org.opendaylight.controller.cluster.raft.persisted.Snapshot} instead. + */ +@Deprecated public class Snapshot implements Serializable { private static final long serialVersionUID = -8298574936724056236L; @@ -22,9 +32,11 @@ public class Snapshot implements Serializable { private final long lastAppliedTerm; private final long electionTerm; private final String electionVotedFor; + private final ServerConfigurationPayload serverConfig; private Snapshot(byte[] state, List unAppliedEntries, long lastIndex, long lastTerm, - long lastAppliedIndex, long lastAppliedTerm, long electionTerm, String electionVotedFor) { + long lastAppliedIndex, long lastAppliedTerm, long electionTerm, String electionVotedFor, + ServerConfigurationPayload serverConfig) { this.state = state; this.unAppliedEntries = unAppliedEntries; this.lastIndex = lastIndex; @@ -33,19 +45,30 @@ public class Snapshot implements Serializable { this.lastAppliedTerm = lastAppliedTerm; this.electionTerm = electionTerm; this.electionVotedFor = electionVotedFor; + this.serverConfig = serverConfig; } public static Snapshot create(byte[] state, List entries, long lastIndex, long lastTerm, long lastAppliedIndex, long lastAppliedTerm) { - return new Snapshot(state, entries, lastIndex, lastTerm, lastAppliedIndex, lastAppliedTerm, -1, null); + return new Snapshot(state, entries, lastIndex, lastTerm, lastAppliedIndex, lastAppliedTerm, -1, null, null); } public static Snapshot create(byte[] state, List entries, long lastIndex, long lastTerm, long lastAppliedIndex, long lastAppliedTerm, long electionTerm, String electionVotedFor) { return new Snapshot(state, entries, lastIndex, lastTerm, lastAppliedIndex, lastAppliedTerm, - electionTerm, electionVotedFor); + electionTerm, electionVotedFor, null); } + public static Snapshot create(byte[] state, List entries, long lastIndex, long lastTerm, + long lastAppliedIndex, long lastAppliedTerm, long electionTerm, String electionVotedFor, + ServerConfigurationPayload serverConfig) { + return new Snapshot(state, entries, lastIndex, lastTerm, lastAppliedIndex, lastAppliedTerm, + electionTerm, electionVotedFor, serverConfig); + } + + @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Exposes a mutable object stored in a field but " + + "this is OK since this class is merely a DTO and does not process the byte[] internally. " + + "Also it would be inefficient to create a return copy as the byte[] could be large.") public byte[] getState() { return state; } @@ -79,11 +102,15 @@ public class Snapshot implements Serializable { return electionVotedFor; } + public ServerConfigurationPayload getServerConfiguration() { + return serverConfig; + } + @Override public String toString() { return "Snapshot [lastIndex=" + lastIndex + ", lastTerm=" + lastTerm + ", lastAppliedIndex=" + lastAppliedIndex + ", lastAppliedTerm=" + lastAppliedTerm + ", unAppliedEntries size=" + unAppliedEntries.size() - + ", state size=" + state.length + ", electionTerm=" + electionTerm + ", electionVotedFor=" + electionVotedFor - + "]"; + + ", state size=" + state.length + ", electionTerm=" + electionTerm + ", electionVotedFor=" + + electionVotedFor + ", ServerConfigPayload=" + serverConfig + "]"; } }