Search in sources :

Example 1 with AggregatedFeedProcessorStatisticsV2

use of com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedFeedProcessorStatisticsV2 in project kylo by Teradata.

the class GroupedStatsUtil method groupStatsByProcessor.

/**
 * Group stats together by processor for a given feed
 *
 * @param feedName     feed name
 * @param groupedStats Map of processorIdentity to list of stats for that processor
 */
public static AggregatedFeedProcessorStatistics groupStatsByProcessor(String feedName, Map<GroupedStatsIdentity, List<GroupedStats>> groupedStats) {
    Long sendJmsTimeMillis = 3000L;
    String collectionId = UUID.randomUUID().toString();
    // Create a random id for the starting processor.
    // the starting feed processor id is not needed as we already know the feed name associated with these stats
    String startingProcessorId = UUID.randomUUID().toString();
    AggregatedFeedProcessorStatisticsV2 feedProcessorStatistics = new AggregatedFeedProcessorStatisticsV2(startingProcessorId, collectionId, sendJmsTimeMillis);
    feedProcessorStatistics.setFeedName(feedName);
    for (Map.Entry<GroupedStatsIdentity, List<GroupedStats>> stats : groupedStats.entrySet()) {
        String processorName = stats.getKey().getProcessorName();
        String processorId = stats.getKey().getProcessorId();
        Map<String, AggregatedProcessorStatistics> processorStatsMap = feedProcessorStatistics.getProcessorStats();
        if (!processorStatsMap.containsKey(processorName)) {
            processorStatsMap.put(processorName, new AggregatedProcessorStatisticsV2(processorId, processorName, collectionId));
        }
        AggregatedProcessorStatistics processorStatistics = processorStatsMap.get(processorName);
        for (GroupedStats s : stats.getValue()) {
            GroupedStatsUtil.addStats1(processorStatistics.getStats(GroupedStats.DEFAULT_SOURCE_CONNECTION_ID), s);
        }
    /*
            AggregatedProcessorStatistics
                processorStatistics =
                feedProcessorStatistics.getProcessorStats()
                    .computeIfAbsent(processorName, k -> new AggregatedProcessorStatisticsV2(processorId, k, collectionId));


            stats.getValue().stream().forEach( s ->  GroupedStatsUtil.add(processorStatistics.getStats(GroupedStats.DEFAULT_SOURCE_CONNECTION_ID), s));
            */
    }
    return feedProcessorStatistics;
}
Also used : GroupedStats(com.thinkbiganalytics.nifi.provenance.model.stats.GroupedStats) ArrayList(java.util.ArrayList) List(java.util.List) AggregatedProcessorStatistics(com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedProcessorStatistics) GroupedStatsIdentity(com.thinkbiganalytics.nifi.provenance.model.stats.GroupedStatsIdentity) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) AggregatedFeedProcessorStatisticsV2(com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedFeedProcessorStatisticsV2) AggregatedProcessorStatisticsV2(com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedProcessorStatisticsV2)

Aggregations

AggregatedFeedProcessorStatisticsV2 (com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedFeedProcessorStatisticsV2)1 AggregatedProcessorStatistics (com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedProcessorStatistics)1 AggregatedProcessorStatisticsV2 (com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedProcessorStatisticsV2)1 GroupedStats (com.thinkbiganalytics.nifi.provenance.model.stats.GroupedStats)1 GroupedStatsIdentity (com.thinkbiganalytics.nifi.provenance.model.stats.GroupedStatsIdentity)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1