Search in sources :

Example 1 with GroupedStatsV2

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

the class NifiStatsJmsReceiver method toSummaryStats.

private NifiFeedProcessorStats toSummaryStats(GroupedStats groupedStats) {
    NifiFeedProcessorStats nifiFeedProcessorStats = new JpaNifiFeedProcessorStats();
    nifiFeedProcessorStats.setTotalCount(groupedStats.getTotalCount());
    nifiFeedProcessorStats.setFlowFilesFinished(groupedStats.getFlowFilesFinished());
    nifiFeedProcessorStats.setFlowFilesStarted(groupedStats.getFlowFilesStarted());
    nifiFeedProcessorStats.setCollectionId(groupedStats.getGroupKey());
    nifiFeedProcessorStats.setBytesIn(groupedStats.getBytesIn());
    nifiFeedProcessorStats.setBytesOut(groupedStats.getBytesOut());
    nifiFeedProcessorStats.setDuration(groupedStats.getDuration());
    nifiFeedProcessorStats.setJobsFinished(groupedStats.getJobsFinished());
    nifiFeedProcessorStats.setJobsStarted(groupedStats.getJobsStarted());
    nifiFeedProcessorStats.setProcessorsFailed(groupedStats.getProcessorsFailed());
    nifiFeedProcessorStats.setCollectionTime(new DateTime(groupedStats.getTime()));
    nifiFeedProcessorStats.setMinEventTime(new DateTime(groupedStats.getMinTime()));
    nifiFeedProcessorStats.setMinEventTimeMillis(nifiFeedProcessorStats.getMinEventTime().getMillis());
    nifiFeedProcessorStats.setMaxEventTime(new DateTime(groupedStats.getMaxTime()));
    nifiFeedProcessorStats.setJobsFailed(groupedStats.getJobsFailed());
    nifiFeedProcessorStats.setSuccessfulJobDuration(groupedStats.getSuccessfulJobDuration());
    nifiFeedProcessorStats.setJobDuration(groupedStats.getJobDuration());
    nifiFeedProcessorStats.setMaxEventId(groupedStats.getMaxEventId());
    nifiFeedProcessorStats.setFailedCount(groupedStats.getProcessorsFailed());
    if (groupedStats instanceof GroupedStatsV2) {
        nifiFeedProcessorStats.setLatestFlowFileId(((GroupedStatsV2) groupedStats).getLatestFlowFileId());
    }
    if (provenanceEventFeedUtil.isFailure(groupedStats.getSourceConnectionIdentifier())) {
        nifiFeedProcessorStats.setFailedCount(groupedStats.getTotalCount() + groupedStats.getProcessorsFailed());
    }
    return nifiFeedProcessorStats;
}
Also used : JpaNifiFeedProcessorStats(com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.JpaNifiFeedProcessorStats) NifiFeedProcessorStats(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats) JpaNifiFeedProcessorStats(com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.JpaNifiFeedProcessorStats) DateTime(org.joda.time.DateTime) GroupedStatsV2(com.thinkbiganalytics.nifi.provenance.model.stats.GroupedStatsV2)

Example 2 with GroupedStatsV2

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

the class GroupedStatsUtil method gatherStats.

/**
 * Gather feed stats for a list of events
 */
public static AggregatedFeedProcessorStatisticsHolder gatherStats(final List<ProvenanceEventRecordDTO> events) {
    Map<String, Map<GroupedStatsIdentity, List<GroupedStats>>> feedStatsByProcessor = new ConcurrentHashMap<>();
    // events.stream().forEach(e -> {
    for (ProvenanceEventRecordDTO e : events) {
        if (!feedStatsByProcessor.containsKey(e.getFeedName())) {
            feedStatsByProcessor.put(e.getFeedName(), new ConcurrentHashMap<GroupedStatsIdentity, List<GroupedStats>>());
        }
        // feedStatsByProcessor.putIfAbsent(e.getFeedName(), );
        Map<GroupedStatsIdentity, List<GroupedStats>> feedStats = feedStatsByProcessor.get(e.getFeedName());
        GroupedStatsIdentity identity = new GroupedStatsIdentity(e.getComponentId(), e.getComponentName());
        if (!feedStats.containsKey(identity)) {
            feedStats.put(identity, new ArrayList<GroupedStats>());
        }
        // feedStats.putIfAbsent(identity, new ArrayList<>());
        List<GroupedStats> feedProcessorStats = feedStats.get(identity);
        // Add the new stats
        GroupedStats statsV2 = GroupedStatsUtil.add(new GroupedStatsV2(), e);
        feedProcessorStats.add(statsV2);
    }
    // );
    List<AggregatedFeedProcessorStatistics> statsList = new ArrayList<>();
    for (Map.Entry<String, Map<GroupedStatsIdentity, List<GroupedStats>>> feedStats : feedStatsByProcessor.entrySet()) {
        AggregatedFeedProcessorStatistics feedProcessorStatistics = GroupedStatsUtil.groupStatsByProcessor(feedStats.getKey(), feedStats.getValue());
        statsList.add(feedProcessorStatistics);
    }
    /* feedStatsByProcessor.entrySet().stream().forEach(feedStats -> {
            AggregatedFeedProcessorStatistics feedProcessorStatistics = GroupedStatsUtil.groupStatsByProcessor(feedStats.getKey(), feedStats.getValue());
            statsList.add(feedProcessorStatistics);
        });
        */
    AggregatedFeedProcessorStatisticsHolderV3 feedProcessorStatisticsHolderV3 = new AggregatedFeedProcessorStatisticsHolderV3();
    feedProcessorStatisticsHolderV3.setFeedStatistics(statsList);
    return feedProcessorStatisticsHolderV3;
}
Also used : GroupedStats(com.thinkbiganalytics.nifi.provenance.model.stats.GroupedStats) ProvenanceEventRecordDTO(com.thinkbiganalytics.nifi.provenance.model.ProvenanceEventRecordDTO) ArrayList(java.util.ArrayList) AggregatedFeedProcessorStatistics(com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedFeedProcessorStatistics) GroupedStatsIdentity(com.thinkbiganalytics.nifi.provenance.model.stats.GroupedStatsIdentity) ArrayList(java.util.ArrayList) List(java.util.List) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) GroupedStatsV2(com.thinkbiganalytics.nifi.provenance.model.stats.GroupedStatsV2) AggregatedFeedProcessorStatisticsHolderV3(com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedFeedProcessorStatisticsHolderV3)

Aggregations

GroupedStatsV2 (com.thinkbiganalytics.nifi.provenance.model.stats.GroupedStatsV2)2 NifiFeedProcessorStats (com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats)1 JpaNifiFeedProcessorStats (com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.JpaNifiFeedProcessorStats)1 ProvenanceEventRecordDTO (com.thinkbiganalytics.nifi.provenance.model.ProvenanceEventRecordDTO)1 AggregatedFeedProcessorStatistics (com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedFeedProcessorStatistics)1 AggregatedFeedProcessorStatisticsHolderV3 (com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedFeedProcessorStatisticsHolderV3)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 DateTime (org.joda.time.DateTime)1