Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / ETS.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.commands;
9
10 import static com.google.common.base.Verify.verifyNotNull;
11 import static java.util.Objects.requireNonNull;
12
13 import java.io.IOException;
14 import java.io.ObjectInput;
15 import java.io.ObjectOutput;
16 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
17
18 /**
19  * Externalizable proxy for use with {@link ExistsTransactionSuccess}. It implements the Chlorine SR2 serialization
20  * format.
21  */
22 final class ETS implements TransactionSuccess.SerialForm<ExistsTransactionSuccess> {
23     @java.io.Serial
24     private static final long serialVersionUID = 1L;
25
26     private ExistsTransactionSuccess message;
27
28     @SuppressWarnings("checkstyle:RedundantModifier")
29     public ETS() {
30         // for Externalizable
31     }
32
33     ETS(final ExistsTransactionSuccess message) {
34         this.message = requireNonNull(message);
35     }
36
37     @Override
38     public ExistsTransactionSuccess message() {
39         return verifyNotNull(message);
40     }
41
42     @Override
43     public void setMessage(final ExistsTransactionSuccess message) {
44         this.message = requireNonNull(message);
45     }
46
47     @Override
48     public void writeExternal(final ObjectOutput out, final ExistsTransactionSuccess msg) throws IOException {
49         out.writeBoolean(msg.getExists());
50     }
51
52     @Override
53     public ExistsTransactionSuccess readExternal(final ObjectInput in, final TransactionIdentifier target,
54             final long sequence) throws IOException {
55         return new ExistsTransactionSuccess(target, sequence, in.readBoolean());
56     }
57
58     @Override
59     public Object readResolve() {
60         return message();
61     }
62 }