use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class HistoryDataReindexingFeedsAvailableCache method updateInfoFlagsForReindexFeed.
private void updateInfoFlagsForReindexFeed() {
metadataAccess.read(() -> {
Feed historyReindexFeed = feedProvider.findBySystemName(historyDataReindexingReindexFeedCategory, historyDataReindexingReindexFeedSystemName);
if (historyReindexFeed == null) {
reindexFeedAvailableWithMatchingName = false;
reindexFeedAvailableWithMatchingProperty = false;
} else {
reindexFeedAvailableWithMatchingName = true;
if (!historyReindexFeed.getUserProperties().isEmpty() && historyReindexFeed.getUserProperties().containsKey(REINDEX_SUPPORT_PROPERTY_NAME_FOR_CHECK) && historyReindexFeed.getUserProperties().get(REINDEX_SUPPORT_PROPERTY_NAME_FOR_CHECK).equals(REINDEX_SUPPORT_PROPERTY_VALUE_FOR_CHECK)) {
reindexFeedAvailableWithMatchingProperty = true;
log.info("Feed supporting history data reindexing (reindex feed) found in Kylo");
} else {
reindexFeedAvailableWithMatchingProperty = false;
}
}
}, MetadataAccess.SERVICE);
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class HistoryDataReindexingFeedsAvailableCache method updateInfoFlagsForRegularFeed.
private void updateInfoFlagsForRegularFeed() {
metadataAccess.read(() -> {
Feed regularIndexFeed = feedProvider.findBySystemName(historyDataReindexingRegularFeedCategory, historyDataReindexingRegularFeedSystemName);
if (regularIndexFeed == null) {
regularFeedAvailableWithMatchingName = false;
regularFeedAvailableWithMatchingProperty = false;
} else {
regularFeedAvailableWithMatchingName = true;
if (!regularIndexFeed.getUserProperties().isEmpty() && regularIndexFeed.getUserProperties().containsKey(REINDEX_SUPPORT_PROPERTY_NAME_FOR_CHECK) && regularIndexFeed.getUserProperties().get(REINDEX_SUPPORT_PROPERTY_NAME_FOR_CHECK).equals(REINDEX_SUPPORT_PROPERTY_VALUE_FOR_CHECK)) {
regularFeedAvailableWithMatchingProperty = true;
log.info("Feed supporting history data reindexing (regular feed) found in Kylo");
} else {
regularFeedAvailableWithMatchingProperty = false;
}
}
}, MetadataAccess.SERVICE);
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class TemplateModelTransform method DOMAIN_TO_REGISTERED_TEMPLATE.
public final Function<FeedManagerTemplate, RegisteredTemplate> DOMAIN_TO_REGISTERED_TEMPLATE(boolean includeFeedNames, boolean includeEncryptedProperties) {
return new Function<FeedManagerTemplate, RegisteredTemplate>() {
@Override
public RegisteredTemplate apply(FeedManagerTemplate domain) {
String json = domain.getJson();
RegisteredTemplate template = deserialize(json, includeEncryptedProperties);
template.setId(domain.getId().toString());
template.setState(domain.getState().name());
template.setNifiTemplateId(domain.getNifiTemplateId());
template.setAllowPreconditions(domain.isAllowPreconditions());
List<Feed> feeds = domain.getFeeds();
template.setFeedsCount(feeds == null ? 0 : feeds.size());
template.setStream(domain.isStream());
if (includeFeedNames && feeds != null) {
template.setFeedNames(feeds.stream().map(feedManagerFeed -> FeedNameUtil.fullName(feedManagerFeed.getCategory().getSystemName(), feedManagerFeed.getName())).collect(Collectors.toSet()));
}
if (domain.getCreatedTime() != null) {
template.setCreateDate(domain.getCreatedTime().toDate());
}
if (domain.getModifiedTime() != null) {
template.setUpdateDate(domain.getModifiedTime().toDate());
}
template.setOrder(domain.getOrder());
template.setTemplateTableOption(domain.getTemplateTableOption());
securityTransform.applyAccessControl(domain, template);
return template;
}
};
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class DefaultServiceLevelAgreementService method saveAndScheduleSla.
/**
* In order to Save an SLA if it is related to a Feed(s) the user needs to have EDIT_DETAILS permission on the Feed(s)
*
* @param serviceLevelAgreement the sla to save
* @param feed an option Feed to relate to this SLA. If this is not present the related feeds are also embedded in the SLA policies. The Feed is a pointer access to the current
* feed the user is editing if they are creating an SLA from the Feed Details page. If creating an SLA from the main SLA page the feed property will not be populated.
*/
private ServiceLevelAgreement saveAndScheduleSla(ServiceLevelAgreementGroup serviceLevelAgreement, FeedMetadata feed) {
// ensure user has permissions to edit the SLA
if (serviceLevelAgreement != null) {
ServiceLevelAgreementMetricTransformerHelper transformer = new ServiceLevelAgreementMetricTransformerHelper();
// Read the feeds on the SLA as a Service. Then verify the current user has access to edit these feeds
List<String> feedsOnSla = metadataAccess.read(() -> {
List<String> feedIds = new ArrayList<>();
// all referencing Feeds
List<String> systemCategoryAndFeedNames = transformer.getCategoryFeedNames(serviceLevelAgreement);
for (String categoryAndFeed : systemCategoryAndFeedNames) {
// fetch and update the reference to the sla
String categoryName = StringUtils.trim(StringUtils.substringBefore(categoryAndFeed, "."));
String feedName = StringUtils.trim(StringUtils.substringAfterLast(categoryAndFeed, "."));
Feed feedEntity = feedProvider.findBySystemName(categoryName, feedName);
if (feedEntity != null) {
feedIds.add(feedEntity.getId().toString());
}
}
return feedIds;
}, MetadataAccess.SERVICE);
boolean allowedToEdit = feedsOnSla.isEmpty() ? true : feedsOnSla.stream().allMatch(feedId -> feedManagerFeedService.checkFeedPermission(feedId, FeedAccessControl.EDIT_DETAILS));
if (allowedToEdit) {
return metadataAccess.commit(() -> {
// Re read back in the Feeds for this session
Set<Feed> slaFeeds = new HashSet<Feed>();
Set<Feed.ID> slaFeedIds = new HashSet<Feed.ID>();
feedsOnSla.stream().forEach(feedId -> {
Feed feedEntity = feedProvider.findById(feedProvider.resolveId(feedId));
if (feedEntity != null) {
slaFeeds.add(feedEntity);
slaFeedIds.add(feedEntity.getId());
}
});
if (feed != null) {
feedManagerFeedService.checkFeedPermission(feed.getId(), FeedAccessControl.EDIT_DETAILS);
}
if (feed != null) {
transformer.applyFeedNameToCurrentFeedProperties(serviceLevelAgreement, feed.getCategory().getSystemName(), feed.getSystemFeedName());
}
ServiceLevelAgreement sla = transformer.getServiceLevelAgreement(serviceLevelAgreement);
ServiceLevelAgreementBuilder slaBuilder = null;
com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement.ID existingId = null;
if (StringUtils.isNotBlank(sla.getId())) {
existingId = slaProvider.resolve(sla.getId());
}
if (existingId != null) {
slaBuilder = slaProvider.builder(existingId);
} else {
slaBuilder = slaProvider.builder();
}
slaBuilder.name(sla.getName()).description(sla.getDescription());
for (com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup group : sla.getGroups()) {
ObligationGroupBuilder groupBuilder = slaBuilder.obligationGroupBuilder(ObligationGroup.Condition.valueOf(group.getCondition()));
for (Obligation o : group.getObligations()) {
groupBuilder.obligationBuilder().metric(o.getMetrics()).description(o.getDescription()).build();
}
groupBuilder.build();
}
com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement savedSla = slaBuilder.build();
List<ServiceLevelAgreementActionConfiguration> actions = transformer.getActionConfigurations(serviceLevelAgreement);
// now assign the sla checks
slaProvider.slaCheckBuilder(savedSla.getId()).removeSlaChecks().actionConfigurations(actions).build();
// relate them
Set<Feed.ID> feedIds = new HashSet<>();
FeedServiceLevelAgreementRelationship feedServiceLevelAgreementRelationship = feedSlaProvider.relateFeeds(savedSla, slaFeeds);
if (feedServiceLevelAgreementRelationship != null && feedServiceLevelAgreementRelationship.getFeeds() != null) {
feedIds = feedServiceLevelAgreementRelationship.getFeeds().stream().map(f -> f.getId()).collect(Collectors.toSet());
}
Set<VelocityTemplate.ID> velocityTemplates = findVelocityTemplates(serviceLevelAgreement);
// Update the JPA mapping in Ops Manager for this SLA and its related Feeds
serviceLevelAgreementDescriptionProvider.updateServiceLevelAgreement(savedSla.getId(), savedSla.getName(), savedSla.getDescription(), feedIds, velocityTemplates);
com.thinkbiganalytics.metadata.rest.model.sla.FeedServiceLevelAgreement restModel = serviceLevelAgreementTransform.toModel(savedSla, slaFeeds, true);
// schedule it
serviceLevelAgreementScheduler.scheduleServiceLevelAgreement(savedSla);
return restModel;
});
}
}
return null;
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class FeedWaterMarkService method cancelActiveWaterMark.
public void cancelActiveWaterMark(String feedId, String waterMarkName) {
com.thinkbiganalytics.metadata.api.feed.Feed.ID updId = this.metadata.read(() -> {
this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_FEEDS);
com.thinkbiganalytics.metadata.api.feed.Feed.ID id = feedProvider.resolveFeed(feedId);
com.thinkbiganalytics.metadata.api.feed.Feed feed = feedProvider.getFeed(id);
if (feed != null) {
return feed.getId();
} else {
throw new FeedNotFoundException(id);
}
});
cancelActiveWaterMark(updId, waterMarkName);
}
Aggregations