Search in sources :

Example 1 with ObligationAssessment

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

the class JpaServiceLevelAssessment method compareTo.

@Override
public int compareTo(ServiceLevelAssessment sla) {
    ComparisonChain chain = ComparisonChain.start().compare(this.getResult(), sla.getResult()).compare(this.getAgreement().getName(), sla.getAgreement().getName());
    if (chain.result() != 0) {
        return chain.result();
    }
    List<ObligationAssessment> list1 = new ArrayList<>(this.getObligationAssessments());
    List<ObligationAssessment> list2 = new ArrayList<>(sla.getObligationAssessments());
    chain = chain.compare(list1.size(), list2.size());
    Collections.sort(list1);
    Collections.sort(list2);
    for (int idx = 0; idx < list1.size(); idx++) {
        chain = chain.compare(list1.get(idx), list2.get(idx));
    }
    return chain.result();
}
Also used : ObligationAssessment(com.thinkbiganalytics.metadata.sla.api.ObligationAssessment) ArrayList(java.util.ArrayList) ComparisonChain(com.google.common.collect.ComparisonChain)

Example 2 with ObligationAssessment

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

the class ServiceLevelAssessmentAlertUtil method getDescription.

public static String getDescription(ServiceLevelAssessment slaAssmt, String newlineChar) {
    StringBuilder descrBldr = new StringBuilder();
    // of the assessment components: sla assessment->obligation assessments->metric assessments
    if (slaAssmt.getObligationAssessments() != null) {
        for (ObligationAssessment obAssmnt : slaAssmt.getObligationAssessments()) {
            if (obAssmnt.getMetricAssessments() != null) {
                for (MetricAssessment metricAssmnt : obAssmnt.getMetricAssessments()) {
                    descrBldr.append("Requirement: ").append(metricAssmnt.getMetricDescription()).append(newlineChar).append("Result: ").append(metricAssmnt.getMessage()).append(newlineChar);
                }
            }
        }
    }
    descrBldr.append("\nAssessed on ").append(slaAssmt.getTime());
    return descrBldr.toString();
}
Also used : ObligationAssessment(com.thinkbiganalytics.metadata.sla.api.ObligationAssessment) MetricAssessment(com.thinkbiganalytics.metadata.sla.api.MetricAssessment)

Example 3 with ObligationAssessment

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

the class SimpleServiceLevelAssessment method compareTo.

@Override
public int compareTo(ServiceLevelAssessment sla) {
    ComparisonChain chain = ComparisonChain.start().compare(this.getResult(), sla.getResult()).compare(this.getAgreement().getName(), sla.getAgreement().getName());
    if (chain.result() != 0) {
        return chain.result();
    }
    List<ObligationAssessment> list1 = new ArrayList<>(this.getObligationAssessments());
    List<ObligationAssessment> list2 = new ArrayList<>(sla.getObligationAssessments());
    chain = chain.compare(list1.size(), list2.size());
    Collections.sort(list1);
    Collections.sort(list2);
    for (int idx = 0; idx < list1.size(); idx++) {
        chain = chain.compare(list1.get(idx), list2.get(idx));
    }
    return chain.result();
}
Also used : ObligationAssessment(com.thinkbiganalytics.metadata.sla.api.ObligationAssessment) ArrayList(java.util.ArrayList) ComparisonChain(com.google.common.collect.ComparisonChain)

Example 4 with ObligationAssessment

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

the class SimpleServiceLevelAssessor method assess.

/*
     * (non-Javadoc)
     * 
     * @see
     * com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAssessor#assess(com.
     * thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)
     */
@Override
public ServiceLevelAssessment assess(ServiceLevelAgreement sla) {
    Log.info("Assessing SLA: {}", sla.getName());
    AssessmentResult combinedResult = AssessmentResult.FAILURE;
    try {
        SimpleServiceLevelAssessment slaAssessment = new SimpleServiceLevelAssessment(sla);
        List<ObligationGroup> groups = sla.getObligationGroups();
        for (ObligationGroup group : groups) {
            ObligationGroup.Condition condition = group.getCondition();
            AssessmentResult groupResult = AssessmentResult.SUCCESS;
            for (Obligation ob : group.getObligations()) {
                ObligationAssessment obAssessment = assess(ob);
                slaAssessment.add(obAssessment);
                groupResult = groupResult.max(obAssessment.getResult());
            }
            // 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.min(groupResult);
        }
        return completeAssessment(slaAssessment, combinedResult);
    } finally {
        Log.debug("Completed assessment of SLA {}: {}", sla.getName(), combinedResult);
    }
}
Also used : ObligationAssessment(com.thinkbiganalytics.metadata.sla.api.ObligationAssessment) Obligation(com.thinkbiganalytics.metadata.sla.api.Obligation) AssessmentResult(com.thinkbiganalytics.metadata.sla.api.AssessmentResult) ObligationGroup(com.thinkbiganalytics.metadata.sla.api.ObligationGroup)

Example 5 with ObligationAssessment

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

Aggregations

ObligationAssessment (com.thinkbiganalytics.metadata.sla.api.ObligationAssessment)5 ArrayList (java.util.ArrayList)3 ComparisonChain (com.google.common.collect.ComparisonChain)2 AssessmentResult (com.thinkbiganalytics.metadata.sla.api.AssessmentResult)2 Obligation (com.thinkbiganalytics.metadata.sla.api.Obligation)2 ObligationGroup (com.thinkbiganalytics.metadata.sla.api.ObligationGroup)2 MetricAssessment (com.thinkbiganalytics.metadata.sla.api.MetricAssessment)1 Condition (com.thinkbiganalytics.metadata.sla.api.ObligationGroup.Condition)1 ServiceLevelAgreement (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)1 ServiceLevelAssessment (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1