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%2FCommitLocalTransactionRequest.java;h=1e16cb5bbde1b4ee064e914a4055caee91b0b59b;hb=e84f63ee098fff5b02cbce1281ca0d1208f966fa;hp=a1aa3995a2d6dade23ab891018dca312cce7d15b;hpb=93fd87f9e46446be9eb8538669ebbfade205590e;p=controller.git diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/CommitLocalTransactionRequest.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/CommitLocalTransactionRequest.java index a1aa3995a2..1e16cb5bbd 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/CommitLocalTransactionRequest.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/CommitLocalTransactionRequest.java @@ -7,13 +7,17 @@ */ package org.opendaylight.controller.cluster.access.commands; +import static java.util.Objects.requireNonNull; + 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 edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; +import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification; /** * Request to commit a local transaction. Since local transactions do not introduce state on the backend until they @@ -25,16 +29,33 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification public final class CommitLocalTransactionRequest extends AbstractLocalTransactionRequest { private static final long serialVersionUID = 1L; + + @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class " + + "implements writeReplace to delegate serialization to a Proxy class and thus instances of this class " + + "aren't serialized. FindBugs does not recognize this.") private final DataTreeModification mod; + private final Exception delayedFailure; private final boolean coordinated; - public CommitLocalTransactionRequest(@Nonnull final TransactionIdentifier identifier, - @Nonnull final ActorRef replyTo, @Nonnull final DataTreeModification mod, final boolean coordinated) { - super(identifier, 0, replyTo); - this.mod = Preconditions.checkNotNull(mod); + public CommitLocalTransactionRequest(final @NonNull TransactionIdentifier identifier, final long sequence, + final @NonNull ActorRef replyTo, final @NonNull DataTreeModification mod, + final @Nullable Exception delayedFailure, final boolean coordinated) { + super(identifier, sequence, replyTo); + this.mod = requireNonNull(mod); + this.delayedFailure = delayedFailure; this.coordinated = coordinated; } + /** + * Return the delayed error detected on the frontend. If this error is present, it will be reported as the result + * of the first step of the commit process. + * + * @return Delayed failure, if present. + */ + public Optional getDelayedFailure() { + return Optional.ofNullable(delayedFailure); + } + public DataTreeModification getModification() { return mod; } @@ -53,6 +74,7 @@ public final class CommitLocalTransactionRequest @Override protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) { - return super.addToStringAttributes(toStringHelper).add("coordinated", coordinated); + return super.addToStringAttributes(toStringHelper).add("coordinated", coordinated) + .add("delayedError", delayedFailure); } }