CDS: Implement front-end support for local transactions
authorRobert Varga <rovarga@cisco.com>
Fri, 24 Apr 2015 11:33:24 +0000 (13:33 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Sat, 16 May 2015 01:38:03 +0000 (01:38 +0000)
Implemented support on the TransactionProxy front-end for optimizations
where the Shard is local to the controller instance. In this mode, the
Shard's DataTree obtained from the FindPrimaryShard message is used to
prepare the modifications completely on the front-end. On ready, the
DataTreeModification instance is passed to the Shard via
the ReadyLocalTransaction message. The Shard then does a direct commit,
eliding the 3PC from the front-end (it's a no-op as it is for remote
write-only txns).

TransactionContext instances are now obtained via an
AbstractTransactionContextFactory passed to TransactionProxy of which
there are 2 kinds: one for single, unchained txns and one for chained
tnxs. Each creates a different DOM transaction instance to handle
preperation of modifications. The DOM transacton is wrapped in a
LocalTransactionContext which the TransactionProxy interfaces with.

Change-Id: I0322b586f394e4b6c7793b8287ac804b41964378
Signed-off-by: Robert Varga <rovarga@cisco.com>
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
(cherry picked from commit 2f7c93174d7834a4c4aedacc9b88aa53a5a0422c)

opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractSnapshotBackedTransactionChain.java

index b7776b2a397940745501a6c87ffcdd5625d10dcc..7683937ce2799a31761b23d3e805f2524b1d590c 100644 (file)
@@ -120,19 +120,26 @@ public abstract class AbstractSnapshotBackedTransactionChain<T> extends Transact
 
     @Override
     public final DOMStoreReadTransaction newReadOnlyTransaction() {
+        return newReadOnlyTransaction(nextTransactionIdentifier());
+    }
+
+    protected DOMStoreReadTransaction newReadOnlyTransaction(T transactionId) {
         final Entry<State, DataTreeSnapshot> entry = getSnapshot();
-        return SnapshotBackedTransactions.newReadTransaction(nextTransactionIdentifier(), getDebugTransactions(), entry.getValue());
+        return SnapshotBackedTransactions.newReadTransaction(transactionId, getDebugTransactions(), entry.getValue());
     }
 
     @Override
     public final DOMStoreReadWriteTransaction newReadWriteTransaction() {
+        return newReadWriteTransaction(nextTransactionIdentifier());
+    }
+
+    protected DOMStoreReadWriteTransaction newReadWriteTransaction(T transactionId) {
         Entry<State, DataTreeSnapshot> entry;
         DOMStoreReadWriteTransaction ret;
 
         do {
             entry = getSnapshot();
-            ret = new SnapshotBackedReadWriteTransaction<T>(nextTransactionIdentifier(),
-                getDebugTransactions(), entry.getValue(), this);
+            ret = new SnapshotBackedReadWriteTransaction<T>(transactionId, getDebugTransactions(), entry.getValue(), this);
         } while (!recordTransaction(entry.getKey(), ret));
 
         return ret;
@@ -140,13 +147,16 @@ public abstract class AbstractSnapshotBackedTransactionChain<T> extends Transact
 
     @Override
     public final DOMStoreWriteTransaction newWriteOnlyTransaction() {
+        return newWriteOnlyTransaction(nextTransactionIdentifier());
+    }
+
+    protected DOMStoreWriteTransaction newWriteOnlyTransaction(T transactionId) {
         Entry<State, DataTreeSnapshot> entry;
         DOMStoreWriteTransaction ret;
 
         do {
             entry = getSnapshot();
-            ret = new SnapshotBackedWriteTransaction<T>(nextTransactionIdentifier(),
-                getDebugTransactions(), entry.getValue(), this);
+            ret = new SnapshotBackedWriteTransaction<T>(transactionId, getDebugTransactions(), entry.getValue(), this);
         } while (!recordTransaction(entry.getKey(), ret));
 
         return ret;