Remove deprecated persisted raft payloads
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / persisted / ApplyJournalEntries.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 java.io.Externalizable;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import java.io.Serializable;
15
16 /**
17  * This is an internal message that is stored in the akka's persistent journal. During recovery, this
18  * message is used to apply recovered journal entries to the state whose indexes range from the context's
19  * current lastApplied index to "toIndex" contained in the message. This message is sent internally from a
20  * behavior to the RaftActor to persist.
21  *
22  * @author Thomas Pantelis
23  */
24 public class ApplyJournalEntries implements Serializable {
25     private static final class Proxy implements Externalizable {
26         private static final long serialVersionUID = 1L;
27
28         private ApplyJournalEntries applyEntries;
29
30         // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
31         // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
32         @SuppressWarnings("checkstyle:RedundantModifier")
33         public Proxy() {
34             // For Externalizable
35         }
36
37         Proxy(final ApplyJournalEntries applyEntries) {
38             this.applyEntries = applyEntries;
39         }
40
41         @Override
42         public void writeExternal(final ObjectOutput out) throws IOException {
43             out.writeLong(applyEntries.toIndex);
44         }
45
46         @Override
47         public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
48             applyEntries = new ApplyJournalEntries(in.readLong());
49         }
50
51         private Object readResolve() {
52             return applyEntries;
53         }
54     }
55
56     private static final long serialVersionUID = 1L;
57
58     private final long toIndex;
59
60     public ApplyJournalEntries(final long toIndex) {
61         this.toIndex = toIndex;
62     }
63
64     public long getToIndex() {
65         return toIndex;
66     }
67
68     private Object writeReplace() {
69         return new Proxy(this);
70     }
71
72     @Override
73     public String toString() {
74         return "ApplyJournalEntries [toIndex=" + toIndex + "]";
75     }
76 }