use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent in project cloudbreak by hortonworks.
the class FreeipaStructuredFlowEventFactory method createStructuredFlowEvent.
@Override
public CDPStructuredFlowEvent createStructuredFlowEvent(Long resourceId, FlowDetails flowDetails, Boolean detailed, 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);
StackStatus stackStatus = stack.getStackStatus();
CDPStructuredFlowEvent event = new CDPStructuredFlowEvent(operationDetails, flowDetails, null, stackStatus.getDetailedStackStatus().name(), stackStatus.getStatusReason());
if (exception != null) {
event.setException(ExceptionUtils.getStackTrace(exception));
}
return event;
}
use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent in project cloudbreak by hortonworks.
the class DatalakeStructuredFlowEventFactory method createStructuredFlowEvent.
@Override
public CDPStructuredFlowEvent<SdxClusterDto> createStructuredFlowEvent(Long resourceId, FlowDetails flowDetails, Boolean detailed, Exception exception) {
SdxCluster sdxCluster = sdxService.getById(resourceId);
CDPOperationDetails operationDetails = makeCdpOperationDetails(resourceId, sdxCluster);
SdxClusterDto sdxClusterDto = sdxClusterDtoConverter.sdxClusterToDto(sdxCluster);
SdxStatusEntity sdxStatus = sdxStatusRepository.findFirstByDatalakeIsOrderByIdDesc(sdxCluster);
String status = sdxStatus.getStatus().name();
String statusReason = sdxStatus.getStatusReason();
CDPStructuredFlowEvent<SdxClusterDto> event = new CDPStructuredFlowEvent<>(operationDetails, flowDetails, sdxClusterDto, status, statusReason);
if (exception != null) {
event.setException(ExceptionUtils.getStackTrace(exception));
}
return event;
}
use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent in project cloudbreak by hortonworks.
the class CDPFlowStructuredEventHandlerTest method testTransitionWhenExceptionNullAndTransitionValueIsNull.
@Test
public void testTransitionWhenExceptionNullAndTransitionValueIsNull() {
Transition<String, String> transition = mock(Transition.class);
CDPStructuredFlowEvent event = new CDPStructuredFlowEvent();
when(cdpStructuredFlowEventFactory.createStructuredFlowEvent(any(), any())).thenReturn(event);
underTest.transition(transition);
ArgumentCaptor<FlowDetails> flowDetailsCaptor = ArgumentCaptor.forClass(FlowDetails.class);
verify(cdpStructuredFlowEventFactory).createStructuredFlowEvent(any(), flowDetailsCaptor.capture());
verify(cdpDefaultStructuredEventClient).sendStructuredEvent(event);
FlowDetails flowDetails = flowDetailsCaptor.getValue();
String unknown = "unknown";
Assertions.assertEquals(unknown, flowDetails.getFlowState());
Assertions.assertEquals(unknown, flowDetails.getNextFlowState());
Assertions.assertEquals(unknown, flowDetails.getFlowEvent());
Assertions.assertEquals(0L, flowDetails.getDuration());
}
use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent in project cloudbreak by hortonworks.
the class FlowCDPEventDataExtractor method shouldAudit.
@Override
public boolean shouldAudit(CDPStructuredEvent structuredEvent) {
CDPOperationDetails operation = structuredEvent.getOperation();
CDPFlowResourceAuditEventConverter flowResourceAuditEventConverter = getConverter(operation.getResourceType());
if (flowResourceAuditEventConverter == null) {
return false;
}
boolean crn = Crn.isCrn(operation.getResourceCrn());
return crn && flowResourceAuditEventConverter.shouldAudit((CDPStructuredFlowEvent) structuredEvent);
}
use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent in project cloudbreak by hortonworks.
the class SdxEventControllerTest method createCDPStructuredFlowEvent.
private CDPStructuredEvent createCDPStructuredFlowEvent(Long timestamp) {
CDPOperationDetails operationDetails = new CDPOperationDetails();
operationDetails.setResourceCrn("someCrn");
operationDetails.setResourceType("datalake");
operationDetails.setTimestamp(timestamp);
operationDetails.setEventType(StructuredEventType.FLOW);
CDPStructuredFlowEvent cdpStructuredEvent = new CDPStructuredFlowEvent() {
@Override
public String getStatus() {
return SENT;
}
@Override
public Long getDuration() {
return 1L;
}
};
cdpStructuredEvent.setOperation(operationDetails);
return cdpStructuredEvent;
}
Aggregations