Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / concepts / TI.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.access.concepts;
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 TransactionIdentifier}.
21  */
22 final class TI implements Externalizable {
23     @java.io.Serial
24     private static final long serialVersionUID = 1L;
25
26     private TransactionIdentifier identifier;
27
28     @SuppressWarnings("checkstyle:RedundantModifier")
29     public TI() {
30         // for Externalizable
31     }
32
33     TI(final TransactionIdentifier identifier) {
34         this.identifier = requireNonNull(identifier);
35     }
36
37     @Override
38     public void readExternal(final ObjectInput in) throws IOException {
39         identifier = new TransactionIdentifier(LocalHistoryIdentifier.readFrom(in), WritableObjects.readLong(in));
40     }
41
42     @Override
43     public void writeExternal(final ObjectOutput out) throws IOException {
44         identifier.getHistoryId().writeTo(out);
45         WritableObjects.writeLong(out, identifier.getTransactionId());
46     }
47
48     @java.io.Serial
49     private Object readResolve() {
50         return verifyNotNull(identifier);
51     }
52 }