Search in sources :

Example 1 with FeedCriteria

use of com.thinkbiganalytics.metadata.api.feed.FeedCriteria in project kylo by Teradata.

the class InMemoryFeedProvider method findBySystemName.

@Override
public Feed findBySystemName(String categorySystemName, String systemName) {
    FeedCriteria c = feedCriteria();
    if (categorySystemName != null) {
        c.category(categorySystemName);
    }
    c.name(systemName);
    List<Feed> feeds = getFeeds(c);
    if (feeds != null && !feeds.isEmpty()) {
        return feeds.get(0);
    }
    return null;
}
Also used : FeedCriteria(com.thinkbiganalytics.metadata.api.feed.FeedCriteria) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Example 2 with FeedCriteria

use of com.thinkbiganalytics.metadata.api.feed.FeedCriteria in project kylo by Teradata.

the class FeedExecutedSinceScheduleAssessor method assess.

@Override
public void assess(FeedExecutedSinceSchedule metric, MetricAssessmentBuilder<Serializable> builder) {
    Date prev = CronExpressionUtil.getPreviousFireTime(metric.getCronExpression(), 2);
    DateTime schedTime = new DateTime(prev);
    String feedName = metric.getFeedName();
    FeedCriteria crit = getFeedProvider().feedCriteria().name(feedName);
    List<Feed> feeds = getFeedProvider().getFeeds(crit);
    if (feeds.size() > 0) {
        Feed feed = feeds.get(0);
        List<FeedOperation> list = this.getFeedOperationsProvider().findLatestCompleted(feed.getId());
        if (!list.isEmpty()) {
            FeedOperation latest = list.get(0);
            if (latest.getStopTime().isAfter(schedTime)) {
                builder.result(AssessmentResult.SUCCESS).message("Feed " + feed.getName() + " has executed at least 1 operation since " + schedTime);
            } else {
                builder.result(AssessmentResult.FAILURE).message("Feed " + feed.getName() + " has not executed any data operations since " + schedTime);
            }
        }
    }
}
Also used : FeedOperation(com.thinkbiganalytics.metadata.api.op.FeedOperation) FeedCriteria(com.thinkbiganalytics.metadata.api.feed.FeedCriteria) Date(java.util.Date) DateTime(org.joda.time.DateTime) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Example 3 with FeedCriteria

use of com.thinkbiganalytics.metadata.api.feed.FeedCriteria 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;
        }
    };
}
Also used : ArrayList(java.util.ArrayList) FeedOperation(com.thinkbiganalytics.metadata.api.op.FeedOperation) FeedOperationsProvider(com.thinkbiganalytics.metadata.api.op.FeedOperationsProvider) FeedCriteria(com.thinkbiganalytics.metadata.api.feed.FeedCriteria) FeedProvider(com.thinkbiganalytics.metadata.api.feed.FeedProvider) DateTime(org.joda.time.DateTime) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) FeedExecutedSinceFeed(com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed)

Example 4 with FeedCriteria

use of com.thinkbiganalytics.metadata.api.feed.FeedCriteria in project kylo by Teradata.

the class InMemoryFeedProvider method getFeeds.

@Override
public List<Feed> getFeeds(FeedCriteria criteria) {
    Criteria critImpl = (Criteria) criteria;
    Iterator<Feed> filtered = Iterators.filter(this.feeds.values().iterator(), critImpl);
    Iterator<Feed> limited = Iterators.limit(filtered, critImpl.getLimit());
    return ImmutableList.copyOf(limited);
}
Also used : AbstractMetadataCriteria(com.thinkbiganalytics.metadata.core.AbstractMetadataCriteria) FeedCriteria(com.thinkbiganalytics.metadata.api.feed.FeedCriteria) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Example 5 with FeedCriteria

use of com.thinkbiganalytics.metadata.api.feed.FeedCriteria in project kylo by Teradata.

the class JcrFeedProvider method findBySystemName.

@Override
public Feed findBySystemName(String categorySystemName, String systemName) {
    FeedCriteria c = feedCriteria();
    if (categorySystemName != null) {
        c.category(categorySystemName);
    }
    c.name(systemName);
    List<Feed> feeds = getFeeds(c);
    if (feeds != null && !feeds.isEmpty()) {
        return feeds.get(0);
    }
    return null;
}
Also used : FeedCriteria(com.thinkbiganalytics.metadata.api.feed.FeedCriteria) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Aggregations

Feed (com.thinkbiganalytics.metadata.api.feed.Feed)5 FeedCriteria (com.thinkbiganalytics.metadata.api.feed.FeedCriteria)5 FeedOperation (com.thinkbiganalytics.metadata.api.op.FeedOperation)2 DateTime (org.joda.time.DateTime)2 FeedProvider (com.thinkbiganalytics.metadata.api.feed.FeedProvider)1 FeedOperationsProvider (com.thinkbiganalytics.metadata.api.op.FeedOperationsProvider)1 FeedExecutedSinceFeed (com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed)1 AbstractMetadataCriteria (com.thinkbiganalytics.metadata.core.AbstractMetadataCriteria)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1