Search in sources :

Example 1 with ServiceLevelAssessment

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

the class DefaultServiceLevelAgreementChecker method checkAgreement.

/**
 * Check the Agreement. Caller needs to wrap this in MetadataAccesss transcation
 */
public void checkAgreement(ServiceLevelAgreement agreement) {
    if (agreement != null) {
        Alert newAlert = null;
        if (isAssessable(agreement)) {
            LOG.info("Assessing SLA  : " + agreement.getName());
            try {
                ServiceLevelAssessment assessment = assessor.assess(agreement);
                if (shouldAlert(agreement, assessment)) {
                    newAlert = alertManager.createEntityAlert(AssessmentAlerts.VIOLATION_ALERT_TYPE, Alert.Level.FATAL, "Violation of SLA: " + agreement.getName(), alertManager.createEntityIdentificationAlertContent(agreement.getId().toString(), SecurityRole.ENTITY_TYPE.SLA, assessment.getId()));
                }
            } catch (AssessorNotFoundException e) {
                LOG.info("SLA assessment failed.  Assessor Not found: {} - Exception: {}", agreement.getName(), e);
            }
        }
        if (newAlert != null) {
            // Record this assessment as the latest for this SLA.
            alertedAssessments.put(agreement.getId(), (ServiceLevelAssessment.ID) newAlert.getContent());
            LOG.info("SLA assessment failed: {} - generated alert: {}", agreement.getName(), newAlert.getId());
        }
    }
}
Also used : ServiceLevelAssessment(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment) AssessorNotFoundException(com.thinkbiganalytics.metadata.sla.spi.AssessorNotFoundException) Alert(com.thinkbiganalytics.alerts.api.Alert)

Example 2 with ServiceLevelAssessment

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment 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 3 with ServiceLevelAssessment

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment 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 ServiceLevelAssessment

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment 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 ServiceLevelAssessment

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment 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

ServiceLevelAssessment (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment)19 ServiceLevelAgreement (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)18 Test (org.junit.Test)14 AssessorNotFoundException (com.thinkbiganalytics.metadata.sla.spi.AssessorNotFoundException)2 Alert (com.thinkbiganalytics.alerts.api.Alert)1 PreconditionTriggerEvent (com.thinkbiganalytics.metadata.api.event.feed.PreconditionTriggerEvent)1 FeedPrecondition (com.thinkbiganalytics.metadata.api.feed.FeedPrecondition)1 JcrServiceLevelAgreementCheck (com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreementCheck)1 AssessmentResult (com.thinkbiganalytics.metadata.sla.api.AssessmentResult)1 Obligation (com.thinkbiganalytics.metadata.sla.api.Obligation)1 ObligationAssessment (com.thinkbiganalytics.metadata.sla.api.ObligationAssessment)1 ObligationGroup (com.thinkbiganalytics.metadata.sla.api.ObligationGroup)1 Condition (com.thinkbiganalytics.metadata.sla.api.ObligationGroup.Condition)1 ServiceLevelAgreementAction (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementAction)1 ServiceLevelAgreementActionConfiguration (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfiguration)1 ServiceLevelAgreementActionValidation (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionValidation)1 ServiceLevelAgreementCheck (com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementCheck)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1