Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / persisted / DE.java
1 /*
2  * Copyright (c) 2022 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.persisted;
9
10 import static com.google.common.base.Verify.verifyNotNull;
11 import static java.util.Objects.requireNonNull;
12
13 import java.io.Externalizable;
14 import java.io.IOException;
15 import java.io.ObjectInput;
16 import java.io.ObjectOutput;
17 import org.opendaylight.yangtools.concepts.WritableObjects;
18
19 /**
20  * Serialization proxy for {@link DeleteEntries}.
21  */
22 final class DE implements Externalizable {
23     @java.io.Serial
24     private static final long serialVersionUID = 1L;
25
26     private DeleteEntries deleteEntries;
27
28     @SuppressWarnings("checkstyle:RedundantModifier")
29     public DE() {
30         // For Externalizable
31     }
32
33     DE(final DeleteEntries deleteEntries) {
34         this.deleteEntries = requireNonNull(deleteEntries);
35     }
36
37     @Override
38     public void writeExternal(final ObjectOutput out) throws IOException {
39         WritableObjects.writeLong(out, deleteEntries.getFromIndex());
40     }
41
42     @Override
43     public void readExternal(final ObjectInput in) throws IOException {
44         deleteEntries = new DeleteEntries(WritableObjects.readLong(in));
45     }
46
47     @java.io.Serial
48     private Object readResolve() {
49         return verifyNotNull(deleteEntries);
50     }
51 }