use of com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed in project kylo by Teradata.
the class JpaFeedProviderTest method testFindFeedUsingGenericFilter.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin" })
@Test
public void testFindFeedUsingGenericFilter() {
// Create feed
final String name = "testCategory.testFeed";
final String id = metadataAccess.commit(() -> {
final OpsManagerFeed.ID feedId = feedProvider.resolveId(UUID.randomUUID().toString());
feedProvider.save(feedId, name, false, 1000L);
return feedId.toString();
});
// Add ACL entries
final BaseFeed.FeedId feedId = new BaseFeed.FeedId(id);
final JpaFeedOpsAclEntry userAcl = new JpaFeedOpsAclEntry(feedId, "dladmin", JpaFeedOpsAclEntry.PrincipalType.USER);
final JpaFeedOpsAclEntry adminAcl = new JpaFeedOpsAclEntry(feedId, "admin", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclProvider.grantAccess(feedId, new UsernamePrincipal("dladmin"), new GroupPrincipal("admin"));
// Verify access to feeds
metadataAccess.read(() -> {
List<OpsManagerFeed> feeds = feedProvider.findAll("name:" + name);
Assert.assertTrue(feeds != null && !feeds.isEmpty());
List<String> feedNames = feedProvider.getFeedNames();
Assert.assertTrue(feedNames != null && !feedNames.isEmpty());
return feeds;
});
}
use of com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed in project kylo by Teradata.
the class OpsFeedManagerFeedProvider method delete.
@Override
public void delete(OpsManagerFeed.ID id) {
OpsManagerFeed feed = repository.findByIdWithoutAcl(id);
if (feed != null) {
log.info("Deleting feed {} ({}) and all job executions. ", feed.getName(), feed.getId());
// first delete all jobs for this feed
deleteFeedJobs(FeedNameUtil.category(feed.getName()), FeedNameUtil.feed(feed.getName()));
// remove an slas on this feed
List<JpaServiceLevelAgreementDescription> slas = serviceLevelAgreementDescriptionRepository.findForFeed(id);
if (slas != null && !slas.isEmpty()) {
serviceLevelAgreementDescriptionRepository.delete(slas);
}
feedStatisticsProvider.deleteFeedStats(feed.getName());
delete(feed);
log.info("Successfully deleted the feed {} ({}) and all job executions. ", feed.getName(), feed.getId());
}
}
use of com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed in project kylo by Teradata.
the class OpsFeedManagerFeedProvider method getLastActiveTimeStamp.
@Override
public DateTime getLastActiveTimeStamp(String feedName) {
DateTime lastFeedTime = null;
OpsManagerFeed feed = this.findByName(feedName);
if (feed.isStream()) {
NifiFeedStats feedStats = metadataAccess.read(() -> nifiFeedStatisticsProvider.findLatestStatsForFeed(feedName));
if (feedStats != null && feedStats.getLastActivityTimestamp() != null) {
lastFeedTime = new DateTime(feedStats.getLastActivityTimestamp());
} else {
log.warn("feedStats.getLastActivityTimestamp is null for streaming feed {} ", feedName);
}
} else {
BatchJobExecution jobExecution = metadataAccess.read(() -> batchJobExecutionProvider.findLatestCompletedJobForFeed(feedName));
if (jobExecution != null) {
lastFeedTime = jobExecution.getEndTime();
}
}
return lastFeedTime;
}
use of com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed 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.OpsManagerFeed in project kylo by Teradata.
the class JpaBatchJobExecutionProvider method notifyFailure.
public void notifyFailure(BatchJobExecution jobExecution, String feedName, boolean isStream, String status) {
OpsManagerFeed feed = jobExecution.getJobInstance().getFeed();
notifyFailure(jobExecution, feed, isStream, status);
}
Aggregations