use of com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed 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