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%2Fpersisted%2FNoopPayload.java;h=0f076c55d755a3286433d388aad2e33faeef1fdb;hb=HEAD;hp=782bb72175a973b0183b63bb9d9d6d2b79b5aac7;hpb=9d5ec5cdd146a56bc03e35b6718e9492a5c8410a;p=controller.git diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/NoopPayload.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/NoopPayload.java index 782bb72175..0f076c55d7 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/NoopPayload.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/NoopPayload.java @@ -7,8 +7,10 @@ */ package org.opendaylight.controller.cluster.raft.persisted; -import java.io.Serializable; -import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; +import akka.dispatch.ControlMessage; +import org.apache.commons.lang3.SerializationUtils; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.controller.cluster.raft.messages.Payload; /** * Payload used for no-op log entries that are put into the journal by the PreLeader in order to commit @@ -16,23 +18,17 @@ import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payloa * * @author Thomas Pantelis */ -public final class NoopPayload extends Payload implements Serializable { - public static final NoopPayload INSTANCE = new NoopPayload(); - - // There is no need for Externalizable - private static final class Proxy implements Serializable { - private static final long serialVersionUID = 1L; - - @SuppressWarnings("static-method") - 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 Proxy PROXY = new Proxy(); + 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(); private NoopPayload() { + // Hidden on purpose } @Override @@ -40,8 +36,13 @@ public final class NoopPayload extends Payload implements Serializable { return 0; } - @SuppressWarnings("static-method") - private Object writeReplace() { + @Override + public int serializedSize() { + return PROXY_SIZE; + } + + @Override + protected Object writeReplace() { return PROXY; } }