Performance improvements
- Fast path of transactions updating a single key.
- Bug fix in StoragePartitionClient where we were always creating a CachingMap
Change-Id: Ide117fba34fd12a9ff4aabd5fb7a21952bae672b
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/TransactionParticipant.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/TransactionParticipant.java
index 66e1f3a..c8308af 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/TransactionParticipant.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/TransactionParticipant.java
@@ -26,7 +26,21 @@
* Returns if this participant has updates that need to be committed.
* @return {@code true} if yes; {@code false} otherwise
*/
- boolean hasPendingUpdates();
+ default boolean hasPendingUpdates() {
+ return totalUpdates() > 0;
+ }
+
+ /**
+ * Returns the number of updates that need to committed for this participant.
+ * @return update count.
+ */
+ int totalUpdates();
+
+ /**
+ * Executes the prepare and commit steps in a single go.
+ * @return {@code true} is successful i.e updates are committed; {@code false} otherwise
+ */
+ CompletableFuture<Boolean> prepareAndCommit();
/**
* Executes the prepare phase.