Search in sources :

Example 1 with CDPStructuredFlowEvent

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;
}
Also used : CDPStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 2 with CDPStructuredFlowEvent

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;
}
Also used : SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) CDPStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)

Example 3 with CDPStructuredFlowEvent

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());
}
Also used : CDPStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent) FlowDetails(com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails) Test(org.junit.jupiter.api.Test)

Example 4 with CDPStructuredFlowEvent

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);
}
Also used : CDPStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent) CDPFlowResourceAuditEventConverter(com.sequenceiq.cloudbreak.structuredevent.service.audit.auditeventname.flow.CDPFlowResourceAuditEventConverter) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)

Example 5 with CDPStructuredFlowEvent

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;
}
Also used : CDPStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)

Aggregations

CDPStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent)9 CDPOperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)7 FlowDetails (com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails)3 Test (org.junit.jupiter.api.Test)3 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)2 SdxStatusEntity (com.sequenceiq.datalake.entity.SdxStatusEntity)2 Json (com.sequenceiq.cloudbreak.common.json.Json)1 CDPStructuredEventEntity (com.sequenceiq.cloudbreak.structuredevent.domain.CDPStructuredEventEntity)1 CDPStructuredEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredEvent)1 CDPFlowResourceAuditEventConverter (com.sequenceiq.cloudbreak.structuredevent.service.audit.auditeventname.flow.CDPFlowResourceAuditEventConverter)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 StackStatus (com.sequenceiq.freeipa.entity.StackStatus)1 Serializable (java.io.Serializable)1