Search in sources :

Example 1 with OpsManagerFeed

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;
    });
}
Also used : UsernamePrincipal(com.thinkbiganalytics.security.UsernamePrincipal) OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed) GroupPrincipal(com.thinkbiganalytics.security.GroupPrincipal) BaseFeed(com.thinkbiganalytics.metadata.core.feed.BaseFeed) JpaFeedOpsAclEntry(com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry) Test(org.junit.Test) WithMockJaasUser(com.thinkbiganalytics.test.security.WithMockJaasUser)

Example 2 with OpsManagerFeed

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());
    }
}
Also used : OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed) JpaServiceLevelAgreementDescription(com.thinkbiganalytics.metadata.jpa.sla.JpaServiceLevelAgreementDescription)

Example 3 with OpsManagerFeed

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;
}
Also used : OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed) BatchJobExecution(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution) QJpaBatchJobExecution(com.thinkbiganalytics.metadata.jpa.jobrepo.job.QJpaBatchJobExecution) JpaNifiFeedStats(com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.JpaNifiFeedStats) NifiFeedStats(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedStats) DateTime(org.joda.time.DateTime)

Example 4 with OpsManagerFeed

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));
}
Also used : FeedOperationStatusEvent(com.thinkbiganalytics.metadata.api.event.feed.FeedOperationStatusEvent) OperationStatus(com.thinkbiganalytics.metadata.api.event.feed.OperationStatus) FeedOperation(com.thinkbiganalytics.metadata.api.op.FeedOperation) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed)

Example 5 with OpsManagerFeed

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);
}
Also used : OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed) JpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.JpaOpsManagerFeed) QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed)

Aggregations

OpsManagerFeed (com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed)23 BatchJobExecution (com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution)6 ArrayList (java.util.ArrayList)6 JpaOpsManagerFeed (com.thinkbiganalytics.metadata.jpa.feed.JpaOpsManagerFeed)4 HashMap (java.util.HashMap)4 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)3 NifiFeedStats (com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedStats)3 QJpaOpsManagerFeed (com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed)3 JpaNifiFeedStats (com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.JpaNifiFeedStats)3 DateTime (org.joda.time.DateTime)3 CacheBuilder (com.google.common.cache.CacheBuilder)2 CacheLoader (com.google.common.cache.CacheLoader)2 LoadingCache (com.google.common.cache.LoadingCache)2 FeedHealth (com.thinkbiganalytics.jobrepo.query.model.FeedHealth)2 MetadataAccess (com.thinkbiganalytics.metadata.api.MetadataAccess)2 NifiFeedProcessorStats (com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats)2 ProvenanceEventRecordDTO (com.thinkbiganalytics.nifi.provenance.model.ProvenanceEventRecordDTO)2 ProvenanceEventRecordDTOHolder (com.thinkbiganalytics.nifi.provenance.model.ProvenanceEventRecordDTOHolder)2 Stopwatch (com.google.common.base.Stopwatch)1 EvictingQueue (com.google.common.collect.EvictingQueue)1