Search in sources :

Example 16 with CloudbreakUsage

use of com.sequenceiq.cloudbreak.domain.CloudbreakUsage in project cloudbreak by hortonworks.

the class UsageService method closeUsagesForStack.

public void closeUsagesForStack(Long stackId) {
    List<CloudbreakUsage> usages = usageRepository.findOpensForStack(stackId);
    for (CloudbreakUsage usage : usages) {
        closeUsage(usage);
        usageRepository.save(usage);
    }
}
Also used : CloudbreakUsage(com.sequenceiq.cloudbreak.domain.CloudbreakUsage)

Example 17 with CloudbreakUsage

use of com.sequenceiq.cloudbreak.domain.CloudbreakUsage in project cloudbreak by hortonworks.

the class UsageService method openUsagesForStack.

public void openUsagesForStack(Stack stack) {
    LocalDateTime ldt = LocalDateTime.now();
    List<CloudbreakUsage> usages = Lists.newArrayList();
    for (InstanceGroup ig : stack.getInstanceGroups()) {
        Template template = ig.getTemplate();
        String instanceType = template == null ? "undefined" : template.getInstanceType();
        String groupName = ig.getGroupName();
        Integer instanceNum = ig.getNodeCount();
        usages.add(usageGeneratorService.openNewUsage(stack, instanceType, instanceNum, groupName, ldt));
    }
    usageRepository.save(usages);
}
Also used : LocalDateTime(java.time.LocalDateTime) CloudbreakUsage(com.sequenceiq.cloudbreak.domain.CloudbreakUsage) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Template(com.sequenceiq.cloudbreak.domain.Template)

Example 18 with CloudbreakUsage

use of com.sequenceiq.cloudbreak.domain.CloudbreakUsage in project cloudbreak by hortonworks.

the class CloudbreakUsageRequestToCloudbreakUsageConverterTest method testConvert.

@Test
public void testConvert() {
    // GIVEN
    // WHEN
    CloudbreakUsage result = underTest.convert(getRequest("usage/cloudbreak-usage.json"));
    // THEN
    assertAllFieldsNotNull(result, asList("day", "costs", "periodStarted", "duration", "status", "flexId", "stackUuid", "instanceNum", "peak", "parentUuid", "smartSenseId"));
}
Also used : CloudbreakUsage(com.sequenceiq.cloudbreak.domain.CloudbreakUsage) Test(org.junit.Test)

Aggregations

CloudbreakUsage (com.sequenceiq.cloudbreak.domain.CloudbreakUsage)18 Date (java.util.Date)4 LocalDate (java.time.LocalDate)3 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)2 Duration (java.time.Duration)2 ArrayList (java.util.ArrayList)2 CloudbreakUsageJson (com.sequenceiq.cloudbreak.api.model.CloudbreakUsageJson)1 CloudbreakFlexUsageJson (com.sequenceiq.cloudbreak.api.model.flex.CloudbreakFlexUsageJson)1 FlexUsageHdpInstanceJson (com.sequenceiq.cloudbreak.api.model.flex.FlexUsageHdpInstanceJson)1 Builder (com.sequenceiq.cloudbreak.domain.CbUsageFilterParameters.Builder)1 FlexSubscription (com.sequenceiq.cloudbreak.domain.FlexSubscription)1 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)1 Stack (com.sequenceiq.cloudbreak.domain.Stack)1 Template (com.sequenceiq.cloudbreak.domain.Template)1 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)1 LocalDateTime (java.time.LocalDateTime)1 ZonedDateTime (java.time.ZonedDateTime)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 Test (org.junit.Test)1