Bump cds-access-api ABIVersion
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / AbstractReadPathTransactionRequestProxyV1.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies, 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 akka.actor.ActorRef;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
15 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
16 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
17 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeStreamVersion;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19
20 /**
21  * Abstract base class for serialization proxies associated with {@link AbstractReadTransactionRequest}s. It implements
22  * the initial (Boron) serialization format.
23  *
24  * @author Robert Varga
25  *
26  * @param <T> Message type
27  */
28 abstract class AbstractReadPathTransactionRequestProxyV1<T extends AbstractReadPathTransactionRequest<T>>
29         extends AbstractReadTransactionRequestProxyV1<T> {
30     private static final long serialVersionUID = 1L;
31
32     private YangInstanceIdentifier path;
33     private transient NormalizedNodeStreamVersion streamVersion;
34
35     protected AbstractReadPathTransactionRequestProxyV1() {
36         // For Externalizable
37     }
38
39     AbstractReadPathTransactionRequestProxyV1(final T request) {
40         super(request);
41         path = request.getPath();
42         streamVersion = request.getVersion().getStreamVersion();
43     }
44
45     @Override
46     public final void writeExternal(final ObjectOutput out) throws IOException {
47         super.writeExternal(out);
48         try (NormalizedNodeDataOutput nnout = NormalizedNodeInputOutput.newDataOutput(out, streamVersion)) {
49             nnout.writeYangInstanceIdentifier(path);
50         }
51     }
52
53     @Override
54     public final void readExternal(final ObjectInput in) throws ClassNotFoundException, IOException {
55         super.readExternal(in);
56         path = NormalizedNodeInputOutput.newDataInput(in).readYangInstanceIdentifier();
57     }
58
59     @Override
60     protected final T createReadRequest(final TransactionIdentifier target, final long sequence,
61             final ActorRef replyTo, final boolean snapshotOnly) {
62         return createReadPathRequest(target, sequence, replyTo, path, snapshotOnly);
63     }
64
65     abstract T createReadPathRequest(TransactionIdentifier target, long sequence, ActorRef replyTo,
66             YangInstanceIdentifier requestPath, boolean snapshotOnly);
67 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.