Search in sources :

Example 1 with CDPFreeIpaStructuredFlowEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.freeipa.CDPFreeIpaStructuredFlowEvent in project cloudbreak by hortonworks.

the class CDPFreeIpaStructuredFlowEventToCDPFreeIpaStatusChangedConverterTest method testConvertingNotEmptyStructuredFlowEvent.

@Test
public void testConvertingNotEmptyStructuredFlowEvent() {
    CDPFreeIpaStructuredFlowEvent cdpStructuredFlowEvent = new CDPFreeIpaStructuredFlowEvent();
    CDPOperationDetails operationDetails = new CDPOperationDetails();
    operationDetails.setEnvironmentCrn("testcrn");
    cdpStructuredFlowEvent.setOperation(operationDetails);
    UsageProto.CDPFreeIPAStatusChanged cdpFreeIPAStatusChanged = underTest.convert(cdpStructuredFlowEvent, UsageProto.CDPFreeIPAStatus.Value.UPSCALE_STARTED);
    Assertions.assertEquals(UsageProto.CDPFreeIPAStatus.Value.UPSCALE_STARTED, cdpFreeIPAStatusChanged.getNewStatus());
    Assertions.assertNotNull(cdpFreeIPAStatusChanged.getOperationDetails());
    Assertions.assertNotNull(cdpFreeIPAStatusChanged.getFreeIPADetails());
    Assertions.assertNotNull(cdpFreeIPAStatusChanged.getStatusDetails());
    Assertions.assertEquals("testcrn", cdpFreeIPAStatusChanged.getEnvironmentCrn());
}
Also used : CDPFreeIpaStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.freeipa.CDPFreeIpaStructuredFlowEvent) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Example 2 with CDPFreeIpaStructuredFlowEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.freeipa.CDPFreeIpaStructuredFlowEvent in project cloudbreak by hortonworks.

the class CDPFreeIpaStructuredFlowEventToCDPFreeIpaStatusChangedConverterTest method testConvertingEmptyStructuredFlowEvent.

@Test
public void testConvertingEmptyStructuredFlowEvent() {
    CDPFreeIpaStructuredFlowEvent cdpStructuredFlowEvent = new CDPFreeIpaStructuredFlowEvent();
    UsageProto.CDPFreeIPAStatusChanged cdpFreeIPAStatusChanged = underTest.convert(cdpStructuredFlowEvent, UsageProto.CDPFreeIPAStatus.Value.UPSCALE_STARTED);
    Assertions.assertEquals(UsageProto.CDPFreeIPAStatus.Value.UPSCALE_STARTED, cdpFreeIPAStatusChanged.getNewStatus());
    Assertions.assertNotNull(cdpFreeIPAStatusChanged.getOperationDetails());
    Assertions.assertNotNull(cdpFreeIPAStatusChanged.getFreeIPADetails());
    Assertions.assertNotNull(cdpFreeIPAStatusChanged.getStatusDetails());
    Assertions.assertEquals("", cdpFreeIPAStatusChanged.getEnvironmentCrn());
}
Also used : CDPFreeIpaStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.freeipa.CDPFreeIpaStructuredFlowEvent) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Example 3 with CDPFreeIpaStructuredFlowEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.freeipa.CDPFreeIpaStructuredFlowEvent in project cloudbreak by hortonworks.

the class CDPFreeIpaLogger method log.

@Override
public void log(CDPStructuredFlowEvent cdpStructuredFlowEvent) {
    FlowDetails flow = cdpStructuredFlowEvent.getFlow();
    UsageProto.CDPFreeIPAStatus.Value useCase = freeIpaUseCaseMapper.useCase(flow);
    LOGGER.debug("Telemetry use case: {}", useCase);
    if (cdpStructuredFlowEvent instanceof CDPFreeIpaStructuredFlowEvent && useCase != UsageProto.CDPFreeIPAStatus.Value.UNSET) {
        LOGGER.debug("Sending usage report for {}", cdpStructuredFlowEvent.getOperation().getResourceType());
        usageReporter.cdpFreeIpaStatusChanged(statusChangedConverter.convert((CDPFreeIpaStructuredFlowEvent) cdpStructuredFlowEvent, useCase));
    }
}
Also used : CDPFreeIpaStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.freeipa.CDPFreeIpaStructuredFlowEvent) FlowDetails(com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails)

Example 4 with CDPFreeIpaStructuredFlowEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.freeipa.CDPFreeIpaStructuredFlowEvent in project cloudbreak by hortonworks.

the class FreeipaStructuredFlowEventFactory method createStructuredFlowEvent.

@Override
public CDPStructuredFlowEvent createStructuredFlowEvent(Long resourceId, FlowDetails flowDetails, Exception exception) {
    Stack stack = stackService.getStackById(resourceId);
    String resourceType = CloudbreakEventService.FREEIPA_RESOURCE_TYPE;
    CDPOperationDetails operationDetails = new CDPOperationDetails(clock.getCurrentTimeMillis(), FLOW, resourceType, stack.getId(), stack.getName(), nodeConfig.getId(), serviceVersion, stack.getAccountId(), stack.getResourceCrn(), ThreadBasedUserCrnProvider.getUserCrn(), stack.getEnvironmentCrn(), null);
    StackDetails stackDetails = stackToStackDetailsConverter.convert(stack);
    StackStatus stackStatus = stack.getStackStatus();
    CDPFreeIpaStructuredFlowEvent event = new CDPFreeIpaStructuredFlowEvent(operationDetails, flowDetails, stackDetails, stackStatus.getDetailedStackStatus().name(), stackStatus.getStatusReason());
    if (exception != null) {
        event.setException(ExceptionUtils.getStackTrace(exception));
    }
    return event;
}
Also used : CDPFreeIpaStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.freeipa.CDPFreeIpaStructuredFlowEvent) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) StackDetails(com.sequenceiq.cloudbreak.structuredevent.event.StackDetails) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) Stack(com.sequenceiq.freeipa.entity.Stack)

Aggregations

CDPFreeIpaStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.freeipa.CDPFreeIpaStructuredFlowEvent)4 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)2 CDPOperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)2 Test (org.junit.jupiter.api.Test)2 FlowDetails (com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails)1 StackDetails (com.sequenceiq.cloudbreak.structuredevent.event.StackDetails)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 StackStatus (com.sequenceiq.freeipa.entity.StackStatus)1