Search in sources :

Example 1 with SimpleServiceLevelAssessor

use of com.thinkbiganalytics.metadata.sla.spi.core.SimpleServiceLevelAssessor in project kylo by Teradata.

the class ServiceLevelAgreementRestController method testTemplate.

@POST
@Path("/test-email-template")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Tests a velocity SLA email template.  This will validate and return the parsed template allowing you to preview it.  If an parse exception occurs it will be indicated in the content of the response.")
@ApiResponses({ @ApiResponse(code = 200, message = "The the SLA email template.", response = VelocityEmailTemplate.class) })
public VelocityEmailTemplate testTemplate(VelocityEmailTemplate template) {
    accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_SERVICE_LEVEL_AGREEMENT_EMAIL_TEMPLATE);
    Map<String, Object> map = new HashMap();
    InMemorySLAProvider slaProvider = new InMemorySLAProvider();
    Metric m1 = new SimpleMetric();
    com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement sla = slaProvider.builder().name("Test SLA").description("SLA Description").obligationBuilder(ObligationGroup.Condition.REQUIRED).metric(m1).build().build();
    map.put("sla", sla);
    SimpleServiceLevelAssessor simpleServiceLevelAssessor = new SimpleServiceLevelAssessor();
    simpleServiceLevelAssessor.registerMetricAssessor(new TestMetricAssessor());
    com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment assessment = simpleServiceLevelAssessor.assess(sla);
    map.put("assessment", assessment);
    map.put("assessmentDescription", ServiceLevelAssessmentAlertUtil.getDescription(assessment, "<br/>"));
    String subject = velocityTemplateProvider.testTemplate(template.getSubject(), map);
    String body = velocityTemplateProvider.testTemplate(template.getBody(), map);
    return new VelocityEmailTemplate(subject, body);
}
Also used : HashMap(java.util.HashMap) SimpleServiceLevelAssessor(com.thinkbiganalytics.metadata.sla.spi.core.SimpleServiceLevelAssessor) VelocityEmailTemplate(com.thinkbiganalytics.common.velocity.model.VelocityEmailTemplate) InMemorySLAProvider(com.thinkbiganalytics.metadata.sla.spi.core.InMemorySLAProvider) Metric(com.thinkbiganalytics.metadata.sla.api.Metric) TestMetric(com.thinkbiganalytics.metadata.api.sla.TestMetric) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with SimpleServiceLevelAssessor

use of com.thinkbiganalytics.metadata.sla.spi.core.SimpleServiceLevelAssessor in project kylo by Teradata.

the class ServerConfiguration method slaAssessor.

@Bean
@Profile("metadata.memory-only")
public ServiceLevelAssessor slaAssessor() {
    SimpleServiceLevelAssessor assr = new SimpleServiceLevelAssessor();
    assr.registerMetricAssessor(datasetUpdatedSinceMetricAssessor());
    assr.registerMetricAssessor(feedExecutedSinceFeedMetricAssessor());
    assr.registerMetricAssessor(feedExecutedSinceScheduleMetricAssessor());
    assr.registerMetricAssessor(datasourceUpdatedSinceFeedExecutedAssessor());
    assr.registerMetricAssessor(withinScheduleAssessor());
    return assr;
}
Also used : SimpleServiceLevelAssessor(com.thinkbiganalytics.metadata.sla.spi.core.SimpleServiceLevelAssessor) Profile(org.springframework.context.annotation.Profile) Bean(org.springframework.context.annotation.Bean)

Aggregations

SimpleServiceLevelAssessor (com.thinkbiganalytics.metadata.sla.spi.core.SimpleServiceLevelAssessor)2 VelocityEmailTemplate (com.thinkbiganalytics.common.velocity.model.VelocityEmailTemplate)1 TestMetric (com.thinkbiganalytics.metadata.api.sla.TestMetric)1 Metric (com.thinkbiganalytics.metadata.sla.api.Metric)1 InMemorySLAProvider (com.thinkbiganalytics.metadata.sla.spi.core.InMemorySLAProvider)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 HashMap (java.util.HashMap)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Bean (org.springframework.context.annotation.Bean)1 Profile (org.springframework.context.annotation.Profile)1