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