Search in sources :

Example 1 with CloudbreakEventV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.events.responses.CloudbreakEventV4Response in project cloudbreak by hortonworks.

the class StackCreationService method getImageCopyNotification.

private Notification<CloudbreakEventV4Response> getImageCopyNotification(CheckImageResult result, Stack stack) {
    CloudbreakEventV4Response notification = new CloudbreakEventV4Response();
    notification.setEventType("IMAGE_COPY_STATE");
    notification.setEventTimestamp(new Date().getTime());
    notification.setEventMessage(String.valueOf(result.getStatusProgressValue()));
    notification.setUserId(stack.getCreator().getUserId());
    notification.setWorkspaceId(stack.getWorkspace().getId());
    notification.setCloud(stack.cloudPlatform());
    notification.setRegion(stack.getRegion());
    notification.setStackCrn(stack.getResourceCrn());
    notification.setStackName(stack.getName());
    notification.setStackStatus(stack.getStatus());
    notification.setTenantName(stack.getCreator().getTenant().getName());
    return new Notification<>(notification);
}
Also used : CloudbreakEventV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.events.responses.CloudbreakEventV4Response) Date(java.util.Date) Notification(com.sequenceiq.cloudbreak.notification.Notification)

Example 2 with CloudbreakEventV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.events.responses.CloudbreakEventV4Response in project cloudbreak by hortonworks.

the class NotificationController method notify.

protected final void notify(ResourceEvent resourceEvent, boolean workspaceMessage, Collection<?> messageArgs) {
    CloudbreakUser cloudbreakUser = restRequestThreadLocalService.getCloudbreakUser();
    CloudbreakEventV4Response notification = new CloudbreakEventV4Response();
    notification.setEventTimestamp(new Date().getTime());
    notification.setUserId(userService.getOrCreate(cloudbreakUser).getUserId());
    notification.setEventType(resourceEvent.name());
    notification.setEventMessage(messagesService.getMessage(resourceEvent.getMessage(), messageArgs));
    notification.setTenantName(cloudbreakUser.getTenant());
    if (workspaceMessage) {
        Long workspaceId = restRequestThreadLocalService.getRequestedWorkspaceId();
        notification.setWorkspaceId(workspaceId);
    }
    notificationSender.send(new Notification<>(notification));
}
Also used : CloudbreakEventV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.events.responses.CloudbreakEventV4Response) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) Date(java.util.Date)

Example 3 with CloudbreakEventV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.events.responses.CloudbreakEventV4Response in project cloudbreak by hortonworks.

the class StructuredNotificationEventToCloudbreakEventV4ResponseConverter method convert.

public CloudbreakEventV4Response convert(StructuredNotificationEvent source) {
    CloudbreakEventV4Response cloudbreakEvent = new CloudbreakEventV4Response();
    if (source.getNotificationDetails() != null) {
        NotificationDetails notificationDetails = source.getNotificationDetails();
        setTypesAndMessage(cloudbreakEvent, notificationDetails);
        cloudbreakEvent.setCloud(notificationDetails.getCloud());
        cloudbreakEvent.setRegion(notificationDetails.getRegion());
        cloudbreakEvent.setAvailabilityZone(notificationDetails.getAvailabiltyZone());
        cloudbreakEvent.setBlueprintId(notificationDetails.getBlueprintId());
        cloudbreakEvent.setBlueprintName(notificationDetails.getBlueprintName());
        cloudbreakEvent.setClusterId(notificationDetails.getClusterId());
        cloudbreakEvent.setClusterName(notificationDetails.getClusterName());
        cloudbreakEvent.setStackCrn(notificationDetails.getStackCrn());
        cloudbreakEvent.setStackName(notificationDetails.getStackName());
        cloudbreakEvent.setStackStatus(Status.valueOf(notificationDetails.getStackStatus()));
        cloudbreakEvent.setNodeCount(notificationDetails.getNodeCount());
        cloudbreakEvent.setInstanceGroup(notificationDetails.getInstanceGroup());
        if (notificationDetails.getClusterStatus() != null) {
            cloudbreakEvent.setClusterStatus(Status.valueOf(notificationDetails.getClusterStatus()));
        }
    } else if (source.getLdapNotificationDetails() != null) {
        LdapNotificationDetails notificationDetails = source.getLdapNotificationDetails();
        cloudbreakEvent.setEventType(notificationDetails.getNotificationType());
        cloudbreakEvent.setNotificationType(notificationDetails.getNotificationType());
        cloudbreakEvent.setEventMessage(notificationDetails.getNotification());
        cloudbreakEvent.setLdapDetails(notificationDetails.getLdapDetails());
    } else if (source.getRdsNotificationDetails() != null) {
        RdsNotificationDetails notificationDetails = source.getRdsNotificationDetails();
        cloudbreakEvent.setEventType(notificationDetails.getNotificationType());
        cloudbreakEvent.setNotificationType(notificationDetails.getNotificationType());
        cloudbreakEvent.setEventMessage(notificationDetails.getNotification());
        cloudbreakEvent.setRdsDetails(notificationDetails.getRdsDetails());
    }
    OperationDetails operationDetails = source.getOperation();
    cloudbreakEvent.setEventTimestamp(operationDetails.getTimestamp());
    cloudbreakEvent.setUserId(operationDetails.getUserId());
    cloudbreakEvent.setWorkspaceId(operationDetails.getWorkspaceId());
    cloudbreakEvent.setTenantName(operationDetails.getTenant());
    if (source.getLdapNotificationDetails() != null) {
        cloudbreakEvent.setLdapDetails(source.getLdapNotificationDetails().getLdapDetails());
    }
    if (source.getRdsNotificationDetails() != null) {
        cloudbreakEvent.setRdsDetails(source.getRdsNotificationDetails().getRdsDetails());
    }
    return cloudbreakEvent;
}
Also used : OperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.legacy.OperationDetails) RdsNotificationDetails(com.sequenceiq.cloudbreak.structuredevent.event.RdsNotificationDetails) NotificationDetails(com.sequenceiq.cloudbreak.structuredevent.event.NotificationDetails) LdapNotificationDetails(com.sequenceiq.cloudbreak.structuredevent.event.LdapNotificationDetails) CloudbreakEventV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.events.responses.CloudbreakEventV4Response) RdsNotificationDetails(com.sequenceiq.cloudbreak.structuredevent.event.RdsNotificationDetails) LdapNotificationDetails(com.sequenceiq.cloudbreak.structuredevent.event.LdapNotificationDetails)

Example 4 with CloudbreakEventV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.events.responses.CloudbreakEventV4Response in project cloudbreak by hortonworks.

the class SdxEventsServiceTests method createCloudbreakEventV4Response.

private CloudbreakEventV4Response createCloudbreakEventV4Response(Long timestamp) {
    CloudbreakEventV4Response cloudbreakEventV4Response = new CloudbreakEventV4Response();
    cloudbreakEventV4Response.setEventTimestamp(timestamp);
    cloudbreakEventV4Response.setClusterName("somename");
    cloudbreakEventV4Response.setEventMessage("testing");
    return cloudbreakEventV4Response;
}
Also used : CloudbreakEventV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.events.responses.CloudbreakEventV4Response)

Example 5 with CloudbreakEventV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.events.responses.CloudbreakEventV4Response in project cloudbreak by hortonworks.

the class StructuredNotificationEventToCloudbreakEventJsonConverterTest method testConvert.

@Test
public void testConvert() {
    CloudbreakEventV4Response result = underTest.convert(source);
    assertNotNull(result);
    assertEquals(MESSAGE, result.getEventMessage());
    assertEquals(TYPE, result.getEventType());
    assertAllFieldsNotNull(result, skippedFields);
}
Also used : CloudbreakEventV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.events.responses.CloudbreakEventV4Response) Test(org.junit.Test) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)

Aggregations

CloudbreakEventV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.events.responses.CloudbreakEventV4Response)5 Date (java.util.Date)2 CloudbreakUser (com.sequenceiq.cloudbreak.common.user.CloudbreakUser)1 AbstractEntityConverterTest (com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)1 Notification (com.sequenceiq.cloudbreak.notification.Notification)1 LdapNotificationDetails (com.sequenceiq.cloudbreak.structuredevent.event.LdapNotificationDetails)1 NotificationDetails (com.sequenceiq.cloudbreak.structuredevent.event.NotificationDetails)1 RdsNotificationDetails (com.sequenceiq.cloudbreak.structuredevent.event.RdsNotificationDetails)1 OperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.legacy.OperationDetails)1 Test (org.junit.Test)1