use of com.thinkbiganalytics.metadata.sla.api.AssessmentResult 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);
}
}
use of com.thinkbiganalytics.metadata.sla.api.AssessmentResult 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.AssessmentResult in project kylo by Teradata.
the class TestObligatinAssessor method assess.
@Override
@SuppressWarnings("unchecked")
public void assess(Obligation obligation, ObligationAssessmentBuilder builder) {
AssessmentResult result = AssessmentResult.SUCCESS;
for (Metric metric : obligation.getMetrics()) {
MetricAssessment assessment = builder.assess(metric);
result = result.max(assessment.getResult());
}
if (this.expectedDescription != null) {
builder.compareWith(this.expectedDescription);
if (!obligation.getDescription().equals(this.expectedDescription)) {
builder.message("The expected description does not match: " + this.expectedDescription);
result = AssessmentResult.FAILURE;
}
}
builder.result(result);
}
Aggregations