Search in sources :

Example 21 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 StructuredNotificationEvent} to {@code CDPStructuredEvent}.
 *
 * @param structuredNotificationEvent Event response from cloudbreak.
 * @param datalakeCrn               Crn of data lake.
 * @return CDP structured Event
 */
private CDPStructuredEvent convert(StructuredNotificationEvent structuredNotificationEvent, String datalakeCrn) {
    CDPStructuredNotificationEvent cdpStructuredNotificationEvent = new CDPStructuredNotificationEvent();
    CDPOperationDetails cdpOperationDetails = new CDPOperationDetails();
    cdpOperationDetails.setTimestamp(structuredNotificationEvent.getOperation().getTimestamp());
    cdpOperationDetails.setEventType(StructuredEventType.NOTIFICATION);
    cdpOperationDetails.setResourceName(structuredNotificationEvent.getOperation().getResourceName());
    cdpOperationDetails.setResourceId(structuredNotificationEvent.getOperation().getResourceId());
    cdpOperationDetails.setResourceCrn(datalakeCrn);
    cdpOperationDetails.setResourceEvent(structuredNotificationEvent.getOperation().getEventType().name());
    cdpOperationDetails.setResourceType(CloudbreakEventService.DATALAKE_RESOURCE_TYPE);
    cdpStructuredNotificationEvent.setOperation(cdpOperationDetails);
    cdpStructuredNotificationEvent.setStatusReason(structuredNotificationEvent.getNotificationDetails().getNotification());
    return cdpStructuredNotificationEvent;
}
Also used : CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) CDPStructuredNotificationEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent)

Example 22 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 23 with CDPOperationDetails

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

the class EventSenderService method createStructureEventForMissingEnvironment.

private CDPStructuredNotificationEvent createStructureEventForMissingEnvironment(BaseNamedFlowEvent payload, ResourceEvent resourceEvent, String userCrn) {
    String resourceType = payload.getClass().getSimpleName().toLowerCase();
    String resourceCrn = payload.getResourceCrn();
    CDPOperationDetails operationDetails = new CDPOperationDetails(System.currentTimeMillis(), NOTIFICATION, resourceType, payload.getResourceId(), payload.getResourceName(), nodeConfig.getId(), serviceVersion, null, resourceCrn, userCrn, resourceCrn, resourceEvent.name());
    CDPStructuredNotificationDetails notificationDetails = getNotificationDetails(resourceEvent, resourceCrn, resourceType, payload);
    String message = cloudbreakMessagesService.getMessage(resourceEvent.getMessage());
    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 24 with CDPOperationDetails

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

the class CDPStructuredEventDBServiceTest method testCreateWhenResourceCrnIsEmpty.

@Test
public void testCreateWhenResourceCrnIsEmpty() {
    CDPStructuredEvent event = new CDPStructuredRestCallEvent();
    CDPOperationDetails operation = new CDPOperationDetails();
    operation.setResourceCrn("");
    event.setOperation(operation);
    underTest.create(event);
    verify(cdpStructuredEventToCDPStructuredEventEntityConverter, never()).convert(event);
}
Also used : CDPStructuredRestCallEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredRestCallEvent) CDPStructuredEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredEvent) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) Test(org.junit.jupiter.api.Test)

Example 25 with CDPOperationDetails

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

the class CDPStructuredEventDBServiceTest method testCreateWhenResourceCrnIsNull.

@Test
public void testCreateWhenResourceCrnIsNull() {
    CDPStructuredEvent event = new CDPStructuredRestCallEvent();
    CDPOperationDetails operation = new CDPOperationDetails();
    operation.setResourceCrn(null);
    event.setOperation(operation);
    underTest.create(event);
    verify(cdpStructuredEventToCDPStructuredEventEntityConverter, never()).convert(event);
}
Also used : CDPStructuredRestCallEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredRestCallEvent) CDPStructuredEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredEvent) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) Test(org.junit.jupiter.api.Test)

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