Java Code Examples for org.apache.nifi.groups.ProcessGroup#getName()

The following examples show how to use org.apache.nifi.groups.ProcessGroup#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BulletinFactory.java    From nifi with Apache License 2.0 6 votes vote down vote up
public static Bulletin createBulletin(final Connectable connectable, final String category, final String severity, final String message) {
    final ComponentType type;
    switch (connectable.getConnectableType()) {
        case REMOTE_INPUT_PORT:
        case REMOTE_OUTPUT_PORT:
            type = ComponentType.REMOTE_PROCESS_GROUP;
            break;
        case INPUT_PORT:
            type = ComponentType.INPUT_PORT;
            break;
        case OUTPUT_PORT:
            type = ComponentType.OUTPUT_PORT;
            break;
        case PROCESSOR:
        default:
            type = ComponentType.PROCESSOR;
            break;
    }

    final ProcessGroup group = connectable.getProcessGroup();
    final String groupId = connectable.getProcessGroupIdentifier();
    final String groupName = group == null ? null : group.getName();
    final String groupPath = buildGroupPath(group);
    return BulletinFactory.createBulletin(groupId, groupName, connectable.getIdentifier(), type, connectable.getName(), category, severity, message, groupPath);
}
 
Example 2
Source File: BulletinFactory.java    From nifi with Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example 3
Source File: ControllerServiceLogObserver.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void onLogMessage(final LogMessage message) {
    // Map LogLevel.WARN to Severity.WARNING so that we are consistent with the Severity enumeration. Else, just use whatever
    // 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 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);
}