You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2017/09/22 15:55:04 UTC

nifi git commit: NIFI-4403 - add group name to bulletins model. This closes #2167

Repository: nifi
Updated Branches:
  refs/heads/master 0c0c33411 -> 50d018566


NIFI-4403 - add group name to bulletins model. This closes #2167


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

Branch: refs/heads/master
Commit: 50d018566db4d2c6f97995dcde7a180d7e154ae6
Parents: 0c0c334
Author: Pierre Villard <pi...@gmail.com>
Authored: Thu Sep 21 14:12:29 2017 +0200
Committer: Matt Gilman <ma...@gmail.com>
Committed: Fri Sep 22 11:53:58 2017 -0400

----------------------------------------------------------------------
 .../java/org/apache/nifi/reporting/Bulletin.java   |  9 +++++++++
 .../org/apache/nifi/reporting/BulletinFactory.java | 13 +++++++++++++
 .../org/apache/nifi/util/MockReportingContext.java |  2 +-
 .../org/apache/nifi/events/BulletinFactory.java    | 17 ++++++++++++++++-
 .../java/org/apache/nifi/jaxb/AdaptedBulletin.java |  9 +++++++++
 .../java/org/apache/nifi/jaxb/BulletinAdapter.java |  4 +++-
 .../nifi/logging/ControllerServiceLogObserver.java |  7 ++++++-
 .../nifi/remote/StandardRemoteProcessGroup.java    |  3 ++-
 .../apache/nifi/remote/StandardRootGroupPort.java  |  3 ++-
 .../reporting/SiteToSiteBulletinReportingTask.java |  1 +
 .../TestSiteToSiteBulletinReportingTask.java       |  3 ++-
 11 files changed, 64 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/50d01856/nifi-api/src/main/java/org/apache/nifi/reporting/Bulletin.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/reporting/Bulletin.java b/nifi-api/src/main/java/org/apache/nifi/reporting/Bulletin.java
index fe370ae..50684d6 100644
--- a/nifi-api/src/main/java/org/apache/nifi/reporting/Bulletin.java
+++ b/nifi-api/src/main/java/org/apache/nifi/reporting/Bulletin.java
@@ -32,6 +32,7 @@ public abstract class Bulletin implements Comparable<Bulletin> {
     private String message;
 
     private String groupId;
+    private String groupName;
     private String sourceId;
     private String sourceName;
     private ComponentType sourceType;
@@ -89,6 +90,14 @@ public abstract class Bulletin implements Comparable<Bulletin> {
         this.groupId = groupId;
     }
 
+    public String getGroupName() {
+        return groupName;
+    }
+
+    public void setGroupName(String groupName) {
+        this.groupName = groupName;
+    }
+
     public String getSourceId() {
         return sourceId;
     }

http://git-wip-us.apache.org/repos/asf/nifi/blob/50d01856/nifi-mock/src/main/java/org/apache/nifi/reporting/BulletinFactory.java
----------------------------------------------------------------------
diff --git a/nifi-mock/src/main/java/org/apache/nifi/reporting/BulletinFactory.java b/nifi-mock/src/main/java/org/apache/nifi/reporting/BulletinFactory.java
index 221bed6..0208a2e 100644
--- a/nifi-mock/src/main/java/org/apache/nifi/reporting/BulletinFactory.java
+++ b/nifi-mock/src/main/java/org/apache/nifi/reporting/BulletinFactory.java
@@ -33,6 +33,19 @@ public class BulletinFactory {
         return bulletin;
     }
 
+    public static Bulletin createBulletin(final String groupId, final String groupName, final String sourceId, final String sourceName,
+            final String category, final String severity, final String message) {
+        final Bulletin bulletin = new MockBulletin(currentId.getAndIncrement());
+        bulletin.setGroupId(groupId);
+        bulletin.setGroupName(groupName);
+        bulletin.setSourceId(sourceId);
+        bulletin.setSourceName(sourceName);
+        bulletin.setCategory(category);
+        bulletin.setLevel(severity);
+        bulletin.setMessage(message);
+        return bulletin;
+    }
+
     public static Bulletin createBulletin(final String category, final String severity, final String message) {
         final Bulletin bulletin = new MockBulletin(currentId.getAndIncrement());
         bulletin.setCategory(category);

http://git-wip-us.apache.org/repos/asf/nifi/blob/50d01856/nifi-mock/src/main/java/org/apache/nifi/util/MockReportingContext.java
----------------------------------------------------------------------
diff --git a/nifi-mock/src/main/java/org/apache/nifi/util/MockReportingContext.java b/nifi-mock/src/main/java/org/apache/nifi/util/MockReportingContext.java
index f65bc3e..b9e23c3 100644
--- a/nifi-mock/src/main/java/org/apache/nifi/util/MockReportingContext.java
+++ b/nifi-mock/src/main/java/org/apache/nifi/util/MockReportingContext.java
@@ -100,7 +100,7 @@ public class MockReportingContext extends MockControllerServiceLookup implements
 
     @Override
     public Bulletin createBulletin(final String componentId, final String category, final Severity severity, final String message) {
-        final Bulletin bulletin = BulletinFactory.createBulletin(null, componentId, "test processor", category, severity.name(), message);
+        final Bulletin bulletin = BulletinFactory.createBulletin(null, null, componentId, "test processor", category, severity.name(), message);
         List<Bulletin> bulletins = componentBulletinsCreated.get(componentId);
         if (bulletins == null) {
             bulletins = new ArrayList<>();

http://git-wip-us.apache.org/repos/asf/nifi/blob/50d01856/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/events/BulletinFactory.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/events/BulletinFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/events/BulletinFactory.java
index 0bd2500..eb00402 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/events/BulletinFactory.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/events/BulletinFactory.java
@@ -48,7 +48,8 @@ public final class BulletinFactory {
 
         final ProcessGroup group = connectable.getProcessGroup();
         final String groupId = group == null ? null : group.getIdentifier();
-        return BulletinFactory.createBulletin(groupId, connectable.getIdentifier(), type, connectable.getName(), category, severity, message);
+        final String groupName = group == null ? null : group.getName();
+        return BulletinFactory.createBulletin(groupId, groupName, connectable.getIdentifier(), type, connectable.getName(), category, severity, message);
     }
 
     public static Bulletin createBulletin(final String groupId, final String sourceId, final ComponentType sourceType, final String sourceName,
@@ -64,6 +65,20 @@ public final class BulletinFactory {
         return bulletin;
     }
 
+    public static Bulletin createBulletin(final String groupId, final String groupName, final String sourceId, final ComponentType sourceType,
+            final String sourceName, final String category, final String severity, final String message) {
+        final Bulletin bulletin = new ComponentBulletin(currentId.getAndIncrement());
+        bulletin.setGroupId(groupId);
+        bulletin.setGroupName(groupName);
+        bulletin.setSourceId(sourceId);
+        bulletin.setSourceType(sourceType);
+        bulletin.setSourceName(sourceName);
+        bulletin.setCategory(category);
+        bulletin.setLevel(severity);
+        bulletin.setMessage(message);
+        return bulletin;
+    }
+
     public static Bulletin createBulletin(final String category, final String severity, final String message) {
         final Bulletin bulletin = new SystemBulletin(currentId.getAndIncrement());
         bulletin.setCategory(category);

http://git-wip-us.apache.org/repos/asf/nifi/blob/50d01856/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/jaxb/AdaptedBulletin.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/jaxb/AdaptedBulletin.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/jaxb/AdaptedBulletin.java
index 17c5991..9fc0626 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/jaxb/AdaptedBulletin.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/jaxb/AdaptedBulletin.java
@@ -32,6 +32,7 @@ public class AdaptedBulletin {
     private String message;
 
     private String groupId;
+    private String groupName;
     private String sourceId;
     private String sourceName;
     private ComponentType sourceType;
@@ -52,6 +53,14 @@ public class AdaptedBulletin {
         this.groupId = groupId;
     }
 
+    public String getGroupName() {
+        return groupName;
+    }
+
+    public void setGroupName(String groupName) {
+        this.groupName = groupName;
+    }
+
     public long getId() {
         return id;
     }

http://git-wip-us.apache.org/repos/asf/nifi/blob/50d01856/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/jaxb/BulletinAdapter.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/jaxb/BulletinAdapter.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/jaxb/BulletinAdapter.java
index acbe0dd..5f3fb94 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/jaxb/BulletinAdapter.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/jaxb/BulletinAdapter.java
@@ -34,7 +34,8 @@ public class BulletinAdapter extends XmlAdapter<AdaptedBulletin, Bulletin> {
         if (b.getSourceId() == null) {
             return BulletinFactory.createBulletin(b.getCategory(), b.getLevel(), b.getMessage());
         } else {
-            return BulletinFactory.createBulletin(b.getGroupId(), b.getSourceId(), b.getSourceType(), b.getSourceName(), b.getCategory(), b.getLevel(), b.getMessage());
+            return BulletinFactory.createBulletin(b.getGroupId(), b.getGroupName(), b.getSourceId(), b.getSourceType(),
+                    b.getSourceName(), b.getCategory(), b.getLevel(), b.getMessage());
         }
     }
 
@@ -47,6 +48,7 @@ public class BulletinAdapter extends XmlAdapter<AdaptedBulletin, Bulletin> {
         aBulletin.setId(b.getId());
         aBulletin.setTimestamp(b.getTimestamp());
         aBulletin.setGroupId(b.getGroupId());
+        aBulletin.setGroupName(b.getGroupName());
         aBulletin.setSourceId(b.getSourceId());
         aBulletin.setSourceType(b.getSourceType());
         aBulletin.setSourceName(b.getSourceName());

http://git-wip-us.apache.org/repos/asf/nifi/blob/50d01856/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/logging/ControllerServiceLogObserver.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/logging/ControllerServiceLogObserver.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/logging/ControllerServiceLogObserver.java
index 3ea432d..b245904 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/logging/ControllerServiceLogObserver.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/logging/ControllerServiceLogObserver.java
@@ -18,6 +18,7 @@ package org.apache.nifi.logging;
 
 import org.apache.nifi.controller.service.ControllerServiceNode;
 import org.apache.nifi.events.BulletinFactory;
+import org.apache.nifi.groups.ProcessGroup;
 import org.apache.nifi.reporting.Bulletin;
 import org.apache.nifi.reporting.BulletinRepository;
 import org.apache.nifi.reporting.ComponentType;
@@ -39,7 +40,11 @@ public class ControllerServiceLogObserver implements LogObserver {
         // the LogLevel is (INFO and ERROR map directly and all others we will just accept as they are).
         final String bulletinLevel = message.getLevel() == LogLevel.WARN ? Severity.WARNING.name() : message.getLevel().toString();
 
-        final Bulletin bulletin = BulletinFactory.createBulletin(null, serviceNode.getIdentifier(), ComponentType.CONTROLLER_SERVICE,
+        final ProcessGroup pg = serviceNode.getProcessGroup();
+        final String groupId = pg == null ? null : pg.getIdentifier();
+        final String groupName = pg == null ? null : pg.getName();
+
+        final Bulletin bulletin = BulletinFactory.createBulletin(groupId, groupName, serviceNode.getIdentifier(), ComponentType.CONTROLLER_SERVICE,
                 serviceNode.getName(), "Log Message", bulletinLevel, message.getMessage());
         bulletinRepository.addBulletin(bulletin);
     }

http://git-wip-us.apache.org/repos/asf/nifi/blob/50d01856/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/remote/StandardRemoteProcessGroup.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/remote/StandardRemoteProcessGroup.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/remote/StandardRemoteProcessGroup.java
index ff5e752..3080195 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/remote/StandardRemoteProcessGroup.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/remote/StandardRemoteProcessGroup.java
@@ -164,9 +164,10 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup {
             @Override
             public void reportEvent(final Severity severity, final String category, final String message) {
                 final String groupId = StandardRemoteProcessGroup.this.getProcessGroup().getIdentifier();
+                final String groupName = StandardRemoteProcessGroup.this.getProcessGroup().getName();
                 final String sourceId = StandardRemoteProcessGroup.this.getIdentifier();
                 final String sourceName = StandardRemoteProcessGroup.this.getName();
-                bulletinRepository.addBulletin(BulletinFactory.createBulletin(groupId, sourceId, ComponentType.REMOTE_PROCESS_GROUP,
+                bulletinRepository.addBulletin(BulletinFactory.createBulletin(groupId, groupName, sourceId, ComponentType.REMOTE_PROCESS_GROUP,
                         sourceName, category, severity.name(), message));
             }
         };

http://git-wip-us.apache.org/repos/asf/nifi/blob/50d01856/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/StandardRootGroupPort.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/StandardRootGroupPort.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/StandardRootGroupPort.java
index ee16406..27f9d9c 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/StandardRootGroupPort.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/StandardRootGroupPort.java
@@ -117,10 +117,11 @@ public class StandardRootGroupPort extends AbstractPort implements RootGroupPort
             @Override
             public void reportEvent(final Severity severity, final String category, final String message) {
                 final String groupId = StandardRootGroupPort.this.getProcessGroup().getIdentifier();
+                final String groupName = StandardRootGroupPort.this.getProcessGroup().getName();
                 final String sourceId = StandardRootGroupPort.this.getIdentifier();
                 final String sourceName = StandardRootGroupPort.this.getName();
                 final ComponentType componentType = direction == TransferDirection.RECEIVE ? ComponentType.INPUT_PORT : ComponentType.OUTPUT_PORT;
-                bulletinRepository.addBulletin(BulletinFactory.createBulletin(groupId, sourceId, componentType, sourceName, category, severity.name(), message));
+                bulletinRepository.addBulletin(BulletinFactory.createBulletin(groupId, groupName, sourceId, componentType, sourceName, category, severity.name(), message));
             }
         };
 

http://git-wip-us.apache.org/repos/asf/nifi/blob/50d01856/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/SiteToSiteBulletinReportingTask.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/SiteToSiteBulletinReportingTask.java b/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/SiteToSiteBulletinReportingTask.java
index b829c1e..27c8649 100644
--- a/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/SiteToSiteBulletinReportingTask.java
+++ b/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/SiteToSiteBulletinReportingTask.java
@@ -192,6 +192,7 @@ public class SiteToSiteBulletinReportingTask extends AbstractSiteToSiteReporting
         addField(builder, "bulletinId", bulletin.getId());
         addField(builder, "bulletinCategory", bulletin.getCategory());
         addField(builder, "bulletinGroupId", bulletin.getGroupId());
+        addField(builder, "bulletinGroupName", bulletin.getGroupName());
         addField(builder, "bulletinLevel", bulletin.getLevel());
         addField(builder, "bulletinMessage", bulletin.getMessage());
         addField(builder, "bulletinNodeAddress", bulletin.getNodeAddress());

http://git-wip-us.apache.org/repos/asf/nifi/blob/50d01856/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/test/java/org/apache/nifi/reporting/TestSiteToSiteBulletinReportingTask.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/test/java/org/apache/nifi/reporting/TestSiteToSiteBulletinReportingTask.java b/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/test/java/org/apache/nifi/reporting/TestSiteToSiteBulletinReportingTask.java
index d247a4e..b15110d 100644
--- a/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/test/java/org/apache/nifi/reporting/TestSiteToSiteBulletinReportingTask.java
+++ b/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/test/java/org/apache/nifi/reporting/TestSiteToSiteBulletinReportingTask.java
@@ -54,7 +54,7 @@ public class TestSiteToSiteBulletinReportingTask {
     public void testSerializedForm() throws IOException, InitializationException {
         // creating the list of bulletins
         final List<Bulletin> bulletins = new ArrayList<Bulletin>();
-        bulletins.add(BulletinFactory.createBulletin("category", "severity", "message"));
+        bulletins.add(BulletinFactory.createBulletin("group-id", "group-name", "source-id", "source-name", "category", "severity", "message"));
 
         // mock the access to the list of bulletins
         final ReportingContext context = Mockito.mock(ReportingContext.class);
@@ -97,6 +97,7 @@ public class TestSiteToSiteBulletinReportingTask {
         JsonReader jsonReader = Json.createReader(new ByteArrayInputStream(msg.getBytes()));
         JsonObject bulletinJson = jsonReader.readArray().getJsonObject(0);
         assertEquals("message", bulletinJson.getString("bulletinMessage"));
+        assertEquals("group-name", bulletinJson.getString("bulletinGroupName"));
     }
 
     @Test