Free disk buffers
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / messages / Payload.java
index 78a249749dfce31d7a8625aced8d957de526ea0b..c75385ab1ea4f83e298d0ac1b6289b7f691a877e 100644 (file)
@@ -17,6 +17,7 @@ import java.io.Serializable;
  * Similarly when state needs to be applied to the derived RaftActor it will be passed an instance of the Payload class.
  */
 public abstract class Payload implements Serializable {
+    @java.io.Serial
     private static final long serialVersionUID = 1L;
 
     /**
@@ -26,10 +27,20 @@ public abstract class Payload implements Serializable {
      */
     public abstract int size();
 
+    /**
+     * Return the estimate of serialized size of this payload when passed through serialization. The estimate needs to
+     * be reasonably accurate and should err on the side of caution and report a slightly-higher size in face of
+     * uncertainty.
+     *
+     * @return An estimate of serialized size.
+     */
+    public abstract int serializedSize();
+
     /**
      * Return the serialization proxy for this object.
      *
      * @return Serialization proxy
      */
+    @java.io.Serial
     protected abstract Object writeReplace();
 }