Search in sources :

Example 1 with FlexUsageCbdInstanceJson

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;
}
Also used : FlexUsageComponentJson(com.sequenceiq.cloudbreak.api.model.flex.FlexUsageComponentJson) ArrayList(java.util.ArrayList) FlexUsageCbdInstanceJson(com.sequenceiq.cloudbreak.api.model.flex.FlexUsageCbdInstanceJson) FlexUsageProductJson(com.sequenceiq.cloudbreak.api.model.flex.FlexUsageProductJson)

Example 2 with FlexUsageCbdInstanceJson

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;
}
Also used : FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription) FlexUsageCbdInstanceJson(com.sequenceiq.cloudbreak.api.model.flex.FlexUsageCbdInstanceJson)

Aggregations

FlexUsageCbdInstanceJson (com.sequenceiq.cloudbreak.api.model.flex.FlexUsageCbdInstanceJson)2 FlexUsageComponentJson (com.sequenceiq.cloudbreak.api.model.flex.FlexUsageComponentJson)1 FlexUsageProductJson (com.sequenceiq.cloudbreak.api.model.flex.FlexUsageProductJson)1 FlexSubscription (com.sequenceiq.cloudbreak.domain.FlexSubscription)1 ArrayList (java.util.ArrayList)1