mirror of https://github.com/apache/nifi.git
NIFI-4403 - add group name to bulletins model. This closes #2167
This commit is contained in:
parent
0c0c33411d
commit
50d018566d
|
@ -32,6 +32,7 @@ public abstract class Bulletin implements Comparable<Bulletin> {
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
private String groupId;
|
private String groupId;
|
||||||
|
private String groupName;
|
||||||
private String sourceId;
|
private String sourceId;
|
||||||
private String sourceName;
|
private String sourceName;
|
||||||
private ComponentType sourceType;
|
private ComponentType sourceType;
|
||||||
|
@ -89,6 +90,14 @@ public abstract class Bulletin implements Comparable<Bulletin> {
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getGroupName() {
|
||||||
|
return groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupName(String groupName) {
|
||||||
|
this.groupName = groupName;
|
||||||
|
}
|
||||||
|
|
||||||
public String getSourceId() {
|
public String getSourceId() {
|
||||||
return sourceId;
|
return sourceId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,19 @@ public class BulletinFactory {
|
||||||
return bulletin;
|
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) {
|
public static Bulletin createBulletin(final String category, final String severity, final String message) {
|
||||||
final Bulletin bulletin = new MockBulletin(currentId.getAndIncrement());
|
final Bulletin bulletin = new MockBulletin(currentId.getAndIncrement());
|
||||||
bulletin.setCategory(category);
|
bulletin.setCategory(category);
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class MockReportingContext extends MockControllerServiceLookup implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Bulletin createBulletin(final String componentId, final String category, final Severity severity, final String message) {
|
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);
|
List<Bulletin> bulletins = componentBulletinsCreated.get(componentId);
|
||||||
if (bulletins == null) {
|
if (bulletins == null) {
|
||||||
bulletins = new ArrayList<>();
|
bulletins = new ArrayList<>();
|
||||||
|
|
|
@ -48,7 +48,8 @@ public final class BulletinFactory {
|
||||||
|
|
||||||
final ProcessGroup group = connectable.getProcessGroup();
|
final ProcessGroup group = connectable.getProcessGroup();
|
||||||
final String groupId = group == null ? null : group.getIdentifier();
|
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,
|
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;
|
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) {
|
public static Bulletin createBulletin(final String category, final String severity, final String message) {
|
||||||
final Bulletin bulletin = new SystemBulletin(currentId.getAndIncrement());
|
final Bulletin bulletin = new SystemBulletin(currentId.getAndIncrement());
|
||||||
bulletin.setCategory(category);
|
bulletin.setCategory(category);
|
||||||
|
|
|
@ -32,6 +32,7 @@ public class AdaptedBulletin {
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
private String groupId;
|
private String groupId;
|
||||||
|
private String groupName;
|
||||||
private String sourceId;
|
private String sourceId;
|
||||||
private String sourceName;
|
private String sourceName;
|
||||||
private ComponentType sourceType;
|
private ComponentType sourceType;
|
||||||
|
@ -52,6 +53,14 @@ public class AdaptedBulletin {
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getGroupName() {
|
||||||
|
return groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupName(String groupName) {
|
||||||
|
this.groupName = groupName;
|
||||||
|
}
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ public class BulletinAdapter extends XmlAdapter<AdaptedBulletin, Bulletin> {
|
||||||
if (b.getSourceId() == null) {
|
if (b.getSourceId() == null) {
|
||||||
return BulletinFactory.createBulletin(b.getCategory(), b.getLevel(), b.getMessage());
|
return BulletinFactory.createBulletin(b.getCategory(), b.getLevel(), b.getMessage());
|
||||||
} else {
|
} 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.setId(b.getId());
|
||||||
aBulletin.setTimestamp(b.getTimestamp());
|
aBulletin.setTimestamp(b.getTimestamp());
|
||||||
aBulletin.setGroupId(b.getGroupId());
|
aBulletin.setGroupId(b.getGroupId());
|
||||||
|
aBulletin.setGroupName(b.getGroupName());
|
||||||
aBulletin.setSourceId(b.getSourceId());
|
aBulletin.setSourceId(b.getSourceId());
|
||||||
aBulletin.setSourceType(b.getSourceType());
|
aBulletin.setSourceType(b.getSourceType());
|
||||||
aBulletin.setSourceName(b.getSourceName());
|
aBulletin.setSourceName(b.getSourceName());
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.nifi.logging;
|
||||||
|
|
||||||
import org.apache.nifi.controller.service.ControllerServiceNode;
|
import org.apache.nifi.controller.service.ControllerServiceNode;
|
||||||
import org.apache.nifi.events.BulletinFactory;
|
import org.apache.nifi.events.BulletinFactory;
|
||||||
|
import org.apache.nifi.groups.ProcessGroup;
|
||||||
import org.apache.nifi.reporting.Bulletin;
|
import org.apache.nifi.reporting.Bulletin;
|
||||||
import org.apache.nifi.reporting.BulletinRepository;
|
import org.apache.nifi.reporting.BulletinRepository;
|
||||||
import org.apache.nifi.reporting.ComponentType;
|
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).
|
// 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 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());
|
serviceNode.getName(), "Log Message", bulletinLevel, message.getMessage());
|
||||||
bulletinRepository.addBulletin(bulletin);
|
bulletinRepository.addBulletin(bulletin);
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,9 +164,10 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup {
|
||||||
@Override
|
@Override
|
||||||
public void reportEvent(final Severity severity, final String category, final String message) {
|
public void reportEvent(final Severity severity, final String category, final String message) {
|
||||||
final String groupId = StandardRemoteProcessGroup.this.getProcessGroup().getIdentifier();
|
final String groupId = StandardRemoteProcessGroup.this.getProcessGroup().getIdentifier();
|
||||||
|
final String groupName = StandardRemoteProcessGroup.this.getProcessGroup().getName();
|
||||||
final String sourceId = StandardRemoteProcessGroup.this.getIdentifier();
|
final String sourceId = StandardRemoteProcessGroup.this.getIdentifier();
|
||||||
final String sourceName = StandardRemoteProcessGroup.this.getName();
|
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));
|
sourceName, category, severity.name(), message));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -117,10 +117,11 @@ public class StandardRootGroupPort extends AbstractPort implements RootGroupPort
|
||||||
@Override
|
@Override
|
||||||
public void reportEvent(final Severity severity, final String category, final String message) {
|
public void reportEvent(final Severity severity, final String category, final String message) {
|
||||||
final String groupId = StandardRootGroupPort.this.getProcessGroup().getIdentifier();
|
final String groupId = StandardRootGroupPort.this.getProcessGroup().getIdentifier();
|
||||||
|
final String groupName = StandardRootGroupPort.this.getProcessGroup().getName();
|
||||||
final String sourceId = StandardRootGroupPort.this.getIdentifier();
|
final String sourceId = StandardRootGroupPort.this.getIdentifier();
|
||||||
final String sourceName = StandardRootGroupPort.this.getName();
|
final String sourceName = StandardRootGroupPort.this.getName();
|
||||||
final ComponentType componentType = direction == TransferDirection.RECEIVE ? ComponentType.INPUT_PORT : ComponentType.OUTPUT_PORT;
|
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));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -192,6 +192,7 @@ public class SiteToSiteBulletinReportingTask extends AbstractSiteToSiteReporting
|
||||||
addField(builder, "bulletinId", bulletin.getId());
|
addField(builder, "bulletinId", bulletin.getId());
|
||||||
addField(builder, "bulletinCategory", bulletin.getCategory());
|
addField(builder, "bulletinCategory", bulletin.getCategory());
|
||||||
addField(builder, "bulletinGroupId", bulletin.getGroupId());
|
addField(builder, "bulletinGroupId", bulletin.getGroupId());
|
||||||
|
addField(builder, "bulletinGroupName", bulletin.getGroupName());
|
||||||
addField(builder, "bulletinLevel", bulletin.getLevel());
|
addField(builder, "bulletinLevel", bulletin.getLevel());
|
||||||
addField(builder, "bulletinMessage", bulletin.getMessage());
|
addField(builder, "bulletinMessage", bulletin.getMessage());
|
||||||
addField(builder, "bulletinNodeAddress", bulletin.getNodeAddress());
|
addField(builder, "bulletinNodeAddress", bulletin.getNodeAddress());
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class TestSiteToSiteBulletinReportingTask {
|
||||||
public void testSerializedForm() throws IOException, InitializationException {
|
public void testSerializedForm() throws IOException, InitializationException {
|
||||||
// creating the list of bulletins
|
// creating the list of bulletins
|
||||||
final List<Bulletin> bulletins = new ArrayList<Bulletin>();
|
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
|
// mock the access to the list of bulletins
|
||||||
final ReportingContext context = Mockito.mock(ReportingContext.class);
|
final ReportingContext context = Mockito.mock(ReportingContext.class);
|
||||||
|
@ -97,6 +97,7 @@ public class TestSiteToSiteBulletinReportingTask {
|
||||||
JsonReader jsonReader = Json.createReader(new ByteArrayInputStream(msg.getBytes()));
|
JsonReader jsonReader = Json.createReader(new ByteArrayInputStream(msg.getBytes()));
|
||||||
JsonObject bulletinJson = jsonReader.readArray().getJsonObject(0);
|
JsonObject bulletinJson = jsonReader.readArray().getJsonObject(0);
|
||||||
assertEquals("message", bulletinJson.getString("bulletinMessage"));
|
assertEquals("message", bulletinJson.getString("bulletinMessage"));
|
||||||
|
assertEquals("group-name", bulletinJson.getString("bulletinGroupName"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue