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