use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class FeedOpsUpgradeAction method upgradeTo.
/* (non-Javadoc)
* @see com.thinkbiganalytics.metadata.upgrade.UpgradeState#upgradeFrom(com.thinkbiganalytics.metadata.api.app.KyloVersion)
*/
@Override
public void upgradeTo(KyloVersion startingVersion) {
log.info("Upgrading from version: " + startingVersion);
for (Category category : categoryProvider.findAll()) {
// Ensure each category has an allowedActions (gets create if not present.)
category.getAllowedActions();
}
// get all feeds defined in feed manager
List<Feed> domainFeeds = feedProvider.findAll();
Map<String, Feed> feedManagerFeedMap = new HashMap<>();
if (domainFeeds != null && !domainFeeds.isEmpty()) {
List<OpsManagerFeed.ID> opsManagerFeedIds = new ArrayList<OpsManagerFeed.ID>();
for (Feed feedManagerFeed : domainFeeds) {
opsManagerFeedIds.add(opsManagerFeedProvider.resolveId(feedManagerFeed.getId().toString()));
feedManagerFeedMap.put(feedManagerFeed.getId().toString(), feedManagerFeed);
// Ensure each feed has an allowedActions (gets create if not present.)
feedManagerFeed.getAllowedActions();
}
// find those that match
List<? extends OpsManagerFeed> opsManagerFeeds = opsManagerFeedProvider.findByFeedIds(opsManagerFeedIds);
if (opsManagerFeeds != null) {
for (OpsManagerFeed opsManagerFeed : opsManagerFeeds) {
feedManagerFeedMap.remove(opsManagerFeed.getId().toString());
}
}
List<OpsManagerFeed> feedsToAdd = new ArrayList<>();
for (Feed feed : feedManagerFeedMap.values()) {
String fullName = FeedNameUtil.fullName(feed.getCategory().getSystemName(), feed.getName());
OpsManagerFeed.ID opsManagerFeedId = opsManagerFeedProvider.resolveId(feed.getId().toString());
OpsManagerFeed opsManagerFeed = new JpaOpsManagerFeed(opsManagerFeedId, fullName);
feedsToAdd.add(opsManagerFeed);
}
log.info("Synchronizing Feeds from Feed Manager. About to insert {} feed ids/names into Operations Manager", feedsToAdd.size());
opsManagerFeedProvider.save(feedsToAdd);
}
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class EnsureTemplateFeedRelationshipsUpgradeAction method ensureFeedTemplateFeedRelationships.
private void ensureFeedTemplateFeedRelationships() {
// ensure the templates have the feed relationships
List<Feed> feeds = feedProvider.findAll();
if (feeds != null) {
feeds.stream().forEach(feed -> {
FeedManagerTemplate template = feed.getTemplate();
if (template != null) {
// ensure the template has feeds.
List<Feed> templateFeeds = null;
try {
templateFeeds = template.getFeeds();
} catch (MetadataRepositoryException e) {
// templateFeeds are weak references.
// if the template feeds return itemNotExists we need to reset it
Throwable rootCause = ExceptionUtils.getRootCause(e);
if (rootCause != null && rootCause instanceof ItemNotFoundException) {
// reset the reference collection. It will be rebuilt in the subsequent call
JcrPropertyUtil.removeAllFromSetProperty(((JcrFeedTemplate) template).getNode(), JcrFeedTemplate.FEEDS);
}
}
if (templateFeeds == null || !templateFeeds.contains(feed)) {
log.info("Updating relationship temlate: {} -> feed: {}", template.getName(), feed.getName());
template.addFeed(feed);
feedManagerTemplateProvider.update(template);
}
}
});
}
feedProvider.populateInverseFeedDependencies();
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class FeedSlaUpgradeAction method upgradeFeedSla.
private void upgradeFeedSla(ExtensibleType type) {
List<ExtensibleEntity> slaRels = entityProvider.getEntities(SLA_REL_TYPE_NAME);
for (ExtensibleEntity rel : slaRels) {
ServiceLevelAgreement sla = JcrUtil.getJcrObject(rel.getProperty("sla"), JcrServiceLevelAgreement.class);
Set<Feed> feeds = rel.getPropertyAsSet("feeds", Node.class).stream().map(JcrFeed::new).collect(Collectors.toSet());
feedSlaProvider.relateFeeds(sla, feeds);
entityProvider.deleteEntity(rel.getId());
}
this.typeProvider.deleteType(type.getId());
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class JobExecutionChangedNotifier method newFeedOperationStatusEvent.
private FeedOperationStatusEvent newFeedOperationStatusEvent(Long jobExecutionId, OpsManagerFeed feed, FeedOperation.State state, String status) {
String feedName = feed != null ? feed.getName() : null;
Feed.ID feedId = feed != null ? feed.getId() : null;
FeedOperation.FeedType feedType = feed != null ? FeedOperation.FeedType.valueOf(feed.getFeedType().name()) : FeedOperation.FeedType.FEED;
return new FeedOperationStatusEvent(new OperationStatus(feedId, feedName, feedType, new OpId(jobExecutionId), state, status));
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class FeedExecutedSinceFeedAssessorTest method setUpAssessor.
/**
* @param triggeredFeedStartTime pass negative value for empty operations list
* @param mainFeedStopTime pass negative for empty operations list
*/
private FeedExecutedSinceFeedAssessor setUpAssessor(int triggeredFeedStartTime, boolean isTriggeredFeedRunning, int mainFeedStopTime, boolean isMainFeedRunning) {
FeedCriteria dummyCriteria = mock(FeedCriteria.class);
when(dummyCriteria.name(Mockito.anyString())).thenReturn(dummyCriteria);
when(dummyCriteria.category(Mockito.anyString())).thenReturn(dummyCriteria);
FeedProvider feedProvider = mock(FeedProvider.class);
when(feedProvider.feedCriteria()).thenReturn(dummyCriteria);
List<Feed> triggeredFeeds = new ArrayList<>();
Feed triggeredFeed = mock(Feed.class);
Feed.ID triggeredFeedId = mock(Feed.ID.class);
when(triggeredFeed.getId()).thenReturn(triggeredFeedId);
triggeredFeeds.add(triggeredFeed);
List<Feed> mainFeeds = new ArrayList<>();
Feed mainFeed = mock(Feed.class);
Feed.ID mainFeedId = mock(Feed.ID.class);
when(mainFeed.getId()).thenReturn(mainFeedId);
mainFeeds.add(mainFeed);
when(feedProvider.getFeeds(dummyCriteria)).thenReturn(mainFeeds, triggeredFeeds);
FeedOperationsProvider opsProvider = mock(FeedOperationsProvider.class);
List<FeedOperation> triggeredFeedOps = new ArrayList<>();
if (triggeredFeedStartTime > 0) {
FeedOperation triggeredOp = mock(FeedOperation.class);
when(triggeredOp.getStartTime()).thenReturn(new DateTime(triggeredFeedStartTime));
triggeredFeedOps.add(triggeredOp);
}
List<FeedOperation> mainFeedOps = new ArrayList<>();
if (mainFeedStopTime > 0) {
FeedOperation mainFeedOp = mock(FeedOperation.class);
when(mainFeedOp.getStopTime()).thenReturn(new DateTime(mainFeedStopTime));
mainFeedOps.add(mainFeedOp);
}
when(opsProvider.findLatestCompleted(mainFeedId)).thenReturn(mainFeedOps);
when(opsProvider.findLatest(triggeredFeedId)).thenReturn(triggeredFeedOps);
when(opsProvider.isFeedRunning(mainFeedId)).thenReturn(isMainFeedRunning);
when(opsProvider.isFeedRunning(triggeredFeedId)).thenReturn(isTriggeredFeedRunning);
return new FeedExecutedSinceFeedAssessor() {
@Override
protected FeedProvider getFeedProvider() {
return feedProvider;
}
@Override
protected FeedOperationsProvider getFeedOperationsProvider() {
return opsProvider;
}
};
}
Aggregations