X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcds-access-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fcommands%2FAbstractReadTransactionRequest.java;h=23fdd85140db711919672496df7cb10745af7c4a;hb=HEAD;hp=6510d5b5b41ffeb9a90f53e25096af034b905041;hpb=5cb0787412ab63a3aa5dcc044511e1ce569662cf;p=controller.git diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbstractReadTransactionRequest.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbstractReadTransactionRequest.java index 6510d5b5b4..23fdd85140 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbstractReadTransactionRequest.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbstractReadTransactionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2016, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -8,60 +8,67 @@ package org.opendaylight.controller.cluster.access.commands; import akka.actor.ActorRef; -import com.google.common.annotations.Beta; import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.ABIVersion; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; /** - * Abstract base class for {@link TransactionRequest}s accessing data as visible in the isolated context of a particular - * transaction. The path of the data being accessed is returned via {@link #getPath()}. + * Abstract base class for {@link TransactionRequest}s accessing transaction state without modifying it. * *

* This class is visible outside of this package for the purpose of allowing common instanceof checks * and simplified codepaths. * - * @author Robert Varga - * * @param Message type */ -@Beta public abstract class AbstractReadTransactionRequest> extends TransactionRequest { + interface SerialForm> extends TransactionRequest.SerialForm { + @Override + default T readExternal(final ObjectInput in, final TransactionIdentifier target, final long sequence, + final ActorRef replyTo) throws IOException { + return readExternal(in, target, sequence, replyTo, in.readBoolean()); + } + + @NonNull T readExternal(@NonNull ObjectInput in, @NonNull TransactionIdentifier target, long sequence, + @NonNull ActorRef replyTo, boolean snapshotOnly) throws IOException; + + @Override + default void writeExternal(final ObjectOutput out, final T msg) throws IOException { + TransactionRequest.SerialForm.super.writeExternal(out, msg); + out.writeBoolean(msg.isSnapshotOnly()); + } + } + + @java.io.Serial private static final long serialVersionUID = 1L; - private final YangInstanceIdentifier path; + private final boolean snapshotOnly; AbstractReadTransactionRequest(final TransactionIdentifier identifier, final long sequence, final ActorRef replyTo, - final YangInstanceIdentifier path, final boolean snapshotOnly) { + final boolean snapshotOnly) { super(identifier, sequence, replyTo); - this.path = Preconditions.checkNotNull(path); this.snapshotOnly = snapshotOnly; } AbstractReadTransactionRequest(final T request, final ABIVersion version) { super(request, version); - this.path = request.getPath(); this.snapshotOnly = request.isSnapshotOnly(); } - @Nonnull - public final YangInstanceIdentifier getPath() { - return path; - } - public final boolean isSnapshotOnly() { return snapshotOnly; } @Override protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) { - return super.addToStringAttributes(toStringHelper).add("path", path); + return super.addToStringAttributes(toStringHelper).add("snapshotOnly", snapshotOnly); } @Override - protected abstract AbstractReadTransactionRequestProxyV1 externalizableProxy(final ABIVersion version); + protected abstract SerialForm externalizableProxy(ABIVersion version); }