Search in sources :

Example 1 with ServiceLevelAgreementGroup

use of com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementGroup in project kylo by Teradata.

the class ServiceLevelAgreementRestController method getSlaAsForm.

@GET
@Path("/{slaId}/form-object")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Gets the form for editing the specified SLA.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the SLA form.", response = ServiceLevelAgreementGroup.class), @ApiResponse(code = 400, message = "The slaId is not a valid UUID.", response = RestResponseStatus.class) })
public Response getSlaAsForm(@UUID @PathParam("slaId") String slaId) {
    accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.ACCESS_SERVICE_LEVEL_AGREEMENTS);
    ServiceLevelAgreementGroup agreement = serviceLevelAgreementService.getServiceLevelAgreementAsFormObject(slaId);
    return Response.ok(agreement).build();
}
Also used : ServiceLevelAgreementGroup(com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementGroup) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with ServiceLevelAgreementGroup

use of com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementGroup in project kylo by Teradata.

the class ServiceLevelAgreementRestController method saveAndScheduleFeedSla.

/**
 * Save an SLA and attach the ref to the Feed
 */
@POST
@Path("/feed/{feedId}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Saves the SLA and attaches it to the specified feed.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the SLA.", response = ServiceLevelAgreementGroup.class), @ApiResponse(code = 400, message = "The feedId is not a valid UUID.", response = RestResponseStatus.class), @ApiResponse(code = 500, message = "The SLA could not be saved.", response = RestResponseStatus.class) })
public Response saveAndScheduleFeedSla(@UUID @PathParam("feedId") String feedId, ServiceLevelAgreementGroup sla) {
    accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_SERVICE_LEVEL_AGREEMENTS);
    ServiceLevelAgreement serviceLevelAgreement = serviceLevelAgreementService.saveAndScheduleFeedSla(sla, feedId);
    ServiceLevelAgreementMetricTransformerHelper helper = new ServiceLevelAgreementMetricTransformerHelper();
    ServiceLevelAgreementGroup serviceLevelAgreementGroup = helper.toServiceLevelAgreementGroup(serviceLevelAgreement);
    return Response.ok(serviceLevelAgreementGroup).build();
}
Also used : ServiceLevelAgreement(com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreement) FeedServiceLevelAgreement(com.thinkbiganalytics.metadata.rest.model.sla.FeedServiceLevelAgreement) ServiceLevelAgreementGroup(com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementGroup) ServiceLevelAgreementMetricTransformerHelper(com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementMetricTransformerHelper) 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 3 with ServiceLevelAgreementGroup

use of com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementGroup in project kylo by Teradata.

the class SlaIT method testSla.

@Test
public void testSla() throws IOException {
    copyDataToDropzone(TEST_FILE);
    LocalDateTime now = LocalDateTime.now();
    String systemName = now.format(DateTimeFormatter.ofPattern("HH_mm_ss_SSS"));
    FeedMetadata response = createSimpleFeed("sla_" + systemName, TEST_FILE);
    waitForFeedToComplete();
    ServiceLevelAgreementGroup oneHourAgoSla = createOneHourAgoFeedProcessingDeadlineSla(response.getCategoryAndFeedName(), response.getFeedId());
    triggerSla(oneHourAgoSla.getName());
    assertSLA(oneHourAgoSla.getId(), FAILURE);
    assertFilterByFailuresContains(oneHourAgoSla.getId());
    assertFilterBySuccessContainsNot(oneHourAgoSla.getId());
    assertFailedSlaAppearsInAlerts(oneHourAgoSla.getId());
    ServiceLevelAgreementGroup oneHourAheadSla = createOneHourAheadFeedProcessingDeadlineSla(response.getCategoryAndFeedName(), response.getFeedId());
    triggerSla(oneHourAheadSla.getName());
    assertFilterByFailuresContainsNot(oneHourAheadSla.getId());
    assertFilterBySuccessContains(oneHourAheadSla.getId());
    assertSuccessfulSlaAppearsNotInAlerts(oneHourAheadSla.getId());
    deleteExistingSla();
}
Also used : LocalDateTime(java.time.LocalDateTime) FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) ServiceLevelAgreementGroup(com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementGroup) Test(org.junit.Test)

Example 4 with ServiceLevelAgreementGroup

use of com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementGroup in project kylo by Teradata.

the class ServiceLevelAgreementRestController method saveSla.

/**
 * Save the General SLA coming in from the UI that is not related to a Feed
 */
@POST
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Saves the specified SLA.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the SLA.", response = ServiceLevelAgreementGroup.class), @ApiResponse(code = 500, message = "The SLA could not be saved.", response = RestResponseStatus.class) })
public Response saveSla(ServiceLevelAgreementGroup sla) {
    accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_SERVICE_LEVEL_AGREEMENTS);
    ServiceLevelAgreement serviceLevelAgreement = serviceLevelAgreementService.saveAndScheduleSla(sla);
    ServiceLevelAgreementMetricTransformerHelper helper = new ServiceLevelAgreementMetricTransformerHelper();
    ServiceLevelAgreementGroup serviceLevelAgreementGroup = helper.toServiceLevelAgreementGroup(serviceLevelAgreement);
    return Response.ok(serviceLevelAgreementGroup).build();
}
Also used : ServiceLevelAgreement(com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreement) FeedServiceLevelAgreement(com.thinkbiganalytics.metadata.rest.model.sla.FeedServiceLevelAgreement) ServiceLevelAgreementGroup(com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementGroup) ServiceLevelAgreementMetricTransformerHelper(com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementMetricTransformerHelper) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 5 with ServiceLevelAgreementGroup

use of com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementGroup in project kylo by Teradata.

the class IntegrationTestBase method createFeedProcessingDeadlineSla.

private ServiceLevelAgreementGroup createFeedProcessingDeadlineSla(String feedName, String feedId, LocalDateTime deadline, String noLaterThanHours) {
    int hourOfDay = deadline.get(ChronoField.HOUR_OF_DAY);
    int minuteOfHour = deadline.get(ChronoField.MINUTE_OF_HOUR);
    String cronExpression = String.format("0 %s %s 1/1 * ? *", minuteOfHour, hourOfDay);
    ServiceLevelAgreementGroup sla = new ServiceLevelAgreementGroup();
    String time = deadline.format(DateTimeFormatter.ofPattern("HH:mm"));
    sla.setName("Before " + time + " (cron: " + cronExpression + ")");
    sla.setDescription("The feed should complete before given date and time");
    List<ServiceLevelAgreementRule> rules = new ArrayList<>();
    ServiceLevelAgreementRule rule = new ServiceLevelAgreementRule();
    rule.setName("Feed Processing deadline");
    rule.setDisplayName("Feed Processing deadline");
    rule.setDescription("Ensure a Feed processes data by a specified time");
    rule.setObjectClassType("com.thinkbiganalytics.metadata.sla.api.core.FeedOnTimeArrivalMetric");
    rule.setObjectShortClassType("FeedOnTimeArrivalMetric");
    rule.setCondition(ObligationGroup.Condition.REQUIRED);
    rule.setProperties(newFieldRuleProperties(newFieldRuleProperty("FeedName", "feedName", feedName), newFieldRuleProperty("ExpectedDeliveryTime", "cronString", cronExpression), newFieldRuleProperty("NoLaterThanTime", "lateTime", noLaterThanHours), newFieldRuleProperty("NoLaterThanUnits", "lateUnits", "hrs")));
    rules.add(rule);
    sla.setRules(rules);
    Response response = given(ServiceLevelAgreementRestController.V1_FEEDMGR_SLA).body(sla).when().post(String.format("feed/%s", feedId));
    response.then().statusCode(HTTP_OK);
    return response.as(ServiceLevelAgreementGroup.class);
}
Also used : Response(com.jayway.restassured.response.Response) ServiceLevelAgreementRule(com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementRule) ArrayList(java.util.ArrayList) ServiceLevelAgreementGroup(com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementGroup)

Aggregations

ServiceLevelAgreementGroup (com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementGroup)5 ApiOperation (io.swagger.annotations.ApiOperation)3 ApiResponses (io.swagger.annotations.ApiResponses)3 Produces (javax.ws.rs.Produces)3 ServiceLevelAgreementMetricTransformerHelper (com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementMetricTransformerHelper)2 FeedServiceLevelAgreement (com.thinkbiganalytics.metadata.rest.model.sla.FeedServiceLevelAgreement)2 ServiceLevelAgreement (com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreement)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 Response (com.jayway.restassured.response.Response)1 FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)1 ServiceLevelAgreementRule (com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementRule)1 LocalDateTime (java.time.LocalDateTime)1 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Test (org.junit.Test)1