use of com.sequenceiq.cloudbreak.api.model.flex.FlexUsageCbdInstanceJson in project cloudbreak by hortonworks.
the class FlexUsageGenerator method getFlexUsageProductJsons.
private List<FlexUsageProductJson> getFlexUsageProductJsons(Iterable<CloudbreakUsage> usages, Long fromDate) {
List<FlexUsageProductJson> flexUsageProducts = new ArrayList<>();
FlexUsageProductJson flexUsageProductJson = new FlexUsageProductJson();
flexUsageProductJson.setProductId(productId);
List<FlexUsageComponentJson> components = new ArrayList<>();
FlexUsageComponentJson cbdComponent = new FlexUsageComponentJson();
cbdComponent.setComponentId(controllerComponentId);
FlexUsageCbdInstanceJson cbdComponentInstance = getFlexUsageCbdInstance(fromDate);
cbdComponent.setInstances(Collections.singletonList(cbdComponentInstance));
components.add(cbdComponent);
FlexUsageComponentJson hdpComponent = new FlexUsageComponentJson();
hdpComponent.setComponentId(clustersComponentId);
hdpComponent.setInstances(getFlexUsageHdpInstances(usages));
components.add(hdpComponent);
flexUsageProductJson.setComponents(components);
flexUsageProducts.add(flexUsageProductJson);
return flexUsageProducts;
}
use of com.sequenceiq.cloudbreak.api.model.flex.FlexUsageCbdInstanceJson in project cloudbreak by hortonworks.
the class FlexUsageGenerator method getFlexUsageCbdInstance.
private FlexUsageCbdInstanceJson getFlexUsageCbdInstance(Long fromDate) {
FlexUsageCbdInstanceJson cbdComponentInstance = new FlexUsageCbdInstanceJson();
cbdComponentInstance.setGuid(cloudbreakNodeConfig.getInstanceUUID());
cbdComponentInstance.setPeakUsage(1);
cbdComponentInstance.setProvider(cbInstanceProvider);
cbdComponentInstance.setRegion(cbInstanceRegion);
String creationTime = "";
if (controllerCreated != null) {
creationTime = formatInstant(Instant.ofEpochMilli(bumpToMillis(controllerCreated)), FLEX_TIME_ZONE_FORMAT_PATTERN);
}
cbdComponentInstance.setCreationTime(creationTime);
FlexSubscription usedForController = Optional.ofNullable(flexSubscriptionRepository.findFirstByUsedForController(true)).orElse(flexSubscriptionRepository.findFirstByIsDefault(true));
cbdComponentInstance.setFlexSubscriptionId(usedForController == null ? "" : usedForController.getSubscriptionId());
cbdComponentInstance.setUsageDate(formatInstant(Instant.ofEpochMilli(fromDate), FLEX_USAGE_DAY_FORMAT_PATTERN));
return cbdComponentInstance;
}
Aggregations