Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / persisted / SS.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.datastore.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
18 /**
19  * Serialization proxy for {@link ShardSnapshotState}.
20  */
21 final class SS implements Externalizable {
22     @java.io.Serial
23     private static final long serialVersionUID = 1L;
24
25     private ShardSnapshotState snapshotState;
26
27     @SuppressWarnings("checkstyle:RedundantModifier")
28     public SS() {
29         // For Externalizable
30     }
31
32     SS(final ShardSnapshotState snapshotState) {
33         this.snapshotState = requireNonNull(snapshotState);
34     }
35
36     @Override
37     public void readExternal(final ObjectInput in) throws IOException {
38         snapshotState = ShardDataTreeSnapshot.deserialize(in);
39     }
40
41     @Override
42     public void writeExternal(final ObjectOutput out) throws IOException {
43         snapshotState.getSnapshot().serialize(out);
44     }
45
46     @java.io.Serial
47     private Object readResolve() {
48         return verifyNotNull(snapshotState);
49     }
50 }