BUG-8372: fix abort message confusion 38/56638/2
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 5 May 2017 11:46:22 +0000 (13:46 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Tue, 9 May 2017 22:42:23 +0000 (22:42 +0000)
Immediate transaction aborts need to use the appropriate message,
not 3PC's TransactionAbortRequest.

Change-Id: I9e25e3f20ed62fc520853685af17accef35c1bb4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4036805b31f73c7e7e2b06e84c8da975b2e45263)

opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalReadWriteProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/RemoteProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalReadWriteProxyTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/RemoteProxyTransactionTest.java

index a41bef9..9eba0bf 100644 (file)
@@ -13,6 +13,7 @@ import java.util.function.Consumer;
 import java.util.function.Supplier;
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.NotThreadSafe;
+import org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest;
 import org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest;
 import org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest;
 import org.opendaylight.controller.cluster.access.commands.PersistenceProtocol;
@@ -220,7 +221,7 @@ final class LocalReadWriteProxyTransaction extends LocalProxyTransaction {
 
             switch (maybeProtocol.get()) {
                 case ABORT:
-                    sendAbort(callback);
+                    sendRequest(new AbortLocalTransactionRequest(getIdentifier(), localActor()), callback);
                     break;
                 case READY:
                     // No-op, as we have already issued a seal()
index e91bd6c..d14b7bd 100644 (file)
@@ -71,7 +71,6 @@ final class RemoteProxyTransaction extends AbstractProxyTransaction {
 
     private volatile Exception operationFailure;
 
-
     RemoteProxyTransaction(final ProxyHistory parent, final TransactionIdentifier identifier,
             final boolean snapshotOnly, final boolean sendReadyOnSeal) {
         super(parent);
@@ -303,7 +302,11 @@ final class RemoteProxyTransaction extends AbstractProxyTransaction {
 
                 switch (maybeProto.get()) {
                     case ABORT:
-                        sendAbort(callback);
+                        ensureInitializedBuilder();
+                        builder.setAbort();
+                        final ModifyTransactionRequest newReq = builder.build();
+                        builderBusy = false;
+                        sendRequest(newReq, callback);
                         break;
                     case SIMPLE:
                         sendRequest(commitRequest(false), callback);
index 9cec79c..390302b 100644 (file)
@@ -177,7 +177,7 @@ public class LocalReadWriteProxyTransactionTest extends LocalProxyTransactionTes
         final ModifyTransactionRequest request = builder.build();
         final Consumer<Response<?, ?>> callback = createCallbackMock();
         transaction.applyModifyTransactionRequest(request, callback);
-        getTester().expectTransactionRequest(TransactionAbortRequest.class);
+        getTester().expectTransactionRequest(AbortLocalTransactionRequest.class);
     }
 
     @Test
index 9d6122f..f646bed 100644 (file)
@@ -178,8 +178,10 @@ public class RemoteProxyTransactionTest extends AbstractProxyTransactionTest<Rem
         builder.setSequence(0L);
         builder.setAbort();
         final ModifyTransactionRequest request = builder.build();
-        final TransactionAbortRequest received = testForwardToRemote(request, TransactionAbortRequest.class);
+        final ModifyTransactionRequest received = testForwardToRemote(request, ModifyTransactionRequest.class);
         Assert.assertEquals(request.getTarget(), received.getTarget());
+        Assert.assertTrue(received.getPersistenceProtocol().isPresent());
+        Assert.assertEquals(PersistenceProtocol.ABORT, received.getPersistenceProtocol().get());
     }
 
     @Test

©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.