Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / messages / Payload.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.raft.messages;
9
10 import java.io.Serializable;
11
12 /**
13  * An instance of a {@link Payload} class is meant to be used as the Payload for {@link AppendEntries}.
14  *
15  * <p>
16  * When an actor which is derived from RaftActor attempts to persistData it must pass an instance of the Payload class.
17  * Similarly when state needs to be applied to the derived RaftActor it will be passed an instance of the Payload class.
18  */
19 public abstract class Payload implements Serializable {
20     @java.io.Serial
21     private static final long serialVersionUID = 1L;
22
23     /**
24      * Return the estimate of in-memory size of this payload.
25      *
26      * @return An estimate of the in-memory size of this payload.
27      */
28     public abstract int size();
29
30     /**
31      * Return the estimate of serialized size of this payload when passed through serialization. The estimate needs to
32      * be reasonably accurate and should err on the side of caution and report a slightly-higher size in face of
33      * uncertainty.
34      *
35      * @return An estimate of serialized size.
36      */
37     public abstract int serializedSize();
38
39     /**
40      * Return the serialization proxy for this object.
41      *
42      * @return Serialization proxy
43      */
44     @java.io.Serial
45     protected abstract Object writeReplace();
46 }