Remove TransactionContext.supportsDirectCommit method 72/34472/2
authorTom Pantelis <tpanteli@brocade.com>
Wed, 10 Feb 2016 18:12:34 +0000 (13:12 -0500)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 15 Feb 2016 09:31:16 +0000 (09:31 +0000)
The supportsDirectCommit method was added for backwards compatibility
with pre-Lithium and thus can be removed to simplify the code. All the
current implementations return true.

Change-Id: I256e19b5c0b63a5371c70def72adc6c2a1427106
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpTransactionContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/RemoteTransactionContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java

index a6e42c4..55ff68e 100644 (file)
@@ -86,11 +86,6 @@ abstract class LocalTransactionContext extends AbstractTransactionContext {
         return cohort.initiateDirectCommit();
     }
 
-    @Override
-    public boolean supportsDirectCommit() {
-        return true;
-    }
-
     @Override
     public void closeTransaction() {
         txDelegate.close();
index fa9d97a..b3dd638 100644 (file)
@@ -34,11 +34,6 @@ final class NoOpTransactionContext extends AbstractTransactionContext {
         LOG.debug("NoOpTransactionContext {} closeTransaction called", getIdentifier());
     }
 
-    @Override
-    public boolean supportsDirectCommit() {
-        return true;
-    }
-
     @Override
     public Future<Object> directCommit() {
         LOG.debug("Tx {} directCommit called, failure: {}", getIdentifier(), failure);
index 67916cf..3f821c7 100644 (file)
@@ -74,11 +74,6 @@ public class RemoteTransactionContext extends AbstractTransactionContext {
         actorContext.sendOperationAsync(getActor(), new CloseTransaction(getTransactionVersion()).toSerializable());
     }
 
-    @Override
-    public boolean supportsDirectCommit() {
-        return true;
-    }
-
     @Override
     public Future<Object> directCommit() {
         LOG.debug("Tx {} directCommit called", getIdentifier());
index 5dcba75..b033980 100644 (file)
@@ -254,30 +254,26 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
             contextWrapper.maybeExecuteTransactionOperation(new TransactionOperation() {
                 @Override
                 public void invoke(TransactionContext transactionContext) {
-                    promise.completeWith(getReadyOrDirectCommitFuture(transactionContext, operationCallbackRef));
+                    promise.completeWith(getDirectCommitFuture(transactionContext, operationCallbackRef));
                 }
             });
             future = promise.future();
         } else {
             // avoid the creation of a promise and a TransactionOperation
-            future = getReadyOrDirectCommitFuture(transactionContext, operationCallbackRef);
+            future = getDirectCommitFuture(transactionContext, operationCallbackRef);
         }
 
         return new SingleCommitCohortProxy(txContextFactory.getActorContext(), future, getIdentifier().toString(),
                 operationCallbackRef);
     }
 
-    private Future<?> getReadyOrDirectCommitFuture(TransactionContext transactionContext,
+    private Future<?> getDirectCommitFuture(TransactionContext transactionContext,
             OperationCallback.Reference operationCallbackRef) {
-        if (transactionContext.supportsDirectCommit()) {
-            TransactionRateLimitingCallback rateLimitingCallback = new TransactionRateLimitingCallback(
-                    txContextFactory.getActorContext());
-            operationCallbackRef.set(rateLimitingCallback);
-            rateLimitingCallback.run();
-            return transactionContext.directCommit();
-        } else {
-            return transactionContext.readyTransaction();
-        }
+        TransactionRateLimitingCallback rateLimitingCallback = new TransactionRateLimitingCallback(
+                txContextFactory.getActorContext());
+        operationCallbackRef.set(rateLimitingCallback);
+        rateLimitingCallback.run();
+        return transactionContext.directCommit();
     }
 
     private AbstractThreePhaseCommitCohort<ActorSelection> createMultiCommitCohort(

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