Search in sources :

Example 6 with CDPStructuredNotificationEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent 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 7 with CDPStructuredNotificationEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent 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 8 with CDPStructuredNotificationEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent 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 9 with CDPStructuredNotificationEvent

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

the class EventSenderService method sendEventAndNotificationWithPayload.

public void sendEventAndNotificationWithPayload(AccountAwareResource resource, String userCrn, ResourceEvent resourceEvent, Object payload, Collection<?> messageArgs) {
    CDPStructuredNotificationEvent cdpStructuredEvent = getStructuredEvent(resource, resourceEvent, payload, messageArgs);
    cdpDefaultStructuredEventClient.sendStructuredEvent(cdpStructuredEvent);
    notificationService.send(resourceEvent, payload, userCrn);
}
Also used : CDPStructuredNotificationEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent)

Example 10 with CDPStructuredNotificationEvent

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

Aggregations

CDPStructuredNotificationEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent)11 CDPOperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)6 CDPStructuredNotificationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationDetails)3 CustomPermissionCheck (com.sequenceiq.authorization.annotation.CustomPermissionCheck)1 ResourceCrn (com.sequenceiq.authorization.annotation.ResourceCrn)1 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)1 JsonUtil (com.sequenceiq.cloudbreak.common.json.JsonUtil)1 StructuredEventType (com.sequenceiq.cloudbreak.structuredevent.event.StructuredEventType)1 CDPStructuredEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredEvent)1 CDPStructuredEventV1Endpoint (com.sequenceiq.cloudbreak.structuredevent.rest.endpoint.CDPStructuredEventV1Endpoint)1 CDPStructuredEventDBService (com.sequenceiq.cloudbreak.structuredevent.service.db.CDPStructuredEventDBService)1 Collection (java.util.Collection)1 List (java.util.List)1 ZipEntry (java.util.zip.ZipEntry)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 Inject (javax.inject.Inject)1 Response (javax.ws.rs.core.Response)1 StreamingOutput (javax.ws.rs.core.StreamingOutput)1 PageRequest (org.springframework.data.domain.PageRequest)1 Sort (org.springframework.data.domain.Sort)1