use of com.thinkbiganalytics.metadata.sla.api.Metric in project kylo by Teradata.
the class ServiceLevelAgreementMetricTransformerHelper method getServiceLevelAgreement.
public ServiceLevelAgreement getServiceLevelAgreement(ServiceLevelAgreementGroup serviceLevelAgreement) {
ServiceLevelAgreement transformedSla = new ServiceLevelAgreement();
transformedSla.setId(serviceLevelAgreement.getId());
transformedSla.setName(serviceLevelAgreement.getName());
transformedSla.setDescription(serviceLevelAgreement.getDescription());
for (ServiceLevelAgreementRule rule : serviceLevelAgreement.getRules()) {
try {
ObligationGroup group = new ObligationGroup();
Metric policy = ServiceLevelAgreementMetricTransformer.instance().fromUiModel(rule);
Obligation obligation = new Obligation(policy.getDescription());
obligation.setMetrics(Lists.newArrayList(policy));
group.addObligation(obligation);
group.setCondition(rule.getCondition().name());
transformedSla.addGroup(group);
} catch (PolicyTransformException e) {
throw new RuntimeException(e);
}
}
return transformedSla;
}
use of com.thinkbiganalytics.metadata.sla.api.Metric in project kylo by Teradata.
the class FeedExecutedSinceFeeds method buildPreconditionObligation.
/**
* Builds the ObligationGroup that holds the metric that will be used to assess if this precondition is met or not
*/
public com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup buildPreconditionObligation() {
Set<Metric> metrics = new HashSet<>();
for (String categoryAndFeed : categoryAndFeedList) {
FeedExecutedSinceFeed metric = new FeedExecutedSinceFeed(sinceCategoryAndFeedName, categoryAndFeed);
metrics.add(metric);
}
Obligation obligation = new Obligation();
obligation.setMetrics(Lists.newArrayList(metrics));
com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup group = new com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup();
group.addObligation(obligation);
group.setCondition(ObligationGroup.Condition.REQUIRED.name());
return group;
}
use of com.thinkbiganalytics.metadata.sla.api.Metric in project kylo by Teradata.
the class DebugController method exampleMetrics.
/**
* returns a list of metrics for debugging
*
* @return a list of metrics
*/
@GET
@Path("metrics")
@Produces(MediaType.APPLICATION_JSON)
public List<Metric> exampleMetrics() {
List<Metric> metrics = new ArrayList<>();
FeedExecutedSinceSchedule feedExecutedSinceSchedule = null;
try {
feedExecutedSinceSchedule = new FeedExecutedSinceSchedule("category", "Feed", "* * * * * ? *");
metrics.add(feedExecutedSinceSchedule);
WithinSchedule withinSchedule = new com.thinkbiganalytics.metadata.api.sla.WithinSchedule("* * * * * ? *", "4 hours");
metrics.add(withinSchedule);
} catch (ParseException e) {
throw new RuntimeException(e);
}
return metrics;
}
use of com.thinkbiganalytics.metadata.sla.api.Metric in project kylo by Teradata.
the class JcrObligation method setMetrics.
public void setMetrics(Set<Metric> metrics) {
try {
NodeIterator nodes = this.node.getNodes(METRICS);
while (nodes.hasNext()) {
Node metricNode = (Node) nodes.next();
metricNode.remove();
}
for (Metric metric : metrics) {
Node metricNode = this.node.addNode(METRICS, METRIC_TYPE);
JcrPropertyUtil.setProperty(metricNode, NAME, metric.getClass().getSimpleName());
JcrPropertyUtil.setProperty(metricNode, DESCRIPTION, metric.getDescription());
JcrUtil.addGenericJson(metricNode, JSON, metric);
}
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to retrieve the metric nodes", e);
}
}
Aggregations