commit | 9254501814c968910d254b5f85087c72bb514b9d | [log] [tgz] |
---|---|---|
author | Madan Jampani <madan.jampani@gmail.com> | Tue Feb 09 13:30:47 2016 -0800 |
committer | Gerrit Code Review <gerrit@onlab.us> | Wed Feb 10 07:55:53 2016 +0000 |
tree | 1a6ed0d653c066bf98d4df3452527102b237df15 | |
parent | 49fff75f7d199423d8e97bae6d744722ff47edb1 [diff] |
Fast path in transaction manager for single update scenarios Change-Id: Ia0ad61aabf5c35fbfadc5b127662edb497bcc9c0
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/TransactionManager.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/TransactionManager.java index 30aebb1..02a9fde 100644 --- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/TransactionManager.java +++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/TransactionManager.java
@@ -50,6 +50,12 @@ * @return transaction commit result */ public CompletableFuture<CommitResult> execute(Transaction transaction) { + // short-circuit if there is only a single update + if (transaction.updates().size() <= 1) { + return database.prepareAndCommit(transaction) + .thenApply(response -> response.success() + ? CommitResult.OK : CommitResult.FAILURE_DURING_COMMIT); + } // clean up if this transaction in already in a terminal state. if (transaction.state() == COMMITTED || transaction.state() == ROLLEDBACK) { return transactions.remove(transaction.id()).thenApply(v -> CommitResult.OK);