Java Code Examples for org.apache.nifi.reporting.BulletinQuery#getGroupIdPattern()
The following examples show how to use
org.apache.nifi.reporting.BulletinQuery#getGroupIdPattern() .
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 | 4 votes |
@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 2
Source File: VolatileBulletinRepository.java From nifi with Apache License 2.0 | 4 votes |
@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); }