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();
}
});
}
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);
});
}
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());
}
});
}
}
Aggregations