use of com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed in project kylo by Teradata.
the class MetadataClientProviderTest method testEnsurePrecondition.
@Test
public void testEnsurePrecondition() {
Feed feed = this.provider.ensureFeed("category", "test5", "");
try {
feed = this.provider.ensurePrecondition(feed.getId(), new DatasourceUpdatedSinceFeedExecuted("ds5", "test5"), new DatasourceUpdatedSinceSchedule("ds5", "0 0 6 * * ? *"), new FeedExecutedSinceFeed("category", "dep5", "category", "test5"), new FeedExecutedSinceSchedule("category", "test5", "0 0 6 * * ? *"), new com.thinkbiganalytics.metadata.api.sla.WithinSchedule("0 0 6 * * ? *", "2 hours"));
} catch (ParseException e) {
e.printStackTrace();
;
}
assertThat(feed).isNotNull();
}
use of com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed in project kylo by Teradata.
the class FeedExecutedSinceFeedAssessor method assess.
@Override
public void assess(FeedExecutedSinceFeed metric, MetricAssessmentBuilder<Serializable> builder) {
LOG.debug("Assessing metric {}", metric.getDescription());
FeedProvider feedProvider = getFeedProvider();
FeedOperationsProvider opsProvider = getFeedOperationsProvider();
List<Feed> mainFeeds = feedProvider.getFeeds(feedProvider.feedCriteria().name(metric.getFeedName()).category(metric.getCategoryName()));
LOG.debug("Main feeds {}", mainFeeds);
List<Feed> triggeredFeeds = feedProvider.getFeeds(feedProvider.feedCriteria().name(metric.getSinceFeedName()).category(metric.getSinceCategoryName()));
LOG.debug("Triggered feeds {}", triggeredFeeds);
builder.metric(metric);
if (!mainFeeds.isEmpty() && !triggeredFeeds.isEmpty()) {
Feed mainFeed = mainFeeds.get(0);
Feed triggeredFeed = triggeredFeeds.get(0);
List<FeedOperation> mainFeedOps = opsProvider.findLatestCompleted(mainFeed.getId());
List<FeedOperation> triggeredFeedOps = opsProvider.findLatest(triggeredFeed.getId());
if (mainFeedOps.isEmpty()) {
// If the feed we are checking has never run then it can't have run before the "since" feed.
LOG.debug("Main feed ops is empty");
builder.result(AssessmentResult.FAILURE).message("Main feed " + mainFeed.getName() + " has never executed.");
} else {
// If the "since" feed has never run then the tested feed has run before it.
if (triggeredFeedOps.isEmpty()) {
LOG.debug("Triggered feed ops is empty");
builder.result(AssessmentResult.SUCCESS).message("Triggered feed " + triggeredFeed.getName() + " has never executed");
} else {
DateTime mainFeedStopTime = mainFeedOps.get(0).getStopTime();
DateTime triggeredFeedStartTime = triggeredFeedOps.get(0).getStartTime();
LOG.debug("Main feed stop time {}", mainFeedStopTime);
LOG.debug("Triggered feed start time {}", triggeredFeedStartTime);
if (mainFeedStopTime.isBefore(triggeredFeedStartTime)) {
LOG.debug("Main feed stop time is before triggered feed start time");
builder.result(AssessmentResult.FAILURE).message("Main feed " + mainFeed.getName() + " has not executed since triggered feed " + triggeredFeed.getName() + ": " + triggeredFeedStartTime);
} else {
LOG.debug("Main feed stop time is after triggered feed start time");
boolean isMainFeedRunning = opsProvider.isFeedRunning(mainFeed.getId());
if (isMainFeedRunning) {
// todo whether to trigger the feed while the other one is already running should be a
// configuration parameter defined by the user
LOG.debug("Main feed is still running");
builder.result(AssessmentResult.SUCCESS).message("Triggered feed " + triggeredFeed.getName() + " has executed since feed " + mainFeed.getName() + ", but main feed " + mainFeed.getName() + " is still running");
} else {
LOG.debug("Main is not running");
builder.result(AssessmentResult.SUCCESS).message("Triggered feed " + triggeredFeed.getName() + " has executed since main feed " + mainFeed.getName() + ".");
}
}
}
}
} else {
LOG.debug("Either triggered or main feed does not exist");
builder.result(AssessmentResult.FAILURE).message("Either feed " + metric.getSinceCategoryAndFeedName() + " and/or feed " + metric.getSinceCategoryAndFeedName() + " does not exist.");
}
}
use of com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed in project kylo by Teradata.
the class FeedExecutedSinceFeedAssessorTest method setUp.
@Before
public void setUp() {
metric = new FeedExecutedSinceFeed("mainCategory.mainFeed", "triggeredCategory.triggeredFeed");
builder = new TestMetricAssessmentBuilder();
}
use of com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed in project kylo by Teradata.
the class ServiceLevelAgreementClientTest method testCreateSLA.
// @Test
public void testCreateSLA() {
ServiceLevelAgreement sla = new ServiceLevelAgreement("TestSLA1", new FeedExecutedSinceFeed("category", "FeedA", "category", "FeedX"), new FeedExecutedSinceFeed("category", "FeedB", "category", "FeedX"));
ServiceLevelAgreement result = client.createSla(sla);
assertThat(result).isNotNull();
}
use of com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed in project kylo by Teradata.
the class FeedExecutedSinceFeeds method buildPreconditionObligation.
/**
* Builds the ObligationGroup that holds the metric that will be used to assess if this precondition is met or not
*/
public com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup buildPreconditionObligation() {
Set<Metric> metrics = new HashSet<>();
for (String categoryAndFeed : categoryAndFeedList) {
FeedExecutedSinceFeed metric = new FeedExecutedSinceFeed(sinceCategoryAndFeedName, categoryAndFeed);
metrics.add(metric);
}
Obligation obligation = new Obligation();
obligation.setMetrics(Lists.newArrayList(metrics));
com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup group = new com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup();
group.addObligation(obligation);
group.setCondition(ObligationGroup.Condition.REQUIRED.name());
return group;
}
Aggregations