Handle ModifyTransactionRequest in forward path 89/98489/4
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 13 Nov 2021 18:38:08 +0000 (19:38 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 13 Nov 2021 19:49:46 +0000 (20:49 +0100)
When we have remote -> local handoff, we will use a
ModifyTransactionRequest, which we need to apply before moving on.

JIRA: CONTROLLER-2022
Change-Id: I04bdfda162d474966b153223c7480fd5b3af8099
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalReadWriteProxyTransaction.java

index 1f1e394..c58f834 100644 (file)
@@ -86,13 +86,13 @@ final class LocalReadWriteProxyTransaction extends LocalProxyTransaction {
     LocalReadWriteProxyTransaction(final ProxyHistory parent, final TransactionIdentifier identifier,
         final DataTreeSnapshot snapshot) {
         super(parent, identifier, false);
-        this.modification = (CursorAwareDataTreeModification) snapshot.newModification();
+        modification = (CursorAwareDataTreeModification) snapshot.newModification();
     }
 
     LocalReadWriteProxyTransaction(final ProxyHistory parent, final TransactionIdentifier identifier) {
         super(parent, identifier, true);
         // This is DONE transaction, this should never be touched
-        this.modification = null;
+        modification = null;
     }
 
     @Override
@@ -325,12 +325,19 @@ final class LocalReadWriteProxyTransaction extends LocalProxyTransaction {
     void forwardToLocal(final LocalProxyTransaction successor, final TransactionRequest<?> request,
             final Consumer<Response<?, ?>> callback) {
         if (request instanceof CommitLocalTransactionRequest) {
-            Verify.verify(successor instanceof LocalReadWriteProxyTransaction);
-            ((LocalReadWriteProxyTransaction) successor).sendRebased((CommitLocalTransactionRequest)request, callback);
-            LOG.debug("Forwarded request {} to successor {}", request, successor);
+            verifyLocalReadWrite(successor).sendRebased((CommitLocalTransactionRequest)request, callback);
+        } else if (request instanceof ModifyTransactionRequest) {
+            verifyLocalReadWrite(successor).handleForwardedRemoteRequest(request, callback);
         } else {
             super.forwardToLocal(successor, request, callback);
+            return;
         }
+        LOG.debug("Forwarded request {} to successor {}", request, successor);
+    }
+
+    private static LocalReadWriteProxyTransaction verifyLocalReadWrite(final LocalProxyTransaction successor) {
+        Verify.verify(successor instanceof LocalReadWriteProxyTransaction, "Unexpected successor %s", successor);
+        return (LocalReadWriteProxyTransaction) successor;
     }
 
     @Override