Search in sources :

Example 1 with FeedExecutedSinceFeed

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();
}
Also used : FeedExecutedSinceSchedule(com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceSchedule) DatasourceUpdatedSinceFeedExecuted(com.thinkbiganalytics.metadata.api.sla.DatasourceUpdatedSinceFeedExecuted) DatasourceUpdatedSinceSchedule(com.thinkbiganalytics.metadata.api.sla.DatasourceUpdatedSinceSchedule) ParseException(java.text.ParseException) FeedExecutedSinceFeed(com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed) Feed(com.thinkbiganalytics.metadata.rest.model.feed.Feed) FeedExecutedSinceFeed(com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed) Test(org.junit.Test)

Example 2 with FeedExecutedSinceFeed

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.");
    }
}
Also used : FeedOperation(com.thinkbiganalytics.metadata.api.op.FeedOperation) FeedOperationsProvider(com.thinkbiganalytics.metadata.api.op.FeedOperationsProvider) 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 3 with FeedExecutedSinceFeed

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();
}
Also used : FeedExecutedSinceFeed(com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed) Before(org.junit.Before)

Example 4 with FeedExecutedSinceFeed

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();
}
Also used : ServiceLevelAgreement(com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreement) FeedExecutedSinceFeed(com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed)

Example 5 with FeedExecutedSinceFeed

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;
}
Also used : Obligation(com.thinkbiganalytics.metadata.rest.model.sla.Obligation) FeedExecutedSinceFeed(com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed) Metric(com.thinkbiganalytics.metadata.sla.api.Metric) ObligationGroup(com.thinkbiganalytics.metadata.sla.api.ObligationGroup) HashSet(java.util.HashSet)

Aggregations

FeedExecutedSinceFeed (com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed)6 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)1 FeedProvider (com.thinkbiganalytics.metadata.api.feed.FeedProvider)1 FeedOperation (com.thinkbiganalytics.metadata.api.op.FeedOperation)1 FeedOperationsProvider (com.thinkbiganalytics.metadata.api.op.FeedOperationsProvider)1 DatasourceUpdatedSinceFeedExecuted (com.thinkbiganalytics.metadata.api.sla.DatasourceUpdatedSinceFeedExecuted)1 DatasourceUpdatedSinceSchedule (com.thinkbiganalytics.metadata.api.sla.DatasourceUpdatedSinceSchedule)1 FeedExecutedSinceSchedule (com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceSchedule)1 JcrPath (com.thinkbiganalytics.metadata.modeshape.support.JcrPath)1 Feed (com.thinkbiganalytics.metadata.rest.model.feed.Feed)1 FeedPrecondition (com.thinkbiganalytics.metadata.rest.model.feed.FeedPrecondition)1 Obligation (com.thinkbiganalytics.metadata.rest.model.sla.Obligation)1 ServiceLevelAgreement (com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreement)1 Metric (com.thinkbiganalytics.metadata.sla.api.Metric)1 ObligationGroup (com.thinkbiganalytics.metadata.sla.api.ObligationGroup)1 ParseException (java.text.ParseException)1 HashSet (java.util.HashSet)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1