Search in sources :

Example 16 with ServiceLevelAgreement

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.

the class ServiceLevelAgreementModelTransform method toModel.

public static com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreement toModel(ServiceLevelAgreement domain, boolean deep) {
    com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreement sla = new com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreement(domain.getId().toString(), domain.getName(), domain.getDescription());
    if (domain.getSlaChecks() != null) {
        List<ServiceLevelAgreementCheck> checks = new ArrayList<>();
        sla.setSlaChecks(checks);
        for (com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementCheck check : domain.getSlaChecks()) {
            ServiceLevelAgreementCheck restModel = new ServiceLevelAgreementCheck();
            restModel.setCronSchedule(check.getCronSchedule());
            if (deep) {
                try {
                    restModel.setActionConfigurations(check.getActionConfigurations());
                } catch (Exception e) {
                    if (ExceptionUtils.getRootCause(e) instanceof ClassNotFoundException) {
                        String msg = ExceptionUtils.getRootCauseMessage(e);
                        // get just the simpleClassName stripping the package info
                        msg = StringUtils.substringAfterLast(msg, ".");
                        sla.addSlaCheckError("Unable to find the SLA Action Configurations of type: " + msg + ". Check with an administrator to ensure the correct plugin is installed with this SLA configuration. ");
                    } else {
                        throw new RuntimeException(e);
                    }
                }
            }
            checks.add(restModel);
        }
    }
    if (deep) {
        if (domain.getObligationGroups().size() == 1 && domain.getObligationGroups().get(0).getCondition() == ObligationGroup.Condition.REQUIRED) {
            for (Obligation domainOb : domain.getObligations()) {
                com.thinkbiganalytics.metadata.rest.model.sla.Obligation ob = toModel(domainOb, true);
                sla.addObligation(ob);
            }
        } else {
            for (ObligationGroup domainGroup : domain.getObligationGroups()) {
                // Force it to be required
                // TODO Rework once the SLA page allows for Sufficient/Required settings
                // TODO use the domainGroup.condition instead
                com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup group = new com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup(ObligationGroup.Condition.REQUIRED.name());
                for (Obligation domainOb : domainGroup.getObligations()) {
                    com.thinkbiganalytics.metadata.rest.model.sla.Obligation ob = toModel(domainOb, true);
                    group.addObligation(ob);
                }
                sla.addGroup(group);
            }
        }
    }
    return sla;
}
Also used : Obligation(com.thinkbiganalytics.metadata.sla.api.Obligation) ServiceLevelAgreementCheck(com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreementCheck) ArrayList(java.util.ArrayList) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) FeedServiceLevelAgreement(com.thinkbiganalytics.metadata.rest.model.sla.FeedServiceLevelAgreement) ObligationGroup(com.thinkbiganalytics.metadata.sla.api.ObligationGroup)

Example 17 with ServiceLevelAgreement

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.

the class FeedPreconditionService method checkPrecondition.

private void checkPrecondition(Feed feed, OperationStatus operationStatus) {
    FeedPrecondition precond = feed.getPrecondition();
    if (precond != null) {
        log.debug("Checking precondition of feed: {} ({})", feed.getName(), feed.getId());
        ServiceLevelAgreement sla = precond.getAgreement();
        boolean isAssess = sla.getAllMetrics().stream().anyMatch(metric -> isMetricDependentOnStatus(metric, operationStatus));
        if (isAssess) {
            ServiceLevelAssessment assessment = this.assessor.assess(sla);
            if (assessment.getResult() == AssessmentResult.SUCCESS) {
                log.info("Firing precondition trigger event for feed:{} ({})", feed.getName(), feed.getId());
                this.eventService.notify(new PreconditionTriggerEvent(feed.getId()));
            }
        } else {
            log.debug("Feed {}.{} does not depend on feed {}", feed.getCategory(), feed.getName(), operationStatus.getFeedName());
        }
    }
}
Also used : ServiceLevelAssessment(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment) PreconditionTriggerEvent(com.thinkbiganalytics.metadata.api.event.feed.PreconditionTriggerEvent) FeedPrecondition(com.thinkbiganalytics.metadata.api.feed.FeedPrecondition) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)

Example 18 with ServiceLevelAgreement

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement 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)

Example 19 with ServiceLevelAgreement

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.

the class SlaQuartzJobBean method executeInternal.

@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
    // query for this SLA
    final Map<String, Object> jobDataMap = context.getMergedJobDataMap();
    metadataAccess.commit(() -> {
        ServiceLevelAgreement.ID slaId = (ServiceLevelAgreement.ID) jobDataMap.get(SLA_ID_PARAM);
        ServiceLevelAgreement sla = slaProvider.getAgreement(slaId);
        if (sla != null) {
            // unscheduleServiceLevelAgreement(slaId);
            if (sla.isEnabled()) {
                slaChecker.checkAgreement(sla);
            } else {
                log.info("SLA {} will not fire since it is disabled ", sla.getName());
            }
        } else {
            log.error("UNABLE TO FIND SLA for {} ", slaId);
        }
    }, MetadataAccess.SERVICE);
}
Also used : ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)

Example 20 with ServiceLevelAgreement

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.

the class InMemoryFeedProvider method ensureFeedSource.

private FeedSource ensureFeedSource(BaseFeed feed, Datasource ds, ServiceLevelAgreement.ID slaId) {
    Map<Datasource.ID, FeedSource> srcIds = new HashMap<>();
    for (FeedSource src : feed.getSources()) {
        srcIds.put(src.getDatasource().getId(), src);
    }
    if (srcIds.containsKey(ds.getId())) {
        return srcIds.get(ds.getId());
    } else {
        ServiceLevelAgreement sla = this.slaProvider.getAgreement(slaId);
        FeedSource src = feed.addSource(ds, sla);
        return src;
    }
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) FeedSource(com.thinkbiganalytics.metadata.api.feed.FeedSource) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) ID(com.thinkbiganalytics.metadata.api.datasource.Datasource.ID)

Aggregations

ServiceLevelAgreement (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)44 Test (org.junit.Test)20 ServiceLevelAssessment (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment)19 JcrServiceLevelAgreement (com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement)8 ArrayList (java.util.ArrayList)6 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)5 Obligation (com.thinkbiganalytics.metadata.sla.api.Obligation)5 Node (javax.jcr.Node)5 JobIdentifier (com.thinkbiganalytics.scheduler.JobIdentifier)4 DefaultJobIdentifier (com.thinkbiganalytics.scheduler.model.DefaultJobIdentifier)4 List (java.util.List)4 Set (java.util.Set)4 Lists (com.google.common.collect.Lists)3 FeedServiceLevelAgreement (com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreement)3 FeedServiceLevelAgreementProvider (com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreementProvider)3 FeedServiceLevelAgreementRelationship (com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreementRelationship)3 JcrMetadataAccess (com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess)3 MetadataRepositoryException (com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException)3 JcrFeed (com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed)3 JcrPropertyUtil (com.thinkbiganalytics.metadata.modeshape.support.JcrPropertyUtil)3