Search in sources :

Example 16 with NifiFeedProcessorStats

use of com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats in project kylo by Teradata.

the class NifiStatsJmsReceiver method createSummaryStats.

private List<NifiFeedProcessorStats> createSummaryStats(AggregatedFeedProcessorStatisticsHolder holder, final List<AggregatedFeedProcessorStatistics> unregisteredEvents) {
    List<NifiFeedProcessorStats> nifiFeedProcessorStatsList = new ArrayList<>();
    holder.getFeedStatistics().values().stream().forEach(feedProcessorStats -> {
        Long collectionIntervalMillis = feedProcessorStats.getCollectionIntervalMillis();
        String feedProcessorId = feedProcessorStats.getStartingProcessorId();
        String feedName = getFeedName(feedProcessorStats);
        if (StringUtils.isNotBlank(feedName)) {
            String feedProcessGroupId = provenanceEventFeedUtil.getFeedProcessGroupId(feedProcessorId);
            feedProcessorStats.getProcessorStats().values().forEach(processorStats -> {
                processorStats.getStats().values().stream().forEach(stats -> {
                    NifiFeedProcessorStats nifiFeedProcessorStats = toSummaryStats(stats);
                    nifiFeedProcessorStats.setFeedName(feedName);
                    nifiFeedProcessorStats.setProcessorId(processorStats.getProcessorId());
                    nifiFeedProcessorStats.setCollectionIntervalSeconds((collectionIntervalMillis / 1000));
                    if (holder instanceof AggregatedFeedProcessorStatisticsHolderV2) {
                        nifiFeedProcessorStats.setCollectionId(((AggregatedFeedProcessorStatisticsHolderV2) holder).getCollectionId());
                    }
                    String processorName = provenanceEventFeedUtil.getProcessorName(processorStats.getProcessorId());
                    if (processorName == null) {
                        processorName = processorStats.getProcessorName();
                    }
                    nifiFeedProcessorStats.setProcessorName(processorName);
                    nifiFeedProcessorStats.setFeedProcessGroupId(feedProcessGroupId);
                    nifiFeedProcessorStatsList.add(nifiFeedProcessorStats);
                });
            });
        } else {
            unregisteredEvents.add(feedProcessorStats);
        }
    });
    return nifiFeedProcessorStatsList;
}
Also used : ArrayList(java.util.ArrayList) NifiFeedProcessorStats(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats) JpaNifiFeedProcessorStats(com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.JpaNifiFeedProcessorStats) AggregatedFeedProcessorStatisticsHolderV2(com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedFeedProcessorStatisticsHolderV2)

Example 17 with NifiFeedProcessorStats

use of com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats in project kylo by Teradata.

the class NifiFeedProcessorStatisticsRestControllerV2 method findStats.

@GET
@Path("/{feedName}/processor-duration")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Returns the list of stats for each processor within the given timeframe relative to now")
@ApiResponses(@ApiResponse(code = 200, message = "Returns the list of stats for each processor within the given timeframe relative to now", response = com.thinkbiganalytics.metadata.rest.jobrepo.nifi.NifiFeedProcessorStats.class, responseContainer = "List"))
public Response findStats(@PathParam("feedName") String feedName, @QueryParam("from") Long fromMillis, @QueryParam("to") Long toMillis) {
    this.accessController.checkPermission(AccessController.SERVICES, OperationsAccessControl.ACCESS_OPS);
    final DateTime endTime = getToDateTime(toMillis);
    final DateTime startTime = getFromDateTime(fromMillis);
    return metadataAccess.read(() -> {
        NiFiFeedProcessorStatsContainer statsContainer = new NiFiFeedProcessorStatsContainer(startTime, endTime);
        List<? extends NifiFeedProcessorStats> list = statsProvider.findFeedProcessorStatisticsByProcessorName(feedName, statsContainer.getStartTime(), statsContainer.getEndTime());
        List<? extends NifiFeedProcessorErrors> errors = statsProvider.findFeedProcessorErrors(feedName, statsContainer.getStartTime(), statsContainer.getEndTime());
        List<com.thinkbiganalytics.metadata.rest.jobrepo.nifi.NifiFeedProcessorStats> model = NifiFeedProcessorStatsTransform.toModel(list);
        statsContainer.setStats(model);
        return Response.ok(statsContainer).build();
    });
}
Also used : NiFiFeedProcessorStatsContainer(com.thinkbiganalytics.metadata.rest.jobrepo.nifi.NiFiFeedProcessorStatsContainer) NifiFeedProcessorStats(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats) DateTime(org.joda.time.DateTime) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

NifiFeedProcessorStats (com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats)17 DateTime (org.joda.time.DateTime)14 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 JpaNifiFeedProcessorStats (com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.JpaNifiFeedProcessorStats)4 AggregatedFeedProcessorStatisticsHolderV2 (com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedFeedProcessorStatisticsHolderV2)3 MetadataAccess (com.thinkbiganalytics.metadata.api.MetadataAccess)2 OpsManagerFeed (com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed)2 BatchJobExecution (com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution)2 NifiFeedProcessorErrors (com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorErrors)2 NifiFeedProcessorStatisticsProvider (com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStatisticsProvider)2 NifiFeedStatisticsProvider (com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedStatisticsProvider)2 NifiFeedStats (com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedStats)2 NiFiFeedProcessorStatsContainer (com.thinkbiganalytics.metadata.rest.jobrepo.nifi.NiFiFeedProcessorStatsContainer)2 AggregatedFeedProcessorStatistics (com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedFeedProcessorStatistics)2 GroupedStatsV2 (com.thinkbiganalytics.nifi.provenance.model.stats.GroupedStatsV2)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2