Search in sources :

Example 1 with NiFiFeedProcessorErrorsContainer

use of com.thinkbiganalytics.metadata.rest.jobrepo.nifi.NiFiFeedProcessorErrorsContainer in project kylo by Teradata.

the class NifiFeedProcessorStatisticsRestControllerV2 method findFeedProcessorErrors.

@GET
@Path("/{feedName}/processor-errors")
@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 findFeedProcessorErrors(@PathParam("feedName") String feedName, @QueryParam("from") Long fromMillis, @QueryParam("to") Long toMillis, @QueryParam("after") Long timestamp) {
    this.accessController.checkPermission(AccessController.SERVICES, OperationsAccessControl.ACCESS_OPS);
    final DateTime endTime = getToDateTime(toMillis);
    final DateTime startTime = getFromDateTime(fromMillis);
    NiFiFeedProcessorErrorsContainer container = new NiFiFeedProcessorErrorsContainer(startTime, endTime);
    List<? extends NifiFeedProcessorErrors> errors = null;
    if (nifiStatsJmsReceiver.isPersistErrors()) {
        errors = metadataAccess.read(() -> {
            if (timestamp != null && timestamp != 0L) {
                return statsProvider.findFeedProcessorErrorsAfter(feedName, new DateTime(timestamp));
            } else {
                return statsProvider.findFeedProcessorErrors(feedName, startTime, endTime);
            }
        });
    } else {
        if (timestamp != null && timestamp != 0L) {
            errors = nifiStatsJmsReceiver.getErrorsForFeed(feedName, timestamp);
        } else {
            errors = nifiStatsJmsReceiver.getErrorsForFeed(feedName, startTime.getMillis(), endTime.getMillis());
        }
    }
    List<com.thinkbiganalytics.metadata.rest.jobrepo.nifi.NifiFeedProcessorStatsErrors> errorsModel = NifiFeedProcessorStatsTransform.toErrorsModel(errors);
    container.setErrors(errorsModel);
    return Response.ok(container).build();
}
Also used : NiFiFeedProcessorErrorsContainer(com.thinkbiganalytics.metadata.rest.jobrepo.nifi.NiFiFeedProcessorErrorsContainer) 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

NiFiFeedProcessorErrorsContainer (com.thinkbiganalytics.metadata.rest.jobrepo.nifi.NiFiFeedProcessorErrorsContainer)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 DateTime (org.joda.time.DateTime)1