Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / ReadTransactionSuccess.java
1 /*
2  * Copyright (c) 2016 Cisco 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.access.commands;
9
10 import static java.util.Objects.requireNonNull;
11
12 import java.io.IOException;
13 import java.io.ObjectInputStream;
14 import java.io.ObjectOutputStream;
15 import java.io.ObjectStreamException;
16 import java.util.Optional;
17 import org.opendaylight.controller.cluster.access.ABIVersion;
18 import org.opendaylight.controller.cluster.access.concepts.SliceableMessage;
19 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
21
22 /**
23  * Successful reply to an {@link ReadTransactionRequest}. It indicates presence of requested data via
24  * {@link #getData()}.
25  */
26 public final class ReadTransactionSuccess extends TransactionSuccess<ReadTransactionSuccess>
27         implements SliceableMessage {
28     @java.io.Serial
29     private static final long serialVersionUID = 1L;
30
31     private final Optional<NormalizedNode> data;
32
33     private ReadTransactionSuccess(final ReadTransactionSuccess request, final ABIVersion version) {
34         super(request, version);
35         data = request.data;
36     }
37
38     public ReadTransactionSuccess(final TransactionIdentifier identifier, final long sequence,
39             final Optional<NormalizedNode> data) {
40         super(identifier, sequence);
41         this.data = requireNonNull(data);
42     }
43
44     public Optional<NormalizedNode> getData() {
45         return data;
46     }
47
48     @Override
49     protected RTS externalizableProxy(final ABIVersion version) {
50         return new RTS(this);
51     }
52
53     @Override
54     protected ReadTransactionSuccess cloneAsVersion(final ABIVersion version) {
55         return new ReadTransactionSuccess(this, version);
56     }
57
58     @java.io.Serial
59     private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException {
60         throwNSE();
61     }
62
63     @java.io.Serial
64     private void readObjectNoData() throws ObjectStreamException {
65         throwNSE();
66     }
67
68     @java.io.Serial
69     private void writeObject(final ObjectOutputStream stream) throws IOException {
70         throwNSE();
71     }
72 }