use of com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata in project kylo by Teradata.
the class DefaultFeedManagerFeedService method updateFeedDatasources.
/**
* Update a given feeds datasources clearing its sources/destinations before revaluating the data
*
* @param feedId the id of the feed rest model to update
*/
public void updateFeedDatasources(String feedId) {
metadataAccess.commit(() -> {
feedProvider.removeFeedDestinations(feedProvider.resolveId(feedId));
feedProvider.removeFeedSources(feedProvider.resolveId(feedId));
});
metadataAccess.commit(() -> {
Feed domainFeed = feedProvider.findById(feedProvider.resolveId(feedId));
FeedMetadata feed = feedModelTransform.domainToFeedMetadata(domainFeed);
assignFeedDatasources(feed, domainFeed);
});
}
use of com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata in project kylo by Teradata.
the class DefaultFeedManagerFeedService method getFeedByName.
@Override
public FeedMetadata getFeedByName(final String categoryName, final String feedName) {
FeedMetadata feedMetadata = metadataAccess.read(() -> {
this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.ACCESS_FEEDS);
Feed domainFeed = feedProvider.findBySystemName(categoryName, feedName);
if (domainFeed != null) {
return feedModelTransform.domainToFeedMetadata(domainFeed);
}
return null;
});
return feedMetadata;
}
use of com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata in project kylo by Teradata.
the class DefaultFeedManagerFeedService method updateAllFeedsDatasources.
/**
* Iterate all of the feeds, clear all sources/destinations and reassign
* Note this will be an expensive call
*/
public void updateAllFeedsDatasources() {
metadataAccess.commit(() -> {
feedProvider.findAll().stream().forEach(domainFeed -> {
domainFeed.clearSourcesAndDestinations();
});
});
metadataAccess.commit(() -> {
feedProvider.findAll().stream().forEach(domainFeed -> {
FeedMetadata feed = feedModelTransform.domainToFeedMetadata(domainFeed);
assignFeedDatasources(feed, domainFeed);
});
});
}
use of com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata in project kylo by Teradata.
the class DefaultFeedManagerFeedService method createFeed.
/**
* Create/Update a Feed in NiFi. Save the metadata to Kylo meta store.
*
* @param feedMetadata the feed metadata
* @return an object indicating if the feed creation was successful or not
*/
public NifiFeed createFeed(final FeedMetadata feedMetadata) {
// functional access to be able to create a feed
this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_FEEDS);
feedHistoryDataReindexingService.checkAndConfigureNiFi(feedMetadata);
feedHistoryDataReindexingService.checkAndEnsureFeedHistoryDataReindexingRequestIsAcceptable(feedMetadata);
if (feedMetadata.getState() == null) {
if (feedMetadata.isActive()) {
feedMetadata.setState(Feed.State.ENABLED.name());
} else {
feedMetadata.setState(Feed.State.DISABLED.name());
}
}
if (StringUtils.isBlank(feedMetadata.getId())) {
feedMetadata.setIsNew(true);
}
// Read all the feeds as System Service account to ensure the feed name is unique
if (feedMetadata.isNew()) {
metadataAccess.read(() -> {
Feed existing = feedProvider.findBySystemName(feedMetadata.getCategory().getSystemName(), feedMetadata.getSystemFeedName());
if (existing != null) {
throw new DuplicateFeedNameException(feedMetadata.getCategoryName(), feedMetadata.getFeedName());
}
}, MetadataAccess.SERVICE);
}
NifiFeed feed = createAndSaveFeed(feedMetadata);
// register the audit for the update event
if (feed.isSuccess() && !feedMetadata.isNew()) {
Feed.State state = Feed.State.valueOf(feedMetadata.getState());
Feed.ID id = feedProvider.resolveId(feedMetadata.getId());
notifyFeedStateChange(feedMetadata, id, state, MetadataChange.ChangeType.UPDATE);
} else if (feed.isSuccess() && feedMetadata.isNew()) {
// update the access control
feedMetadata.toRoleMembershipChangeList().stream().forEach(roleMembershipChange -> securityService.changeFeedRoleMemberships(feed.getFeedMetadata().getId(), roleMembershipChange));
}
feedHistoryDataReindexingService.updateHistoryDataReindexingFeedsAvailableCache(feedMetadata);
return feed;
}
use of com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata in project kylo by Teradata.
the class DefaultFeedManagerFeedService method disableFeed.
// @Transactional(transactionManager = "metadataTransactionManager")
private boolean disableFeed(final Feed.ID feedId) {
return metadataAccess.commit(() -> {
boolean disabled = feedProvider.disableFeed(feedId);
Feed domainFeed = feedProvider.findById(feedId);
if (domainFeed != null) {
domainFeed.setState(Feed.State.DISABLED);
feedProvider.update(domainFeed);
if (disabled) {
FeedMetadata feedMetadata = feedModelTransform.domainToFeedMetadata(domainFeed);
notifyFeedStateChange(feedMetadata, feedId, Feed.State.DISABLED, MetadataChange.ChangeType.UPDATE);
}
}
return disabled;
});
}
Aggregations