Trigger snapshots on legacy persisted entries
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / persisted / DeleteEntries.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  * Internal message that is stored in the akka's persistent journal to delete journal entries.
18  *
19  * @author Thomas Pantelis
20  */
21 public sealed class DeleteEntries implements Serializable {
22     @Deprecated(since = "7.0.0", forRemoval = true)
23     private static final class Legacy extends DeleteEntries implements LegacySerializable {
24         @java.io.Serial
25         private static final long serialVersionUID = 1L;
26
27         Legacy(final long fromIndex) {
28             super(fromIndex);
29         }
30     }
31
32     @Deprecated(since = "7.0.0", forRemoval = true)
33     private static final class Proxy implements Externalizable {
34         @java.io.Serial
35         private static final long serialVersionUID = 1L;
36
37         private DeleteEntries deleteEntries = null;
38
39         // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
40         // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
41         @SuppressWarnings("checkstyle:RedundantModifier")
42         public Proxy() {
43             // For Externalizable
44         }
45
46         @Override
47         public void writeExternal(final ObjectOutput out) throws IOException {
48             out.writeLong(deleteEntries.fromIndex);
49         }
50
51         @Override
52         public void readExternal(final ObjectInput in) throws IOException {
53             deleteEntries = new Legacy(in.readLong());
54         }
55
56         @java.io.Serial
57         private Object readResolve() {
58             return deleteEntries;
59         }
60     }
61
62     @java.io.Serial
63     private static final long serialVersionUID = 1L;
64
65     private final long fromIndex;
66
67     public DeleteEntries(final long fromIndex) {
68         this.fromIndex = fromIndex;
69     }
70
71     public final long getFromIndex() {
72         return fromIndex;
73     }
74
75     @java.io.Serial
76     public final Object writeReplace() {
77         return new DE(this);
78     }
79
80     @Override
81     public final String toString() {
82         return "DeleteEntries [fromIndex=" + fromIndex + "]";
83     }
84 }