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;
}
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());
}
}
}
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);
}
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);
}
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;
}
}
Aggregations