Search in sources :

Example 21 with OpsManagerFeed

use of com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed in project kylo by Teradata.

the class FeedsRestController method getFeedHealthCounts.

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

use of com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed in project kylo by Teradata.

the class FeedsRestController method getAlerts.

private Collection<AlertSummaryGrouped> getAlerts(final String feedName, final String feedId) {
    return metadataAccess.read(() -> {
        String derivedFeedId = feedId;
        // get necessary feed info
        if (StringUtils.isBlank(feedId) && StringUtils.isNotBlank(feedName)) {
            // get the feedId for this feed name
            OpsManagerFeed feed = opsFeedManagerFeedProvider.findByName(feedName);
            if (feed != null) {
                derivedFeedId = feed.getId().toString();
            }
        }
        if (StringUtils.isBlank(derivedFeedId)) {
            return Collections.emptyList();
        }
        List<? extends ServiceLevelAgreementDescription> slas = serviceLevelAgreementDescriptionProvider.findForFeed(opsFeedManagerFeedProvider.resolveId(derivedFeedId));
        List<String> slaIds = new ArrayList<>();
        if (slas != null && !slas.isEmpty()) {
            slaIds = slas.stream().map(sla -> sla.getSlaId().toString()).collect(Collectors.toList());
        }
        List<String> ids = new ArrayList<>();
        ids.addAll(slaIds);
        ids.add(derivedFeedId);
        String filter = ids.stream().collect(Collectors.joining("||"));
        List<AlertSummary> alerts = new ArrayList<>();
        AlertCriteria criteria = alertProvider.criteria().state(Alert.State.UNHANDLED).orFilter(filter);
        alertProvider.getAlertsSummary(criteria).forEachRemaining(alerts::add);
        return alertsModel.groupAlertSummaries(alerts);
    });
}
Also used : AlertCriteria(com.thinkbiganalytics.alerts.api.AlertCriteria) OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed) ArrayList(java.util.ArrayList) AlertSummary(com.thinkbiganalytics.alerts.api.AlertSummary)

Example 23 with OpsManagerFeed

use of com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed in project kylo by Teradata.

the class RemoveDuplicateOpsManagerFeedsUpgradeAction method upgradeTo.

@Override
public void upgradeTo(final KyloVersion startingVersion) {
    log.info("remove duplicate ops manager feeds from version: {}", startingVersion);
    List<? extends OpsManagerFeed> feeds = opsManagerFeedProvider.findFeedsWithSameName();
    if (feeds != null) {
        final List<OpsManagerFeed> feedsToDelete = new ArrayList<>();
        final Map<String, OpsManagerFeed> feedsToKeep = new HashMap<>();
        feeds.stream().forEach(feed -> {
            log.info("Found duplicate feed {} - {} ", feed.getId(), feed.getName());
            Feed jcrFeed = feedProvider.getFeed(feed.getId());
            if (jcrFeed == null) {
                feedsToDelete.add(feed);
            } else {
                feedsToKeep.put(feed.getName(), feed);
            }
        });
        feedsToDelete.stream().forEach(feed -> {
            OpsManagerFeed feedToKeep = feedsToKeep.get(feed.getName());
            if (feedToKeep != null) {
                // remove it
                log.info("Unable to find feed {} - {} in JCR metadata.  A feed with id of {} already exists with this same name {}.  Attempt to remove its data from Operations Manager", feed.getId(), feed.getName(), feedToKeep.getId(), feedToKeep.getName());
                opsManagerFeedProvider.delete(feed.getId());
            }
        });
    }
}
Also used : OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) JcrFeed(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed) OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed)

Aggregations

OpsManagerFeed (com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed)23 BatchJobExecution (com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution)6 ArrayList (java.util.ArrayList)6 JpaOpsManagerFeed (com.thinkbiganalytics.metadata.jpa.feed.JpaOpsManagerFeed)4 HashMap (java.util.HashMap)4 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)3 NifiFeedStats (com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedStats)3 QJpaOpsManagerFeed (com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed)3 JpaNifiFeedStats (com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.JpaNifiFeedStats)3 DateTime (org.joda.time.DateTime)3 CacheBuilder (com.google.common.cache.CacheBuilder)2 CacheLoader (com.google.common.cache.CacheLoader)2 LoadingCache (com.google.common.cache.LoadingCache)2 FeedHealth (com.thinkbiganalytics.jobrepo.query.model.FeedHealth)2 MetadataAccess (com.thinkbiganalytics.metadata.api.MetadataAccess)2 NifiFeedProcessorStats (com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats)2 ProvenanceEventRecordDTO (com.thinkbiganalytics.nifi.provenance.model.ProvenanceEventRecordDTO)2 ProvenanceEventRecordDTOHolder (com.thinkbiganalytics.nifi.provenance.model.ProvenanceEventRecordDTOHolder)2 Stopwatch (com.google.common.base.Stopwatch)1 EvictingQueue (com.google.common.collect.EvictingQueue)1