Adjust to mdsal DOM read/exists FluentFuture change
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / CommitLocalTransactionRequest.java
index 1f739515c99c6f0c6eb1c4e960a97ebc4f3b113f..5cff1a8f5cd9482f8bb330f49c524773d05f68d2 100644 (file)
@@ -11,7 +11,10 @@ import akka.actor.ActorRef;
 import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.base.Preconditions;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.Optional;
 import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 
@@ -22,18 +25,36 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification
  * @author Robert Varga
  */
 @Beta
-public final class CommitLocalTransactionRequest extends AbstractLocalTransactionRequest<CommitLocalTransactionRequest> {
+public final class CommitLocalTransactionRequest
+        extends AbstractLocalTransactionRequest<CommitLocalTransactionRequest> {
     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(final @Nonnull TransactionIdentifier identifier,
-            final @Nonnull ActorRef replyTo, final @Nonnull DataTreeModification mod, final boolean coordinated) {
-        super(identifier, replyTo);
+    public CommitLocalTransactionRequest(@Nonnull final TransactionIdentifier identifier, final long sequence,
+            @Nonnull final ActorRef replyTo, @Nonnull final DataTreeModification mod,
+            @Nullable final Exception delayedFailure, final boolean coordinated) {
+        super(identifier, sequence, replyTo);
         this.mod = Preconditions.checkNotNull(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<Exception> getDelayedFailure() {
+        return Optional.ofNullable(delayedFailure);
+    }
+
     public DataTreeModification getModification() {
         return mod;
     }
@@ -52,6 +73,7 @@ public final class CommitLocalTransactionRequest extends AbstractLocalTransactio
 
     @Override
     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
-        return super.addToStringAttributes(toStringHelper).add("coordinated", coordinated);
+        return super.addToStringAttributes(toStringHelper).add("coordinated", coordinated)
+                .add("delayedError", delayedFailure);
     }
-}
\ No newline at end of file
+}