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