- @Deprecated(since = "7.0.0", forRemoval = true)
- private static final class Legacy extends Snapshot implements LegacySerializable {
- @java.io.Serial
- private static final long serialVersionUID = 1L;
-
- Legacy(final State state, final List<ReplicatedLogEntry> unAppliedEntries, final long lastIndex,
- final long lastTerm, final long lastAppliedIndex, final long lastAppliedTerm, final long electionTerm,
- final String electionVotedFor, final ServerConfigurationPayload serverConfig) {
- super(state, unAppliedEntries, lastIndex, lastTerm, lastAppliedIndex, lastAppliedTerm, electionTerm,
- electionVotedFor, serverConfig);
- }
- }
-
- @Deprecated(since = "7.0.0", forRemoval = true)
- private static final class Proxy implements Externalizable {
- @java.io.Serial
- private static final long serialVersionUID = 1L;
-
- private Snapshot snapshot = null;
-
- // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
- // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
- @SuppressWarnings("checkstyle:RedundantModifier")
- public Proxy() {
- // For Externalizable
- }
-
- @Override
- public void writeExternal(final ObjectOutput out) throws IOException {
- out.writeLong(snapshot.lastIndex);
- out.writeLong(snapshot.lastTerm);
- out.writeLong(snapshot.lastAppliedIndex);
- out.writeLong(snapshot.lastAppliedTerm);
- out.writeLong(snapshot.electionTerm);
- out.writeObject(snapshot.electionVotedFor);
- out.writeObject(snapshot.serverConfig);
-
- out.writeInt(snapshot.unAppliedEntries.size());
- for (ReplicatedLogEntry e: snapshot.unAppliedEntries) {
- out.writeLong(e.getIndex());
- out.writeLong(e.getTerm());
- out.writeObject(e.getData());
- }
-
- out.writeObject(snapshot.state);
- }
-
- @Override
- public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
- long lastIndex = in.readLong();
- long lastTerm = in.readLong();
- long lastAppliedIndex = in.readLong();
- long lastAppliedTerm = in.readLong();
- long electionTerm = in.readLong();
- String electionVotedFor = (String) in.readObject();
- ServerConfigurationPayload serverConfig = (ServerConfigurationPayload) in.readObject();
-
- int size = in.readInt();
- var unAppliedEntries = ImmutableList.<ReplicatedLogEntry>builderWithExpectedSize(size);
- for (int i = 0; i < size; i++) {
- unAppliedEntries.add(new SimpleReplicatedLogEntry(in.readLong(), in.readLong(),
- (Payload) in.readObject()));
- }
-
- State state = (State) in.readObject();
-
- snapshot = new Legacy(state, unAppliedEntries.build(), lastIndex, lastTerm, lastAppliedIndex,
- lastAppliedTerm, electionTerm, electionVotedFor, serverConfig);
- }
-
- @java.io.Serial
- private Object readResolve() {
- return snapshot;
- }
- }
-