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());
}
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());
}
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));
}
}
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;
}
Aggregations