use of com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementRule 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);
}
Aggregations