Java Code Examples for org.apache.nifi.reporting.Bulletin#getGroupId()

The following examples show how to use org.apache.nifi.reporting.Bulletin#getGroupId() . 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: VolatileBulletinRepository.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private String getBulletinStoreKey(final Bulletin bulletin) {
    switch (bulletin.getSourceType()) {
        case FLOW_CONTROLLER:
            return CONTROLLER_BULLETIN_STORE_KEY;
        case CONTROLLER_SERVICE:
            return SERVICE_BULLETIN_STORE_KEY;
        case REPORTING_TASK:
            return REPORTING_TASK_BULLETIN_STORE_KEY;
        default:
            return bulletin.getGroupId();
    }
}
 
Example 2
Source File: VolatileBulletinRepository.java    From nifi with Apache License 2.0 5 votes vote down vote up
private String getBulletinStoreKey(final Bulletin bulletin) {
    switch (bulletin.getSourceType()) {
        case FLOW_CONTROLLER:
            return CONTROLLER_BULLETIN_STORE_KEY;
        case CONTROLLER_SERVICE:
            return SERVICE_BULLETIN_STORE_KEY;
        case REPORTING_TASK:
            return REPORTING_TASK_BULLETIN_STORE_KEY;
        default:
            return bulletin.getGroupId();
    }
}
 
Example 3
Source File: VolatileBulletinRepository.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Override
public List<Bulletin> findBulletins(final BulletinQuery bulletinQuery) {
    final Filter<Bulletin> filter = new Filter<Bulletin>() {
        @Override
        public boolean select(final Bulletin bulletin) {
            final long fiveMinutesAgo = System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(5);
            if (bulletin.getTimestamp().getTime() < fiveMinutesAgo) {
                return false;
            }

            // only include bulletins after the specified id
            if (bulletinQuery.getAfter() != null && bulletin.getId() <= bulletinQuery.getAfter()) {
                return false;
            }

            // if group pattern was specified see if it should be excluded
            if (bulletinQuery.getGroupIdPattern() != null) {
                // exclude if this bulletin doesnt have a group or if it doesnt match
                if (bulletin.getGroupId() == null || !bulletinQuery.getGroupIdPattern().matcher(bulletin.getGroupId()).find()) {
                    return false;
                }
            }

            // if a message pattern was specified see if it should be excluded
            if (bulletinQuery.getMessagePattern() != null) {
                // exclude if this bulletin doesnt have a message or if it doesnt match
                if (bulletin.getMessage() == null || !bulletinQuery.getMessagePattern().matcher(bulletin.getMessage()).find()) {
                    return false;
                }
            }

            // if a name pattern was specified see if it should be excluded
            if (bulletinQuery.getNamePattern() != null) {
                // exclude if this bulletin doesnt have a source name or if it doesnt match
                if (bulletin.getSourceName() == null || !bulletinQuery.getNamePattern().matcher(bulletin.getSourceName()).find()) {
                    return false;
                }
            }

            // if a source id was specified see if it should be excluded
            if (bulletinQuery.getSourceIdPattern() != null) {
                // exclude if this bulletin doesn't have a source id or if it doesn't match
                if (bulletin.getSourceId() == null || !bulletinQuery.getSourceIdPattern().matcher(bulletin.getSourceId()).find()) {
                    return false;
                }
            }

            // if a source component type was specified see if it should be excluded
            if (bulletinQuery.getSourceType() != null) {
                // exclude if this bulletin source type doesn't match
                if (bulletin.getSourceType() == null || !bulletinQuery.getSourceType().equals(bulletin.getSourceType())) {
                    return false;
                }
            }

            return true;
        }
    };

    final List<Bulletin> selected = new ArrayList<>();
    int max = bulletinQuery.getLimit() == null ? Integer.MAX_VALUE : bulletinQuery.getLimit();

    for (final ConcurrentMap<String, RingBuffer<Bulletin>> componentMap : bulletinStoreMap.values()) {
        for (final RingBuffer<Bulletin> ringBuffer : componentMap.values()) {
            final List<Bulletin> bulletinsForComponent = ringBuffer.getSelectedElements(filter, max);
            selected.addAll(bulletinsForComponent);
            max -= bulletinsForComponent.size();
            if (max <= 0) {
                break;
            }
        }
    }

    // sort by descending ID
    Collections.sort(selected);

    return selected;
}
 
Example 4
Source File: BulletinEnumerator.java    From nifi with Apache License 2.0 4 votes vote down vote up
private Object filterColumns(final Bulletin bulletin) {
    if (bulletin == null) {
        return null;
    }

    final boolean isClustered = context.isClustered();
    String nodeId = context.getClusterNodeIdentifier();
    if (nodeId == null && isClustered) {
        nodeId = "unknown";
    }

    final Object[] row = new Object[]{
            bulletin.getId(),
            bulletin.getCategory(),
            bulletin.getGroupId(),
            bulletin.getGroupName(),
            bulletin.getGroupPath(),
            bulletin.getLevel(),
            bulletin.getMessage(),
            bulletin.getNodeAddress(),
            nodeId,
            bulletin.getSourceId(),
            bulletin.getSourceName(),
            bulletin.getSourceType().name(),
            bulletin.getTimestamp()
    };

    // If we want no fields just return null
    if (fields == null) {
        return row;
    }

    // If we want only a single field, then Calcite is going to expect us to return
    // the actual value, NOT a 1-element array of values.
    if (fields.length == 1) {
        final int desiredCellIndex = fields[0];
        return row[desiredCellIndex];
    }

    // Create a new Object array that contains only the desired fields.
    final Object[] filtered = new Object[fields.length];
    for (int i = 0; i < fields.length; i++) {
        final int indexToKeep = fields[i];
        filtered[i] = row[indexToKeep];
    }

    return filtered;
}
 
Example 5
Source File: VolatileBulletinRepository.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public List<Bulletin> findBulletins(final BulletinQuery bulletinQuery) {
    final Filter<Bulletin> filter = new Filter<Bulletin>() {
        @Override
        public boolean select(final Bulletin bulletin) {
            final long fiveMinutesAgo = System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(5);
            if (bulletin.getTimestamp().getTime() < fiveMinutesAgo) {
                return false;
            }

            // only include bulletins after the specified id
            if (bulletinQuery.getAfter() != null && bulletin.getId() <= bulletinQuery.getAfter()) {
                return false;
            }

            // if group pattern was specified see if it should be excluded
            if (bulletinQuery.getGroupIdPattern() != null) {
                // exclude if this bulletin doesnt have a group or if it doesnt match
                if (bulletin.getGroupId() == null || !bulletinQuery.getGroupIdPattern().matcher(bulletin.getGroupId()).find()) {
                    return false;
                }
            }

            // if a message pattern was specified see if it should be excluded
            if (bulletinQuery.getMessagePattern() != null) {
                // exclude if this bulletin doesnt have a message or if it doesnt match
                if (bulletin.getMessage() == null || !bulletinQuery.getMessagePattern().matcher(bulletin.getMessage()).find()) {
                    return false;
                }
            }

            // if a name pattern was specified see if it should be excluded
            if (bulletinQuery.getNamePattern() != null) {
                // exclude if this bulletin doesnt have a source name or if it doesnt match
                if (bulletin.getSourceName() == null || !bulletinQuery.getNamePattern().matcher(bulletin.getSourceName()).find()) {
                    return false;
                }
            }

            // if a source id was specified see if it should be excluded
            if (bulletinQuery.getSourceIdPattern() != null) {
                // exclude if this bulletin doesn't have a source id or if it doesn't match
                if (bulletin.getSourceId() == null || !bulletinQuery.getSourceIdPattern().matcher(bulletin.getSourceId()).find()) {
                    return false;
                }
            }

            // if a source component type was specified see if it should be excluded
            if (bulletinQuery.getSourceType() != null) {
                // exclude if this bulletin source type doesn't match
                if (bulletin.getSourceType() == null || !bulletinQuery.getSourceType().equals(bulletin.getSourceType())) {
                    return false;
                }
            }

            return true;
        }
    };

    final Set<Bulletin> selected = new TreeSet<>();
    int max = bulletinQuery.getLimit() == null ? Integer.MAX_VALUE : bulletinQuery.getLimit();

    for (final ConcurrentMap<String, RingBuffer<Bulletin>> componentMap : bulletinStoreMap.values()) {
        for (final RingBuffer<Bulletin> ringBuffer : componentMap.values()) {
            final List<Bulletin> bulletinsForComponent = ringBuffer.getSelectedElements(filter, max);
            selected.addAll(bulletinsForComponent);
            max -= bulletinsForComponent.size();
            if (max <= 0) {
                break;
            }
        }
    }

    return new ArrayList<>(selected);
}