From 31ca8d02f7af5cdb82970d31501574bb4d6b7a3b Mon Sep 17 00:00:00 2001 From: Jeff Storck Date: Thu, 18 Aug 2016 11:33:16 -0400 Subject: [PATCH] NIFI-2488 Fixed BulletinDTOs not getting their node addresses set properly during bulletin merging. This closes #888 --- .../nifi/cluster/manager/BulletinMerger.java | 41 +++++-------------- 1 file changed, 10 insertions(+), 31 deletions(-) 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 ed96f7564f..79b1447b8b 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 mergeBulletins(final Map> bulletins) { - final List bulletinDtos = new ArrayList<>(); + final List bulletinEntities = new ArrayList<>(); for (final Map.Entry> entry : bulletins.entrySet()) { final NodeIdentifier nodeId = entry.getKey(); final List 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 normalizedMergedValidationErrors(final Map> validationErrorMap, int totalNodes) { - final Set normalizedValidationErrors = new HashSet<>(); - for (final Map.Entry> validationEntry : validationErrorMap.entrySet()) { - final String msg = validationEntry.getKey(); - final Set 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; } }