2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.access.commands;
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.yangtools.yang.data.api.YangInstanceIdentifier;
20 * Abstract base class for serialization proxies associated with {@link AbstractReadTransactionRequest}s. It implements
21 * the initial (Boron) serialization format.
23 * @author Robert Varga
25 * @param <T> Message type
27 abstract class AbstractReadTransactionRequestProxyV1<T extends AbstractReadTransactionRequest<T>>
28 extends AbstractTransactionRequestProxy<T> {
29 private static final long serialVersionUID = 1L;
30 private YangInstanceIdentifier path;
31 private boolean snapshotOnly;
33 protected AbstractReadTransactionRequestProxyV1() {
37 AbstractReadTransactionRequestProxyV1(final T request) {
39 path = request.getPath();
40 snapshotOnly = request.isSnapshotOnly();
44 public final void writeExternal(final ObjectOutput out) throws IOException {
45 super.writeExternal(out);
46 try (NormalizedNodeDataOutput nnout = NormalizedNodeInputOutput.newDataOutput(out)) {
47 nnout.writeYangInstanceIdentifier(path);
49 out.writeBoolean(snapshotOnly);
53 public final void readExternal(final ObjectInput in) throws ClassNotFoundException, IOException {
54 super.readExternal(in);
55 path = NormalizedNodeInputOutput.newDataInput(in).readYangInstanceIdentifier();
56 snapshotOnly = in.readBoolean();
60 protected final T createRequest(final TransactionIdentifier target, final long sequence, final ActorRef replyTo) {
61 return createReadRequest(target, sequence, replyTo, path, snapshotOnly);
64 abstract T createReadRequest(TransactionIdentifier target, long sequence, ActorRef replyTo,
65 YangInstanceIdentifier requestPath, boolean snapshotOnly);