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