use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.
the class JcrFeedProvider method disableFeed.
@Override
public boolean disableFeed(Feed.ID id) {
Feed feed = getFeed(id);
if (accessController.isEntityAccessControlled()) {
feed.getAllowedActions().checkPermission(FeedAccessControl.ENABLE_DISABLE);
}
if (!feed.getState().equals(Feed.State.DISABLED)) {
feed.setState(Feed.State.DISABLED);
// disable any SLAs on this feed
List<ServiceLevelAgreement> serviceLevelAgreements = feed.getServiceLevelAgreements();
if (serviceLevelAgreements != null) {
for (ServiceLevelAgreement sla : serviceLevelAgreements) {
JcrServiceLevelAgreement jcrSla = (JcrServiceLevelAgreement) sla;
jcrSla.disabled();
}
}
return true;
}
return false;
}
use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.
the class JpaServiceLevelAssessmentProvider method ensureServiceLevelAgreementOnAssessment.
/**
* Makes sure the Service Level Assessment object has its respective SLA attached to it for reference lookups
*
* @param assessment the assessment to check and ensure it has its SLA attached
* @return {@code true} if it was able to attach the SLA to the assessment, {@code false} if it was not about to attach and find the SLA
*/
public boolean ensureServiceLevelAgreementOnAssessment(ServiceLevelAssessment assessment) {
if (assessment != null && assessment.getAgreement() != null) {
return true;
}
if (assessment.getAgreement() == null && assessment.getServiceLevelAgreementId() != null) {
ServiceLevelAgreement agreement = slaProvider.getAgreement(slaProvider.resolve(assessment.getServiceLevelAgreementId().toString()));
((JpaServiceLevelAssessment) assessment).setAgreement(agreement);
}
return assessment != null && assessment.getAgreement() != null;
}
use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.
the class JpaServiceLevelAssessor method assess.
/**
* Assess the SLA (coming from JCR)
*
* @param sla the SLA to be assessed
*/
public ServiceLevelAssessment assess(ServiceLevelAgreement sla) {
log.info("Assessing SLA: {}", sla.getName());
ServiceLevelAssessment assessment = null;
ServiceLevelAgreement serviceLevelAgreement = sla;
assessment = this.metadataAccess.commit(() -> {
AssessmentResult combinedResult = AssessmentResult.SUCCESS;
try {
// create the new Assessment
JpaServiceLevelAssessment slaAssessment = new JpaServiceLevelAssessment();
slaAssessment.setId(JpaServiceLevelAssessment.SlaAssessmentId.create());
slaAssessment.setAgreement(serviceLevelAgreement);
List<ObligationGroup> groups = sla.getObligationGroups();
for (ObligationGroup group : groups) {
Condition condition = group.getCondition();
AssessmentResult groupResult = AssessmentResult.SUCCESS;
Set<ObligationAssessment> obligationAssessments = new HashSet<>();
log.debug("Assessing obligation group {} with {} obligations", group, group.getObligations().size());
for (Obligation ob : group.getObligations()) {
ObligationAssessment obAssessment = assess(ob, slaAssessment);
obligationAssessments.add(obAssessment);
// slaAssessment.add(obAssessment);
groupResult = groupResult.max(obAssessment.getResult());
}
slaAssessment.setObligationAssessments(obligationAssessments);
// Short-circuit required or sufficient if necessary.
switch(condition) {
case REQUIRED:
if (groupResult == AssessmentResult.FAILURE) {
return completeAssessment(slaAssessment, groupResult);
}
break;
case SUFFICIENT:
if (groupResult != AssessmentResult.FAILURE) {
return completeAssessment(slaAssessment, groupResult);
}
break;
default:
}
// Required condition but non-failure, sufficient condition but non-success, or optional condition:
// continue assessing groups and retain the best of the group results.
combinedResult = combinedResult.max(groupResult);
}
return completeAssessment(slaAssessment, combinedResult);
} finally {
log.debug("Completed assessment of SLA {}: {}", sla.getName(), combinedResult);
}
}, MetadataAccess.SERVICE);
return assessment;
}
use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.
the class DefaultServiceLevelAgreementChecker method checkAgreements.
/**
* Caller should wrap this in commit
*/
public void checkAgreements() {
List<? extends ServiceLevelAgreement> list = slaProvider.getAgreements();
LOG.info("Checking {} service level agreements", list.size());
for (ServiceLevelAgreement agreement : list) {
checkAgreement(agreement);
}
LOG.info("Completed checking SLAs");
}
use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.
the class InMemorySLAProvider method replaceSLA.
private SLAImpl replaceSLA(SLAID id, SLAImpl sla) {
ServiceLevelAgreement oldSla = this.slas.get(id);
ServiceLevelAgreement.ID namedId = this.nameToSlas.get(sla.getName());
// besides the one being replaced.
if (namedId == null || oldSla.getId().equals(namedId)) {
sla.setId(id);
this.slas.put(id, sla);
return sla;
} else {
throw new DuplicateAgreementNameException(sla.getName());
}
}
Aggregations