Search in sources :

Example 1 with ServiceLevelAgreement

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.

the class DefaultServiceLevelAgreementChecker method shouldAlert.

/**
 * Determine whether an alert should be generated for this assessment by comparing is to the last one for the same SLA.
 *
 * @return true if the alert should be generated
 */
protected boolean shouldAlert(ServiceLevelAgreement agreement, ServiceLevelAssessment assessment) {
    boolean shouldAlert = false;
    try {
        // Get the last assessment that was created for this SLA (if any).
        ServiceLevelAssessment previous = null;
        ServiceLevelAssessment.ID previousId = this.alertedAssessments.get(agreement.getId());
        if (previousId != null) {
            previous = this.assessmentProvider.findServiceLevelAssessment(previousId);
        } else {
            previous = this.assessmentProvider.findLatestAssessment(agreement.getId());
        }
        if (previous != null) {
            if (previous.getAgreement() == null && assessment.getServiceLevelAgreementId() != null) {
                ServiceLevelAgreement previousAgreement = slaProvider.getAgreement(slaProvider.resolve(assessment.getServiceLevelAgreementId().toString()));
            }
            shouldAlert = assessment.compareTo(previous) != 0;
        } else {
            shouldAlert = true;
        }
    } catch (Exception e) {
        LOG.error("Error checking shouldAlert for {}. {} ", agreement.getName(), e.getMessage(), e);
    }
    return shouldAlert;
}
Also used : ServiceLevelAssessment(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) AssessorNotFoundException(com.thinkbiganalytics.metadata.sla.spi.AssessorNotFoundException)

Example 2 with ServiceLevelAgreement

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.

the class InMemorySLAProviderTest method testReplace.

@Test
public void testReplace() {
    ServiceLevelAgreement.ID id = this.provider.builder().name("First").build().getId();
    this.provider.builder(id).name("Second").build();
    ServiceLevelAgreement second = this.provider.getAgreement(id);
    assertThat(second).isNotNull();
    assertThat(second.getName()).isEqualTo("Second");
}
Also used : ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) Test(org.junit.Test)

Example 3 with ServiceLevelAgreement

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.

the class SimpleServiceLevelAssessmentCompareTest method testCompareEqualMetricComparables.

@Test
public void testCompareEqualMetricComparables() {
    this.assessor.registerMetricAssessor(new TestMetricAssessor(1, "1"));
    ServiceLevelAgreement sla = this.provider.builder().name("test").obligationBuilder().description("test").metric(new TestMetric(1, "1")).build().build();
    ServiceLevelAssessment assmt1 = this.assessor.assess(sla);
    ServiceLevelAssessment assmt2 = this.assessor.assess(sla);
    assertThat(assmt1).isEqualByComparingTo(assmt2);
}
Also used : ServiceLevelAssessment(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) Test(org.junit.Test)

Example 4 with ServiceLevelAgreement

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.

the class SimpleServiceLevelAssessmentCompareTest method testCompareNotEqualMetricComparables.

@Test
public void testCompareNotEqualMetricComparables() {
    TestMetric metric = new TestMetric(1, "1");
    this.assessor.registerMetricAssessor(new TestMetricAssessor(1, "1"));
    ServiceLevelAgreement sla = this.provider.builder().name("test").obligationBuilder().description("test").metric(metric).build().build();
    ServiceLevelAssessment assmt1 = this.assessor.assess(sla);
    metric.setIntValue(2);
    ServiceLevelAssessment assmt2 = this.assessor.assess(sla);
    assertThat(assmt1).isNotEqualByComparingTo(assmt2);
    assertThat(assmt1).isLessThan(assmt2);
}
Also used : ServiceLevelAssessment(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) Test(org.junit.Test)

Example 5 with ServiceLevelAgreement

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.

the class SimpleServiceLevelAssessmentCompareTest method testCompareNotEqualObligationComparables.

@Test
public void testCompareNotEqualObligationComparables() {
    TestObligatinAssessor obAssessor = new TestObligatinAssessor("aaa");
    this.assessor.registerMetricAssessor(new TestMetricAssessor(1, "1"));
    this.assessor.registerObligationAssessor(obAssessor);
    ServiceLevelAgreement sla = this.provider.builder().name("test").obligationBuilder().description("aaa").metric(new TestMetric(1, "1")).build().build();
    ServiceLevelAssessment assmt1 = this.assessor.assess(sla);
    obAssessor.setExpectedDescription("bbb");
    ServiceLevelAssessment assmt2 = this.assessor.assess(sla);
    assertThat(assmt1).isNotEqualByComparingTo(assmt2);
    assertThat(assmt1).isLessThan(assmt2);
}
Also used : ServiceLevelAssessment(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) Test(org.junit.Test)

Aggregations

ServiceLevelAgreement (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)44 Test (org.junit.Test)20 ServiceLevelAssessment (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment)19 JcrServiceLevelAgreement (com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement)8 ArrayList (java.util.ArrayList)6 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)5 Obligation (com.thinkbiganalytics.metadata.sla.api.Obligation)5 Node (javax.jcr.Node)5 JobIdentifier (com.thinkbiganalytics.scheduler.JobIdentifier)4 DefaultJobIdentifier (com.thinkbiganalytics.scheduler.model.DefaultJobIdentifier)4 List (java.util.List)4 Set (java.util.Set)4 Lists (com.google.common.collect.Lists)3 FeedServiceLevelAgreement (com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreement)3 FeedServiceLevelAgreementProvider (com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreementProvider)3 FeedServiceLevelAgreementRelationship (com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreementRelationship)3 JcrMetadataAccess (com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess)3 MetadataRepositoryException (com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException)3 JcrFeed (com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed)3 JcrPropertyUtil (com.thinkbiganalytics.metadata.modeshape.support.JcrPropertyUtil)3