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;
}
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);
}
}
}
}
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;
}
};
}
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);
}
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;
}
Aggregations