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