use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionValidation in project kylo by Teradata.
the class ServiceLevelAgreementActionUtil method validateConfiguration.
public static ServiceLevelAgreementActionValidation validateConfiguration(ServiceLevelAgreementAction action) {
if (validActionCache.containsKey(action.getClass()) && validActionCache.get(action.getClass()) == true) {
return ServiceLevelAgreementActionValidation.VALID;
}
if (action != null) {
ServiceLevelAgreementActionValidation validAction = action.validateConfiguration();
validAction.setActionClass(action.getClass().getName());
validActionCache.put(action.getClass(), validAction.isValid());
return validAction;
}
return new ServiceLevelAgreementActionValidation(false, "Unable to find SLA Action ");
}
use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionValidation 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.ServiceLevelAgreementActionValidation 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