Search in sources :

Example 16 with CDPOperationDetails

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

the class SdxEventsService method convert.

/**
 * Converts a collection of {@code CloudbreakEventV4Response} to {@code CDPStructuredEvent}.
 *
 * @param cloudbreakEventV4Response Event response from cloudbreak.
 * @param datalakeCrn               Crn of data lake.
 * @return CDP structured Event
 */
private CDPStructuredEvent convert(CloudbreakEventV4Response cloudbreakEventV4Response, String datalakeCrn) {
    CDPStructuredNotificationEvent cdpStructuredNotificationEvent = new CDPStructuredNotificationEvent();
    CDPOperationDetails cdpOperationDetails = new CDPOperationDetails();
    cdpOperationDetails.setTimestamp(cloudbreakEventV4Response.getEventTimestamp());
    cdpOperationDetails.setEventType(StructuredEventType.NOTIFICATION);
    cdpOperationDetails.setResourceName(cloudbreakEventV4Response.getClusterName());
    cdpOperationDetails.setResourceId(cloudbreakEventV4Response.getClusterId());
    cdpOperationDetails.setResourceCrn(datalakeCrn);
    cdpOperationDetails.setResourceEvent(cloudbreakEventV4Response.getEventType());
    cdpOperationDetails.setResourceType(CloudbreakEventService.DATALAKE_RESOURCE_TYPE);
    cdpStructuredNotificationEvent.setOperation(cdpOperationDetails);
    cdpStructuredNotificationEvent.setStatusReason(cloudbreakEventV4Response.getEventMessage());
    return cdpStructuredNotificationEvent;
}
Also used : CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) CDPStructuredNotificationEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent)

Example 17 with CDPOperationDetails

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

the class DatalakeStructuredFlowEventFactory method createStructuredFlowEvent.

@Override
public CDPStructuredFlowEvent<SdxClusterDto> createStructuredFlowEvent(Long resourceId, FlowDetails flowDetails, 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 18 with CDPOperationDetails

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

the class DatalakeStructuredFlowEventFactory method makeCdpOperationDetails.

private CDPOperationDetails makeCdpOperationDetails(Long resourceId, SdxCluster sdxCluster) {
    // turning the string constants in CloudbreakEventService into a enums would be nice.
    String resourceType = CloudbreakEventService.DATALAKE_RESOURCE_TYPE;
    // todo: make a CDPOperationDetails Builder
    CDPOperationDetails operationDetails = new CDPOperationDetails();
    operationDetails.setTimestamp(clock.getCurrentTimeMillis());
    operationDetails.setEventType(FLOW);
    operationDetails.setResourceId(resourceId);
    operationDetails.setResourceName(sdxCluster.getName());
    operationDetails.setResourceType(resourceType);
    operationDetails.setCloudbreakId(nodeConfig.getId());
    operationDetails.setCloudbreakVersion(serviceVersion);
    operationDetails.setResourceCrn(sdxCluster.getResourceCrn());
    operationDetails.setUserCrn(ThreadBasedUserCrnProvider.getUserCrn());
    operationDetails.setAccountId(sdxCluster.getAccountId());
    operationDetails.setEnvironmentCrn(sdxCluster.getEnvCrn());
    operationDetails.setUuid(UUID.randomUUID().toString());
    return operationDetails;
}
Also used : CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)

Example 19 with CDPOperationDetails

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

the class EventSenderService method getStructuredEvent.

private CDPStructuredNotificationEvent getStructuredEvent(AccountAwareResource resource, ResourceEvent resourceEvent, Object payload, Collection<?> messageArgs) {
    String resourceType = resource.getClass().getSimpleName().toLowerCase();
    String resourceCrn = resource.getResourceCrn();
    CDPOperationDetails operationDetails = new CDPOperationDetails(System.currentTimeMillis(), NOTIFICATION, resourceType, resource.getId(), resource.getName(), nodeConfig.getId(), serviceVersion, resource.getAccountId(), resourceCrn, ThreadBasedUserCrnProvider.getUserCrn(), resourceCrn, resourceEvent.name());
    CDPStructuredNotificationDetails notificationDetails = getNotificationDetails(resourceEvent, resourceCrn, resourceType, payload);
    String message = cloudbreakMessagesService.getMessage(resourceEvent.getMessage(), messageArgs);
    return new CDPStructuredNotificationEvent(operationDetails, notificationDetails, resourceEvent.name(), message);
}
Also used : CDPStructuredNotificationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationDetails) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) CDPStructuredNotificationEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent)

Example 20 with CDPOperationDetails

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

the class SdxEventsServiceTests 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

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