package org.opendaylight.controller.cluster.raft.persisted;
import akka.dispatch.ControlMessage;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
import java.io.Serializable;
/**
*
* @author Thomas Pantelis
*/
-public sealed class ApplyJournalEntries implements Serializable, ControlMessage {
- @Deprecated(since = "7.0.0", forRemoval = true)
- private static final class Legacy extends ApplyJournalEntries implements LegacySerializable {
- @java.io.Serial
- private static final long serialVersionUID = 1L;
-
- Legacy(final long toIndex) {
- super(toIndex);
- }
- }
-
- @Deprecated(since = "7.0.0", forRemoval = true)
- private static final class Proxy implements Externalizable {
- @java.io.Serial
- private static final long serialVersionUID = 1L;
-
- private ApplyJournalEntries applyEntries = 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(applyEntries.toIndex);
- }
-
- @Override
- public void readExternal(final ObjectInput in) throws IOException {
- applyEntries = new Legacy(in.readLong());
- }
-
- @java.io.Serial
- private Object readResolve() {
- return applyEntries;
- }
- }
-
+public final class ApplyJournalEntries implements Serializable, ControlMessage {
@java.io.Serial
private static final long serialVersionUID = 1L;
this.toIndex = toIndex;
}
- public final long getToIndex() {
+ public long getToIndex() {
return toIndex;
}
- @java.io.Serial
- public final Object writeReplace() {
- return new AJE(this);
- }
-
@Override
- public final String toString() {
+ public String toString() {
return "ApplyJournalEntries [toIndex=" + toIndex + "]";
}
+
+ @java.io.Serial
+ private Object writeReplace() {
+ return new AJE(this);
+ }
}
*/
package org.opendaylight.controller.cluster.raft.persisted;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
import java.io.Serializable;
/**
*
* @author Thomas Pantelis
*/
-public sealed class DeleteEntries implements Serializable {
- @Deprecated(since = "7.0.0", forRemoval = true)
- private static final class Legacy extends DeleteEntries implements LegacySerializable {
- @java.io.Serial
- private static final long serialVersionUID = 1L;
-
- Legacy(final long fromIndex) {
- super(fromIndex);
- }
- }
-
- @Deprecated(since = "7.0.0", forRemoval = true)
- private static final class Proxy implements Externalizable {
- @java.io.Serial
- private static final long serialVersionUID = 1L;
-
- private DeleteEntries deleteEntries = 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(deleteEntries.fromIndex);
- }
-
- @Override
- public void readExternal(final ObjectInput in) throws IOException {
- deleteEntries = new Legacy(in.readLong());
- }
-
- @java.io.Serial
- private Object readResolve() {
- return deleteEntries;
- }
- }
-
+public final class DeleteEntries implements Serializable {
@java.io.Serial
private static final long serialVersionUID = 1L;
this.fromIndex = fromIndex;
}
- public final long getFromIndex() {
+ public long getFromIndex() {
return fromIndex;
}
- @java.io.Serial
- public final Object writeReplace() {
- return new DE(this);
- }
-
@Override
- public final String toString() {
+ public String toString() {
return "DeleteEntries [fromIndex=" + fromIndex + "]";
}
+
+ @java.io.Serial
+ private Object writeReplace() {
+ return new DE(this);
+ }
}
package org.opendaylight.controller.cluster.raft.persisted;
import akka.dispatch.ControlMessage;
-import java.io.Serializable;
import org.apache.commons.lang3.SerializationUtils;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.controller.cluster.raft.messages.Payload;
*
* @author Thomas Pantelis
*/
-// FIXME: do not implement MigratedSerializable once Proxy is gone
-public final class NoopPayload extends Payload implements ControlMessage, MigratedSerializable {
- // There is no need for Externalizable
- @Deprecated(since = "7.0.0", forRemoval = true)
- private static final class Proxy implements Serializable {
- @java.io.Serial
- private static final long serialVersionUID = 1L;
- private static final @NonNull NoopPayload INSTANCE = new NoopPayload(true);
-
- @java.io.Serial
- private Object readResolve() {
- return INSTANCE;
- }
- }
-
+public final class NoopPayload extends Payload implements ControlMessage {
@java.io.Serial
private static final long serialVersionUID = 1L;
private static final @NonNull NP PROXY = new NP();
// Estimate to how big the proxy is. Note this includes object stream overhead, so it is a bit conservative
private static final int PROXY_SIZE = SerializationUtils.serialize(PROXY).length;
- public static final @NonNull NoopPayload INSTANCE = new NoopPayload(false);
-
- private final boolean migrated;
+ public static final @NonNull NoopPayload INSTANCE = new NoopPayload();
- private NoopPayload(final boolean migrated) {
- this.migrated = migrated;
+ private NoopPayload() {
+ // Hidden on purpose
}
@Override
}
@Override
- public boolean isMigrated() {
- return migrated;
- }
-
- // FIXME: protected once not MigratedSerializable
- @Override
- public Object writeReplace() {
+ protected Object writeReplace() {
return PROXY;
}
}
import static java.util.Objects.requireNonNull;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
import java.io.Serializable;
import org.apache.commons.lang3.SerializationUtils;
import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
*
* @author Thomas Pantelis
*/
-public sealed class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Serializable {
- @Deprecated(since = "7.0.0", forRemoval = true)
- private static final class Legacy extends SimpleReplicatedLogEntry implements LegacySerializable {
- @java.io.Serial
- private static final long serialVersionUID = 1L;
-
- Legacy(final long index, final long term, final Payload payload) {
- super(index, term, payload);
- }
- }
-
- @Deprecated(since = "7.0.0", forRemoval = true)
- private static final class Proxy implements Externalizable {
- @java.io.Serial
- private static final long serialVersionUID = 1L;
-
- private long index;
- private long term;
- private Payload data;
-
- // 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(index);
- out.writeLong(term);
- out.writeObject(data);
- }
-
- @Override
- public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
- index = in.readLong();
- term = in.readLong();
- data = (Payload) in.readObject();
- }
-
- @java.io.Serial
- private Object readResolve() {
- return new Legacy(index, term, data);
- }
- }
-
+public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Serializable {
@java.io.Serial
private static final long serialVersionUID = 1L;
// Estimate to how big the proxy is. Note this includes object stream overhead, so it is a bit conservative.
}
@Override
- public final Payload getData() {
+ public Payload getData() {
return payload;
}
@Override
- public final long getTerm() {
+ public long getTerm() {
return term;
}
@Override
- public final long getIndex() {
+ public long getIndex() {
return index;
}
@Override
- public final int size() {
+ public int size() {
return payload.size();
}
@Override
- public final int serializedSize() {
+ public int serializedSize() {
return PROXY_SIZE + payload.serializedSize();
}
@Override
- public final boolean isPersistencePending() {
+ public boolean isPersistencePending() {
return persistencePending;
}
@Override
- public final void setPersistencePending(final boolean pending) {
+ public void setPersistencePending(final boolean pending) {
persistencePending = pending;
}
- @java.io.Serial
- public final Object writeReplace() {
- return new LE(this);
- }
-
@Override
- public final int hashCode() {
+ public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + payload.hashCode();
}
@Override
- public final boolean equals(final Object obj) {
+ public boolean equals(final Object obj) {
return this == obj || obj instanceof SimpleReplicatedLogEntry other && index == other.index
&& term == other.term && payload.equals(other.payload);
}
@Override
- public final String toString() {
+ public String toString() {
return "SimpleReplicatedLogEntry [index=" + index + ", term=" + term + ", payload=" + payload + "]";
}
+
+ @java.io.Serial
+ private Object writeReplace() {
+ return new LE(this);
+ }
}
*/
package org.opendaylight.controller.cluster.raft.persisted;
-import com.google.common.collect.ImmutableList;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
import java.io.Serializable;
import java.util.List;
import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
-import org.opendaylight.controller.cluster.raft.messages.Payload;
/**
* Represents a snapshot of the raft data.
*
* @author Thomas Pantelis
*/
-public sealed class Snapshot implements Serializable {
+public final class Snapshot implements Serializable {
/**
* Implementations of this interface are used as the state payload for a snapshot.
*
}
}
- @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;
- }
- }
-
@java.io.Serial
private static final long serialVersionUID = 1L;
private final String electionVotedFor;
private final ServerConfigurationPayload serverConfig;
- Snapshot(final State state, final List<ReplicatedLogEntry> unAppliedEntries, final long lastIndex,
+ private Snapshot(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) {
this.state = state;
return serverConfig;
}
- @java.io.Serial
- public final Object writeReplace() {
- return new SS(this);
- }
-
@Override
- public final String toString() {
+ public String toString() {
return "Snapshot [lastIndex=" + lastIndex + ", lastTerm=" + lastTerm + ", lastAppliedIndex=" + lastAppliedIndex
+ ", lastAppliedTerm=" + lastAppliedTerm + ", unAppliedEntries size=" + unAppliedEntries.size()
+ ", state=" + state + ", electionTerm=" + electionTerm + ", electionVotedFor="
+ electionVotedFor + ", ServerConfigPayload=" + serverConfig + "]";
}
+
+ @java.io.Serial
+ private Object writeReplace() {
+ return new SS(this);
+ }
}
*/
package org.opendaylight.controller.cluster.raft.persisted;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
import java.io.Serializable;
/**
* Message class to persist election term information.
*/
-public sealed class UpdateElectionTerm implements Serializable {
- @Deprecated(since = "7.0.0", forRemoval = true)
- private static final class Legacy extends UpdateElectionTerm implements LegacySerializable {
- @java.io.Serial
- private static final long serialVersionUID = 1L;
-
- Legacy(final long currentTerm, final String votedFor) {
- super(currentTerm, votedFor);
- }
- }
-
- @Deprecated(since = "7.0.0", forRemoval = true)
- private static final class Proxy implements Externalizable {
- @java.io.Serial
- private static final long serialVersionUID = 1L;
-
- private UpdateElectionTerm updateElectionTerm = 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(updateElectionTerm.currentTerm);
- out.writeObject(updateElectionTerm.votedFor);
- }
-
- @Override
- public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
- updateElectionTerm = new Legacy(in.readLong(), (String) in.readObject());
- }
-
- @java.io.Serial
- private Object readResolve() {
- return updateElectionTerm;
- }
- }
-
+public final class UpdateElectionTerm implements Serializable {
@java.io.Serial
private static final long serialVersionUID = 1L;
this.votedFor = votedFor;
}
- public final long getCurrentTerm() {
+ public long getCurrentTerm() {
return currentTerm;
}
- public final String getVotedFor() {
+ public String getVotedFor() {
return votedFor;
}
- @java.io.Serial
- public final Object writeReplace() {
- return new UT(this);
- }
-
@Override
- public final String toString() {
+ public String toString() {
return "UpdateElectionTerm [currentTerm=" + currentTerm + ", votedFor=" + votedFor + "]";
}
+
+ @java.io.Serial
+ private Object writeReplace() {
+ return new UT(this);
+ }
}