Repository: nifi
Updated Branches:
  refs/heads/master 46b81058c -> 31ca8d02f


NIFI-2488 Fixed BulletinDTOs not getting their node addresses set properly 
during bulletin merging. This closes #888


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

Branch: refs/heads/master
Commit: 31ca8d02f7af5cdb82970d31501574bb4d6b7a3b
Parents: 46b8105
Author: Jeff Storck <[email protected]>
Authored: Thu Aug 18 11:33:16 2016 -0400
Committer: Matt Gilman <[email protected]>
Committed: Fri Aug 19 08:32:00 2016 -0400

----------------------------------------------------------------------
 .../nifi/cluster/manager/BulletinMerger.java    | 41 +++++---------------
 1 file changed, 10 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/31ca8d02/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/BulletinMerger.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/BulletinMerger.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/BulletinMerger.java
index ed96f75..79b1447 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/BulletinMerger.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/BulletinMerger.java
@@ -22,10 +22,8 @@ import org.apache.nifi.web.api.entity.BulletinEntity;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 public final class BulletinMerger {
 
@@ -54,23 +52,26 @@ public final class BulletinMerger {
      * @param bulletins bulletins
      */
     public static List<BulletinEntity> mergeBulletins(final 
Map<NodeIdentifier, List<BulletinEntity>> bulletins) {
-        final List<BulletinEntity> bulletinDtos = new ArrayList<>();
+        final List<BulletinEntity> bulletinEntities = new ArrayList<>();
 
         for (final Map.Entry<NodeIdentifier, List<BulletinEntity>> entry : 
bulletins.entrySet()) {
             final NodeIdentifier nodeId = entry.getKey();
             final List<BulletinEntity> nodeBulletins = entry.getValue();
             final String nodeAddress = nodeId.getApiAddress() + ":" + 
nodeId.getApiPort();
 
-            for (final BulletinEntity bulletin : nodeBulletins) {
-                if (bulletin.getNodeAddress() == null) {
-                    bulletin.setNodeAddress(nodeAddress);
+            for (final BulletinEntity bulletinEntity : nodeBulletins) {
+                if (bulletinEntity.getNodeAddress() == null) {
+                    bulletinEntity.setNodeAddress(nodeAddress);
                 }
 
-                bulletinDtos.add(bulletin);
+                if (bulletinEntity.getCanRead() && 
bulletinEntity.getBulletin() != null && 
bulletinEntity.getBulletin().getNodeAddress() == null) {
+                    bulletinEntity.getBulletin().setNodeAddress(nodeAddress);
+                }
+                bulletinEntities.add(bulletinEntity);
             }
         }
 
-        Collections.sort(bulletinDtos, (BulletinEntity o1, BulletinEntity o2) 
-> {
+        Collections.sort(bulletinEntities, (BulletinEntity o1, BulletinEntity 
o2) -> {
             final int timeComparison = 
o1.getTimestamp().compareTo(o2.getTimestamp());
             if (timeComparison != 0) {
                 return timeComparison;
@@ -79,28 +80,6 @@ public final class BulletinMerger {
             return o1.getNodeAddress().compareTo(o2.getNodeAddress());
         });
 
-        return bulletinDtos;
-    }
-
-    /**
-     * Normalizes the validation errors.
-     *
-     * @param validationErrorMap validation errors for each node
-     * @param totalNodes total number of nodes
-     * @return the normalized validation errors
-     */
-    public static Set<String> normalizedMergedValidationErrors(final 
Map<String, Set<NodeIdentifier>> validationErrorMap, int totalNodes) {
-        final Set<String> normalizedValidationErrors = new HashSet<>();
-        for (final Map.Entry<String, Set<NodeIdentifier>> validationEntry : 
validationErrorMap.entrySet()) {
-            final String msg = validationEntry.getKey();
-            final Set<NodeIdentifier> nodeIds = validationEntry.getValue();
-
-            if (nodeIds.size() == totalNodes) {
-                normalizedValidationErrors.add(msg);
-            } else {
-                nodeIds.forEach(id -> 
normalizedValidationErrors.add(id.getApiAddress() + ":" + id.getApiPort() + " 
-- " + msg));
-            }
-        }
-        return normalizedValidationErrors;
+        return bulletinEntities;
     }
 }

Reply via email to