You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2018/09/14 15:34:07 UTC

nifi git commit: NIFI-5577 Fixing update method in NaiveRevisionManager so that failed updates don't change the revision

Repository: nifi
Updated Branches:
  refs/heads/master 647152ab1 -> 14729be83


NIFI-5577 Fixing update method in NaiveRevisionManager so that failed updates don't change the revision

This closes #2995.

Signed-off-by: Mark Payne <ma...@hotmail.com>


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/14729be8
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/14729be8
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/14729be8

Branch: refs/heads/master
Commit: 14729be837109af9fe986d61a0b3abcb2288672a
Parents: 647152a
Author: Bryan Bende <bb...@apache.org>
Authored: Thu Sep 6 15:54:41 2018 -0400
Committer: Mark Payne <ma...@hotmail.com>
Committed: Fri Sep 14 11:33:53 2018 -0400

----------------------------------------------------------------------
 .../nifi/web/revision/NaiveRevisionManager.java | 41 ++++----------------
 1 file changed, 7 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/14729be8/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-optimistic-locking/src/main/java/org/apache/nifi/web/revision/NaiveRevisionManager.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-optimistic-locking/src/main/java/org/apache/nifi/web/revision/NaiveRevisionManager.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-optimistic-locking/src/main/java/org/apache/nifi/web/revision/NaiveRevisionManager.java
index c9a87a2..6f07bdb 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-optimistic-locking/src/main/java/org/apache/nifi/web/revision/NaiveRevisionManager.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-optimistic-locking/src/main/java/org/apache/nifi/web/revision/NaiveRevisionManager.java
@@ -19,9 +19,7 @@ package org.apache.nifi.web.revision;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
@@ -115,43 +113,18 @@ public class NaiveRevisionManager implements RevisionManager {
         // We successfully verified all revisions.
         logger.debug("Successfully verified Revision Claim for all revisions");
 
-        RevisionUpdate<T> updatedComponent = null;
-        try {
-            updatedComponent = task.update();
-        } finally {
-            // Release the lock that we are holding and update the revision.
-            // To do this, we need to map the old revision to the new revision
-            // so that we have an efficient way to lookup the pairing, so that
-            // we can easily obtain the old revision and the new revision for
-            // the same component in order to call #unlock on the RevisionLock
-            final Map<Revision, Revision> updatedRevisions = new HashMap<>();
-            final Map<String, Revision> revisionsByComponentId = new HashMap<>();
-            for (final Revision revision : revisionList) {
-                updatedRevisions.put(revision, revision);
-                revisionsByComponentId.put(revision.getComponentId(), revision);
-            }
-
-            if (updatedComponent != null) {
-                for (final Revision updatedRevision : updatedComponent.getUpdatedRevisions()) {
-                    final Revision oldRevision = revisionsByComponentId.get(updatedRevision.getComponentId());
-                    if (oldRevision != null) {
-                        updatedRevisions.put(oldRevision, updatedRevision);
-                    }
-                }
-            }
+        // Perform the update
+        final RevisionUpdate<T> updatedComponent = task.update();
 
-            for (final Revision revision : revisionList) {
-                final Revision updatedRevision = updatedRevisions.get(revision);
+        // If the update succeeded then put the updated revisions into the revisionMap
+        // If an exception is thrown during the update we don't want to update revision so it is ok to bounce out of this method
+        if (updatedComponent != null) {
+            for (final Revision updatedRevision : updatedComponent.getUpdatedRevisions()) {
                 revisionMap.put(updatedRevision.getComponentId(), updatedRevision);
-
-                if (updatedRevision.getVersion() != revision.getVersion()) {
-                    logger.debug("Unlocked Revision {} and updated associated Version to {}", revision, updatedRevision.getVersion());
-                } else {
-                    logger.debug("Unlocked Revision {} without updating Version", revision);
-                }
             }
         }
 
         return updatedComponent;
     }
+
 }