Search in sources :

Example 21 with ServiceLevelAgreement

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;
}
Also used : JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Example 22 with ServiceLevelAgreement

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

Example 23 with ServiceLevelAgreement

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;
}
Also used : ServiceLevelAssessment(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment) Condition(com.thinkbiganalytics.metadata.sla.api.ObligationGroup.Condition) HashSet(java.util.HashSet) Set(java.util.Set) ObligationAssessment(com.thinkbiganalytics.metadata.sla.api.ObligationAssessment) Obligation(com.thinkbiganalytics.metadata.sla.api.Obligation) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) ArrayList(java.util.ArrayList) List(java.util.List) AssessmentResult(com.thinkbiganalytics.metadata.sla.api.AssessmentResult) ObligationGroup(com.thinkbiganalytics.metadata.sla.api.ObligationGroup)

Example 24 with ServiceLevelAgreement

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

Example 25 with ServiceLevelAgreement

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());
    }
}
Also used : DuplicateAgreementNameException(com.thinkbiganalytics.metadata.sla.api.DuplicateAgreementNameException) ID(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement.ID) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)

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