Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIFI-7210 - added PG path in bulletins for S2S Bulletin RT #4100

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public abstract class Bulletin implements Comparable<Bulletin> {

private String groupId;
private String groupName;
private String groupPath;
private String sourceId;
private String sourceName;
private ComponentType sourceType;
Expand Down Expand Up @@ -98,6 +99,14 @@ public void setGroupName(String groupName) {
this.groupName = groupName;
}

public String getGroupPath() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add this to the BULLETINS table in the sql-reporting bundle too? Would be helpful for queries.

return groupPath;
}

public void setGroupPath(String groupPath) {
this.groupPath = groupPath;
}

public String getSourceId() {
return sourceId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,19 @@ public static Bulletin createBulletin(final String category, final String severi
bulletin.setMessage(message);
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 String groupPath) {
final Bulletin bulletin = new MockBulletin(currentId.getAndIncrement());
bulletin.setGroupId(groupId);
bulletin.setGroupName(groupName);
bulletin.setGroupPath(groupPath);
bulletin.setSourceId(sourceId);
bulletin.setSourceType(sourceType);
bulletin.setSourceName(sourceName);
bulletin.setCategory(category);
bulletin.setLevel(severity);
bulletin.setMessage(message);
return bulletin;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,22 @@ public static Bulletin createBulletin(final Connectable connectable, final Strin
final ProcessGroup group = connectable.getProcessGroup();
final String groupId = connectable.getProcessGroupIdentifier();
final String groupName = group == null ? null : group.getName();
return BulletinFactory.createBulletin(groupId, groupName, connectable.getIdentifier(), type, connectable.getName(), category, severity, message);
final String groupPath = buildGroupPath(group);
return BulletinFactory.createBulletin(groupId, groupName, connectable.getIdentifier(), type, connectable.getName(), category, severity, message, groupPath);
}

private static String buildGroupPath(ProcessGroup group) {
if(group == null) {
return null;
} else {
String path = group.getName();
ProcessGroup parent = group.getParent();
while(parent != null) {
path = parent.getName() + " / " + path;
parent = parent.getParent();
}
return path;
}
}

public static Bulletin createBulletin(final String groupId, final String sourceId, final ComponentType sourceType, final String sourceName,
Expand Down Expand Up @@ -79,6 +94,21 @@ public static Bulletin createBulletin(final String groupId, final String groupNa
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 String groupPath) {
final Bulletin bulletin = new ComponentBulletin(currentId.getAndIncrement());
bulletin.setGroupId(groupId);
bulletin.setGroupName(groupName);
bulletin.setGroupPath(groupPath);
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ private JsonObject serialize(final JsonBuilderFactory factory, final JsonObjectB
addField(builder, "bulletinCategory", bulletin.getCategory(), allowNullValues);
addField(builder, "bulletinGroupId", bulletin.getGroupId(), allowNullValues);
addField(builder, "bulletinGroupName", bulletin.getGroupName(), allowNullValues);
addField(builder, "bulletinGroupPath", bulletin.getGroupPath(), allowNullValues);
addField(builder, "bulletinLevel", bulletin.getLevel(), allowNullValues);
addField(builder, "bulletinMessage", bulletin.getMessage(), allowNullValues);
addField(builder, "bulletinNodeAddress", bulletin.getNodeAddress(), allowNullValues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ <h2>Record writer</h2>
{ "name" : "bulletinCategory", "type" : ["string", "null"] },
{ "name" : "bulletinGroupId", "type" : ["string", "null"] },
{ "name" : "bulletinGroupName", "type" : ["string", "null"] },
{ "name" : "bulletinGroupPath", "type" : ["string", "null"] },
{ "name" : "bulletinLevel", "type" : ["string", "null"] },
{ "name" : "bulletinMessage", "type" : ["string", "null"] },
{ "name" : "bulletinNodeAddress", "type" : ["string", "null"] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{ "name" : "bulletinCategory", "type" : ["string", "null"] },
{ "name" : "bulletinGroupId", "type" : ["string", "null"] },
{ "name" : "bulletinGroupName", "type" : ["string", "null"] },
{ "name" : "bulletinGroupPath", "type" : ["string", "null"] },
{ "name" : "bulletinLevel", "type" : ["string", "null"] },
{ "name" : "bulletinMessage", "type" : ["string", "null"] },
{ "name" : "bulletinNodeAddress", "type" : ["string", "null"] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -82,7 +81,7 @@ public PropertyValue answer(InvocationOnMock invocation) throws Throwable {
public void testSerializedForm() throws IOException, InitializationException {
// creating the list of bulletins
final List<Bulletin> bulletins = new ArrayList<Bulletin>();
bulletins.add(BulletinFactory.createBulletin("group-id", "group-name", "source-id", "source-name", "category", "severity", "message"));
bulletins.add(BulletinFactory.createBulletin("group-id", "group-name", "source-id", ComponentType.PROCESSOR, "source-name", "category", "severity", "message", "group-path"));

// mock the access to the list of bulletins
final ReportingContext context = Mockito.mock(ReportingContext.class);
Expand Down Expand Up @@ -125,7 +124,7 @@ public PropertyValue answer(final InvocationOnMock invocation) throws Throwable
JsonObject bulletinJson = jsonReader.readArray().getJsonObject(0);
assertEquals("message", bulletinJson.getString("bulletinMessage"));
assertEquals("group-name", bulletinJson.getString("bulletinGroupName"));
assertNull(bulletinJson.get("bulletinSourceType"));
assertEquals("group-path", bulletinJson.getString("bulletinGroupPath"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private Object filterColumns(final Bulletin bulletin) {
bulletin.getCategory(),
bulletin.getGroupId(),
bulletin.getGroupName(),
bulletin.getGroupPath(),
bulletin.getLevel(),
bulletin.getMessage(),
bulletin.getNodeAddress(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public RelDataType getRowType(final RelDataTypeFactory typeFactory) {
"bulletinCategory",
"bulletinGroupId",
"bulletinGroupName",
"bulletinGroupPath",
"bulletinLevel",
"bulletinMessage",
"bulletinNodeAddress",
Expand All @@ -178,6 +179,7 @@ public RelDataType getRowType(final RelDataTypeFactory typeFactory) {
typeFactory.createJavaType(String.class),
typeFactory.createJavaType(String.class),
typeFactory.createJavaType(String.class),
typeFactory.createJavaType(String.class),
typeFactory.createJavaType(Date.class)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ <h3>BULLETINS</h3>
<tr><td>bulletinCategory</td><td>String</td></tr>
<tr><td>bulletinGroupId</td><td>String</td></tr>
<tr><td>bulletinGroupName</td><td>String</td></tr>
<tr><td>bulletinGroupPath</td><td>String</td></tr>
<tr><td>bulletinLevel</td><td>String</td></tr>
<tr><td>bulletinMessage</td><td>String</td></tr>
<tr><td>bulletinNodeAddress</td><td>String</td></tr>
Expand Down