Search in sources :

Example 1 with FeedHealth

use of com.thinkbiganalytics.jobrepo.query.model.FeedHealth in project kylo by Teradata.

the class FeedHealthUtil method parseToList.

public static List<FeedHealth> parseToList(List<ExecutedFeed> latestOpFeeds, Map<String, Long> avgRunTimes) {
    List<FeedHealth> list = new ArrayList<FeedHealth>();
    Map<String, FeedHealth> map = new HashMap<String, FeedHealth>();
    if (latestOpFeeds != null) {
        for (ExecutedFeed feed : latestOpFeeds) {
            String feedName = feed.getName();
            FeedHealth feedHealth = map.get(feedName);
            if (feedHealth == null) {
                feedHealth = new DefaultFeedHealth();
                feedHealth.setFeed(feedName);
                if (avgRunTimes != null) {
                    feedHealth.setAvgRuntime(avgRunTimes.get(feedName));
                }
                list.add(feedHealth);
                map.put(feedName, feedHealth);
            }
            feedHealth.setLastOpFeed(feed);
        }
    }
    return list;
}
Also used : DefaultFeedHealth(com.thinkbiganalytics.jobrepo.query.model.DefaultFeedHealth) ExecutedFeed(com.thinkbiganalytics.jobrepo.query.model.ExecutedFeed) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FeedHealth(com.thinkbiganalytics.jobrepo.query.model.FeedHealth) DefaultFeedHealth(com.thinkbiganalytics.jobrepo.query.model.DefaultFeedHealth)

Example 2 with FeedHealth

use of com.thinkbiganalytics.jobrepo.query.model.FeedHealth in project kylo by Teradata.

the class FeedModelTransform method feedHealth.

/**
 * Transform the FeedHealth domain object to the REST friendly FeedHealth object
 *
 * @return the transformed FeedHealth object
 */
public static FeedHealth feedHealth(FeedSummary domain) {
    FeedHealth feedHealth = new DefaultFeedHealth();
    feedHealth.setUnhealthyCount(domain.getFailedCount());
    feedHealth.setHealthyCount(domain.getCompletedCount());
    feedHealth.setFeed(domain.getFeedName());
    feedHealth.setFeedId(domain.getFeedId() != null ? domain.getFeedId().toString() : null);
    feedHealth.setLastOpFeed(executedFeed(domain));
    feedHealth.setStream(domain.isStream());
    feedHealth.setRunningCount(domain.getRunningCount());
    return feedHealth;
}
Also used : DefaultFeedHealth(com.thinkbiganalytics.jobrepo.query.model.DefaultFeedHealth) FeedHealth(com.thinkbiganalytics.jobrepo.query.model.FeedHealth) DefaultFeedHealth(com.thinkbiganalytics.jobrepo.query.model.DefaultFeedHealth)

Example 3 with FeedHealth

use of com.thinkbiganalytics.jobrepo.query.model.FeedHealth in project kylo by Teradata.

the class FeedsRestController method getFeedHealthForFeed.

@GET
@Path("/health/{feedName}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Gets the detailed health status of the specified feed.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the health.", response = FeedStatus.class), @ApiResponse(code = 404, message = "The feed does not exist.", response = RestResponseStatus.class) })
public FeedStatus getFeedHealthForFeed(@Context HttpServletRequest request, @PathParam("feedName") String feedName) {
    this.accessController.checkPermission(AccessController.SERVICES, OperationsAccessControl.ACCESS_OPS);
    return metadataAccess.read(() -> {
        final FeedHealth feedHealth = getFeedHealthCounts(request, feedName);
        if (feedHealth != null) {
            return FeedModelTransform.feedStatus(Lists.newArrayList(feedHealth));
        }
        final OpsManagerFeed feed = opsFeedManagerFeedProvider.findByName(feedName);
        if (feed != null) {
            return FeedModelTransform.feedStatus(feed);
        } else {
            throw new NotFoundException();
        }
    });
}
Also used : OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed) NotFoundException(javax.ws.rs.NotFoundException) FeedHealth(com.thinkbiganalytics.jobrepo.query.model.FeedHealth) 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)

Example 4 with FeedHealth

use of com.thinkbiganalytics.jobrepo.query.model.FeedHealth in project kylo by Teradata.

the class FeedHealthSummaryCache method getUserFeedHealth.

public SearchResult getUserFeedHealth(Long time, FeedSummaryFilter feedSummaryFilter, RoleSetExposingSecurityExpressionRoot userContext) {
    SearchResult<com.thinkbiganalytics.jobrepo.query.model.FeedSummary> searchResult = new SearchResultImpl();
    List<FeedHealth> feedSummaryHealth = null;
    // get the entire list back and filter it for user access
    List<? extends FeedSummary> list = getFeedSummaryList(time).stream().filter(filter(feedSummaryFilter, userContext)).collect(Collectors.toList());
    feedSummaryHealth = list.stream().sorted(feedSummaryFilter.getSort() != null ? getComparator(feedSummaryFilter.getSort()) : byName).skip(feedSummaryFilter.getStart()).limit(feedSummaryFilter.getLimit() > 0 ? feedSummaryFilter.getLimit() : Integer.MAX_VALUE).map(f -> FeedModelTransform.feedHealth(f)).collect(Collectors.toList());
    // Transform it to FeedSummary objects
    FeedStatus feedStatus = FeedModelTransform.feedStatus(feedSummaryHealth);
    Long total = new Long(list.size());
    searchResult.setData(feedStatus.getFeedSummary());
    searchResult.setRecordsTotal(total);
    searchResult.setRecordsFiltered(total);
    return searchResult;
}
Also used : SearchResultImpl(com.thinkbiganalytics.rest.model.search.SearchResultImpl) FeedStatus(com.thinkbiganalytics.jobrepo.query.model.FeedStatus) FeedHealth(com.thinkbiganalytics.jobrepo.query.model.FeedHealth) JpaFeedSummary(com.thinkbiganalytics.metadata.jpa.feed.JpaFeedSummary) FeedSummary(com.thinkbiganalytics.metadata.api.feed.FeedSummary)

Example 5 with FeedHealth

use of com.thinkbiganalytics.jobrepo.query.model.FeedHealth in project kylo by Teradata.

the class FeedModelTransform method feedHealth.

/**
 * Transform the FeedHealth domain object to the REST friendly FeedHealth object
 *
 * @return the transformed FeedHealth object
 */
public static FeedHealth feedHealth(com.thinkbiganalytics.metadata.api.feed.FeedHealth domain) {
    FeedHealth feedHealth = new DefaultFeedHealth();
    feedHealth.setUnhealthyCount(domain.getFailedCount());
    feedHealth.setHealthyCount(domain.getCompletedCount());
    feedHealth.setFeed(domain.getFeedName());
    feedHealth.setFeedId(domain.getFeedId() != null ? domain.getFeedId().toString() : null);
    feedHealth.setLastOpFeed(executedFeed(domain));
    feedHealth.setStream(domain.isStream());
    feedHealth.setRunningCount(domain.getRunningCount());
    return feedHealth;
}
Also used : DefaultFeedHealth(com.thinkbiganalytics.jobrepo.query.model.DefaultFeedHealth) FeedHealth(com.thinkbiganalytics.jobrepo.query.model.FeedHealth) DefaultFeedHealth(com.thinkbiganalytics.jobrepo.query.model.DefaultFeedHealth)

Aggregations

FeedHealth (com.thinkbiganalytics.jobrepo.query.model.FeedHealth)7 DefaultFeedHealth (com.thinkbiganalytics.jobrepo.query.model.DefaultFeedHealth)4 FeedStatus (com.thinkbiganalytics.jobrepo.query.model.FeedStatus)2 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 ExecutedFeed (com.thinkbiganalytics.jobrepo.query.model.ExecutedFeed)1 FeedSummary (com.thinkbiganalytics.metadata.api.feed.FeedSummary)1 OpsManagerFeed (com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed)1 JpaFeedSummary (com.thinkbiganalytics.metadata.jpa.feed.JpaFeedSummary)1 SearchResultImpl (com.thinkbiganalytics.rest.model.search.SearchResultImpl)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Nonnull (javax.annotation.Nonnull)1 NotFoundException (javax.ws.rs.NotFoundException)1