atomic-storage: remove type dependency at segment level I/O
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / persisted / NoopPayload.java
1 /*
2  * Copyright (c) 2016 Brocade Communications Systems, Inc. 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.persisted;
9
10 import akka.dispatch.ControlMessage;
11 import org.apache.commons.lang3.SerializationUtils;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.controller.cluster.raft.messages.Payload;
14
15 /**
16  * Payload used for no-op log entries that are put into the journal by the PreLeader in order to commit
17  * entries from the prior term.
18  *
19  * @author Thomas Pantelis
20  */
21 public final class NoopPayload extends Payload implements ControlMessage {
22     @java.io.Serial
23     private static final long serialVersionUID = 1L;
24     private static final @NonNull NP PROXY = new NP();
25     // Estimate to how big the proxy is. Note this includes object stream overhead, so it is a bit conservative
26     private static final int PROXY_SIZE = SerializationUtils.serialize(PROXY).length;
27
28     public static final @NonNull NoopPayload INSTANCE = new NoopPayload();
29
30     private NoopPayload() {
31         // Hidden on purpose
32     }
33
34     @Override
35     public int size() {
36         return 0;
37     }
38
39     @Override
40     public int serializedSize() {
41         return PROXY_SIZE;
42     }
43
44     @Override
45     protected Object writeReplace() {
46         return PROXY;
47     }
48 }