use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementAction in project kylo by Teradata.
the class ServiceLevelAgreementActionConfigTransformer method validateAction.
public List<ServiceLevelAgreementActionValidation> validateAction(String actionConfigurationClassName) {
List<ServiceLevelAgreementActionValidation> validation = null;
try {
Class<? extends ServiceLevelAgreementActionConfiguration> configurationClass = ClassNameChangeRegistry.findClass(actionConfigurationClassName);
ServiceLevelAgreementActionConfig annotation = (ServiceLevelAgreementActionConfig) configurationClass.getAnnotation(ServiceLevelAgreementActionConfig.class);
Class<? extends ServiceLevelAgreementAction>[] actions = annotation.actionClasses();
if (actions != null) {
List<Class<? extends ServiceLevelAgreementAction>> actionClassList = Lists.newArrayList(actions);
validation = ServiceLevelAgreementActionUtil.validateActionConfiguration(actionClassList);
} else {
validation.add(new ServiceLevelAgreementActionValidation(false, "No Actions are defined for :" + actionConfigurationClassName));
}
} catch (ClassNotFoundException e) {
if (validation != null) {
validation.add(new ServiceLevelAgreementActionValidation(false, "ImmutableAction Configuration Not Found: " + e.getMessage()));
}
}
return validation;
}
use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementAction 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