Search in sources :

Example 26 with CDPOperationDetails

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

the class CDPStructuredFlowEventToCDPOperationDetailsConverterTest method testFlowAndFlowChainType.

@Test
public void testFlowAndFlowChainType() {
    CDPEnvironmentStructuredFlowEvent cdpStructuredFlowEvent = new CDPEnvironmentStructuredFlowEvent();
    FlowDetails flowDetails = new FlowDetails();
    flowDetails.setFlowId("flowId");
    flowDetails.setFlowChainId("flowChainId");
    flowDetails.setNextFlowState("ENV_CREATION_FINISHED_STATE");
    cdpStructuredFlowEvent.setFlow(flowDetails);
    CDPOperationDetails operationDetails = new CDPOperationDetails();
    operationDetails.setUuid("correlationId");
    cdpStructuredFlowEvent.setOperation(operationDetails);
    UsageProto.CDPOperationDetails details = underTest.convert(cdpStructuredFlowEvent, null);
    Assertions.assertEquals(UsageProto.CDPRequestProcessingStep.Value.FINAL, details.getCdpRequestProcessingStep());
    Assertions.assertEquals("flowId", details.getFlowId());
    Assertions.assertEquals("flowChainId", details.getFlowChainId());
    Assertions.assertEquals("correlationId", details.getCorrelationId());
}
Also used : CDPEnvironmentStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent) FlowDetails(com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Example 27 with CDPOperationDetails

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

the class CDPStructuredFlowEventToCDPOperationDetailsConverter method convert.

public UsageProto.CDPOperationDetails convert(CDPStructuredFlowEvent cdpStructuredFlowEvent, String cloudPlatform) {
    UsageProto.CDPOperationDetails.Builder cdpOperationDetails = UsageProto.CDPOperationDetails.newBuilder();
    if (cdpStructuredFlowEvent != null) {
        CDPOperationDetails structuredOperationDetails = cdpStructuredFlowEvent.getOperation();
        if (structuredOperationDetails != null) {
            cdpOperationDetails.setAccountId(defaultIfEmpty(structuredOperationDetails.getAccountId(), ""));
            cdpOperationDetails.setResourceCrn(defaultIfEmpty(structuredOperationDetails.getResourceCrn(), ""));
            cdpOperationDetails.setResourceName(defaultIfEmpty(structuredOperationDetails.getResourceName(), ""));
            cdpOperationDetails.setInitiatorCrn(defaultIfEmpty(structuredOperationDetails.getUserCrn(), ""));
            cdpOperationDetails.setCorrelationId(defaultIfEmpty(structuredOperationDetails.getUuid(), ""));
        }
        if (cloudPlatform != null) {
            cdpOperationDetails.setEnvironmentType(UsageProto.CDPEnvironmentsEnvironmentType.Value.valueOf(cloudPlatform));
        }
        FlowDetails flowDetails = cdpStructuredFlowEvent.getFlow();
        if (flowDetails != null) {
            String flowId = defaultIfEmpty(flowDetails.getFlowId(), "");
            cdpOperationDetails.setFlowId(flowId);
            // We will use flow id if there is no flowchain id, this helps to correlate requests
            cdpOperationDetails.setFlowChainId(defaultIfEmpty(flowDetails.getFlowChainId(), flowId));
            cdpOperationDetails.setFlowState(flowDetails.getFlowState() != null && !"unknown".equals(flowDetails.getFlowState()) && flowDetails.getNextFlowState() != null && (flowDetails.getNextFlowState().endsWith("_FAILED_STATE") || flowDetails.getNextFlowState().endsWith("_FAIL_STATE")) ? flowDetails.getFlowState() : "");
        }
        cdpOperationDetails.setCdpRequestProcessingStep(cdpRequestProcessingStepMapper.mapIt(cdpStructuredFlowEvent.getFlow()));
    }
    cdpOperationDetails.setApplicationVersion(appVersion);
    return cdpOperationDetails.build();
}
Also used : FlowDetails(com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)

Example 28 with CDPOperationDetails

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

the class CDPStructuredEventToCDPStructuredEventEntityConverter method convert.

public CDPStructuredEventEntity convert(CDPStructuredEvent source) {
    try {
        CDPStructuredEventEntity structuredEventEntity = new CDPStructuredEventEntity();
        structuredEventEntity.setStructuredEventJson(new Json(source));
        CDPOperationDetails operationDetails = source.getOperation();
        structuredEventEntity.setEventType(operationDetails.getEventType());
        structuredEventEntity.setResourceType(operationDetails.getResourceType());
        structuredEventEntity.setResourceCrn(operationDetails.getResourceCrn());
        structuredEventEntity.setTimestamp(operationDetails.getTimestamp());
        structuredEventEntity.setAccountId(source.getOperation().getAccountId());
        return structuredEventEntity;
    } catch (IllegalArgumentException e) {
        LOGGER.error("Failed to parse structured event JSON, source: {}", source.getType(), e);
        return null;
    }
}
Also used : CDPStructuredEventEntity(com.sequenceiq.cloudbreak.structuredevent.domain.CDPStructuredEventEntity) Json(com.sequenceiq.cloudbreak.common.json.Json) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)

Example 29 with CDPOperationDetails

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails 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)

Example 30 with CDPOperationDetails

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

the class EnvironmentStructuredFlowEventFactory method createStructuredFlowEvent.

@Override
public CDPStructuredFlowEvent createStructuredFlowEvent(Long resourceId, FlowDetails flowDetails, Boolean detailed, Exception exception) {
    Environment environment = environmentService.findEnvironmentByIdOrThrow(resourceId);
    String resourceType = CloudbreakEventService.ENVIRONMENT_RESOURCE_TYPE;
    CDPOperationDetails operationDetails = new CDPOperationDetails(clock.getCurrentTimeMillis(), FLOW, resourceType, environment.getId(), environment.getName(), nodeConfig.getId(), serviceVersion, environment.getAccountId(), environment.getResourceCrn(), environment.getCreator(), environment.getResourceCrn(), null);
    EnvironmentDetails environmentDetails = environmentDtoConverter.environmentToDto(environment);
    CDPEnvironmentStructuredFlowEvent event = new CDPEnvironmentStructuredFlowEvent(operationDetails, flowDetails, environmentDetails, environment.getStatus().name(), getReason(environment));
    if (exception != null) {
        event.setException(ExceptionUtils.getStackTrace(exception));
    }
    return event;
}
Also used : CDPEnvironmentStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent) EnvironmentDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails) Environment(com.sequenceiq.environment.environment.domain.Environment) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)

Aggregations

CDPOperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)31 Test (org.junit.jupiter.api.Test)8 CDPStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent)7 CDPStructuredNotificationEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent)6 CDPStructuredEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredEvent)5 FlowDetails (com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails)4 CDPStructuredRestCallEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredRestCallEvent)4 Json (com.sequenceiq.cloudbreak.common.json.Json)3 CDPStructuredEventEntity (com.sequenceiq.cloudbreak.structuredevent.domain.CDPStructuredEventEntity)3 CDPStructuredNotificationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationDetails)3 CDPEnvironmentStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent)3 EnvironmentDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails)3 RestCallDetails (com.sequenceiq.cloudbreak.structuredevent.event.rest.RestCallDetails)3 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)2 CDPFreeIpaStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.freeipa.CDPFreeIpaStructuredFlowEvent)2 RestRequestDetails (com.sequenceiq.cloudbreak.structuredevent.event.rest.RestRequestDetails)2 RestResponseDetails (com.sequenceiq.cloudbreak.structuredevent.event.rest.RestResponseDetails)2 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)2 SdxStatusEntity (com.sequenceiq.datalake.entity.SdxStatusEntity)2 Environment (com.sequenceiq.environment.environment.domain.Environment)2