Search in sources :

Example 1 with ServiceLevelAgreementAction

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;
}
Also used : ServiceLevelAgreementAction(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementAction) ServiceLevelAgreementActionValidation(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionValidation) ServiceLevelAgreementActionConfig(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfig)

Example 2 with ServiceLevelAgreementAction

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);
}
Also used : ServiceLevelAssessment(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment) ServiceLevelAgreementAction(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementAction) JcrServiceLevelAgreementCheck(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreementCheck) ServiceLevelAgreementCheck(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementCheck) JcrServiceLevelAgreementCheck(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreementCheck) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) ServiceLevelAgreementActionValidation(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionValidation) ServiceLevelAgreementActionConfiguration(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfiguration)

Aggregations

ServiceLevelAgreementAction (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementAction)2 ServiceLevelAgreementActionValidation (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionValidation)2 JcrServiceLevelAgreementCheck (com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreementCheck)1 ServiceLevelAgreement (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)1 ServiceLevelAgreementActionConfig (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfig)1 ServiceLevelAgreementActionConfiguration (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfiguration)1 ServiceLevelAssessment (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment)1 ServiceLevelAgreementCheck (com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementCheck)1