Search in sources :

Example 6 with EnvironmentDetails

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

Example 7 with EnvironmentDetails

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

the class CDPStructuredFlowEventToCDPEnvironmentRequestedConverter method convert.

public UsageProto.CDPEnvironmentRequested convert(CDPEnvironmentStructuredFlowEvent cdpStructuredFlowEvent) {
    UsageProto.CDPEnvironmentRequested.Builder cdpEnvironmentRequestedBuilder = UsageProto.CDPEnvironmentRequested.newBuilder();
    cdpEnvironmentRequestedBuilder.setOperationDetails(operationDetailsConverter.convert(cdpStructuredFlowEvent));
    if (cdpStructuredFlowEvent != null) {
        EnvironmentDetails environmentDetails = cdpStructuredFlowEvent.getPayload();
        cdpEnvironmentRequestedBuilder.setEnvironmentDetails(environmentDetailsConverter.convert(environmentDetails));
        cdpEnvironmentRequestedBuilder.setTelemetryFeatureDetails(telemetryFeatureDetailsConverter.convert(environmentDetails));
        cdpEnvironmentRequestedBuilder.setFreeIPA(freeIPADetailsConverter.convert(environmentDetails));
    }
    UsageProto.CDPEnvironmentRequested ret = cdpEnvironmentRequestedBuilder.build();
    LOGGER.debug("Converted CDPEnvironmentRequested event: {}", ret);
    return ret;
}
Also used : EnvironmentDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto)

Example 8 with EnvironmentDetails

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

the class CDPStructuredFlowEventToCDPOperationDetailsConverter method convert.

public UsageProto.CDPOperationDetails convert(CDPEnvironmentStructuredFlowEvent cdpStructuredFlowEvent) {
    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(), ""));
        }
        EnvironmentDetails environmentDetails = cdpStructuredFlowEvent.getPayload();
        if (environmentDetails != null && environmentDetails.getCloudPlatform() != null) {
            cdpOperationDetails.setEnvironmentType(UsageProto.CDPEnvironmentsEnvironmentType.Value.valueOf(environmentDetails.getCloudPlatform()));
        }
        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.getFlowState() : "");
        }
        cdpOperationDetails.setCdpRequestProcessingStep(environmentRequestProcessingStepMapper.mapIt(cdpStructuredFlowEvent.getFlow()));
    }
    cdpOperationDetails.setApplicationVersion(appVersion);
    return cdpOperationDetails.build();
}
Also used : EnvironmentDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails) FlowDetails(com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)

Aggregations

EnvironmentDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails)8 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)5 CDPOperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)3 CDPEnvironmentStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent)2 Environment (com.sequenceiq.environment.environment.domain.Environment)2 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)1 SubnetType (com.sequenceiq.cloudbreak.cloud.model.network.SubnetType)1 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)1 FlowDetails (com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails)1 ProxyDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.proxy.ProxyDetails)1 CcmV2TlsType (com.sequenceiq.common.api.type.CcmV2TlsType)1 PublicEndpointAccessGateway (com.sequenceiq.common.api.type.PublicEndpointAccessGateway)1 Tunnel (com.sequenceiq.common.api.type.Tunnel)1 AzureParams (com.sequenceiq.environment.network.dto.AzureParams)1 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1