use of com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreementCheck in project kylo by Teradata.
the class ServiceLevelAgreementActionAlertResponderFactory method handleViolation.
/**
* handle the violation. Return true if the sla has actions configured in additional generating an alert.
* @param alert the alert
* @return true if additional actions were triggered, false if not
*/
private boolean handleViolation(Alert alert) {
return metadataAccess.read(() -> {
ServiceLevelAssessment.ID assessmentId = alert.getContent();
ServiceLevelAssessment assessment = assessmentProvider.findServiceLevelAssessment(assessmentId);
ServiceLevelAgreement agreement = assessment.getAgreement();
assessmentProvider.ensureServiceLevelAgreementOnAssessment(assessment);
agreement = assessment.getAgreement();
boolean hasActions = false;
if (agreement != null && agreement.getSlaChecks() != null && !agreement.getSlaChecks().isEmpty()) {
for (ServiceLevelAgreementCheck check : agreement.getSlaChecks()) {
for (ServiceLevelAgreementActionConfiguration configuration : ((JcrServiceLevelAgreementCheck) check).getActionConfigurations(true)) {
List<Class<? extends ServiceLevelAgreementAction>> responders = configuration.getActionClasses();
if (responders != null) {
// first check to see if there is a Spring Bean configured for this class type... if so call that
for (Class<? extends ServiceLevelAgreementAction> responderClass : responders) {
ServiceLevelAgreementAction action = ServiceLevelAgreementActionUtil.instantiate(responderClass);
if (action != null) {
hasActions = true;
log.info("Found {} action", action.getClass().getName());
// reassign the content of the alert to the ServiceLevelAssessment
// validate the action is ok
ServiceLevelAgreementActionValidation validation = ServiceLevelAgreementActionUtil.validateConfiguration(action);
if (validation.isValid()) {
action.respond(configuration, assessment, alert);
} else {
log.error("Unable to invoke SLA ImmutableAction {} while assessing {} due to Configuration error: {}. Please fix.", action.getClass(), agreement.getName(), validation.getValidationMessage());
}
}
}
}
}
}
}
return hasActions;
}, MetadataAccess.SERVICE);
}
Aggregations