use of com.sequenceiq.cloudbreak.structuredevent.event.NotificationDetails in project cloudbreak by hortonworks.
the class StructuredNotificationEventToCloudbreakEventJsonConverter method convert.
@Override
public CloudbreakEventsJson convert(StructuredNotificationEvent source) {
CloudbreakEventsJson cloudbreakEvent = new CloudbreakEventsJson();
NotificationDetails notificationDetails = source.getNotificationDetails();
OperationDetails operationDetails = source.getOperation();
cloudbreakEvent.setEventType(notificationDetails.getNotificationType());
cloudbreakEvent.setEventTimestamp(operationDetails.getTimestamp());
cloudbreakEvent.setEventMessage(notificationDetails.getNotification());
cloudbreakEvent.setOwner(operationDetails.getUserId());
cloudbreakEvent.setAccount(operationDetails.getAccount());
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.setStackId(notificationDetails.getStackId());
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()));
}
return cloudbreakEvent;
}
use of com.sequenceiq.cloudbreak.structuredevent.event.NotificationDetails in project cloudbreak by hortonworks.
the class ServiceTestUtils method createEvent.
public static StructuredNotificationEvent createEvent(Long stackId, int nodeCount, String eventStatus, Date eventTimestamp) {
OperationDetails operation = new OperationDetails(eventTimestamp.getTime(), "NOTIFICATION", "STACK", stackId, "account", "userid", "username", "cbId", "cbVersion");
NotificationDetails notification = new NotificationDetails();
notification.setNotificationType(eventStatus);
notification.setNodeCount(nodeCount);
return new StructuredNotificationEvent(operation, notification);
}
use of com.sequenceiq.cloudbreak.structuredevent.event.NotificationDetails in project cloudbreak by hortonworks.
the class StructuredNotificationEventToCloudbreakEventJsonConverterTest method createSource.
@Override
public StructuredNotificationEvent createSource() {
OperationDetails operation = new OperationDetails(Calendar.getInstance().getTimeInMillis(), "NOTIFICATION", "STACK", 1L, "account", "owner", "userName", "cbId", "cbVersion");
NotificationDetails notification = new NotificationDetails();
notification.setInstanceGroup("master");
notification.setRegion("us");
notification.setStackName("usagestack");
notification.setStackId(1L);
notification.setNotification("message");
notification.setNotificationType("eventType");
notification.setCloud(GCP);
notification.setBlueprintName("blueprintName");
notification.setBlueprintId(1L);
notification.setStackStatus(AVAILABLE.name());
notification.setNodeCount(1);
notification.setClusterStatus(AVAILABLE.name());
notification.setClusterId(1L);
notification.setClusterName("test");
return new StructuredNotificationEvent(operation, notification);
}
use of com.sequenceiq.cloudbreak.structuredevent.event.NotificationDetails in project cloudbreak by hortonworks.
the class StructuredFlowEventFactory method createStructuredNotificationEvent.
public StructuredNotificationEvent createStructuredNotificationEvent(Long stackId, String notificationType, String message, String instanceGroupName) {
Stack stack = stackService.getById(stackId);
UserProfile userProfile = userProfileService.get(stack.getAccount(), stack.getOwner());
OperationDetails operationDetails = new OperationDetails("NOTIFICATION", "STACK", stackId, stack.getAccount(), stack.getOwner(), userProfile.getUserName(), cloudbreakNodeConfig.getInstanceUUID(), cbVersion);
NotificationDetails notificationDetails = new NotificationDetails();
notificationDetails.setNotificationType(notificationType);
notificationDetails.setNotification(message);
notificationDetails.setCloud(stack.cloudPlatform());
notificationDetails.setRegion(stack.getRegion());
notificationDetails.setAvailabiltyZone(stack.getAvailabilityZone());
notificationDetails.setStackId(stackId);
notificationDetails.setStackName(stack.getDisplayName());
notificationDetails.setStackStatus(stack.getStatus().name());
notificationDetails.setNodeCount(stack.getRunningInstanceMetaData().size());
notificationDetails.setInstanceGroup(instanceGroupName);
Cluster cluster = stack.getCluster();
if (cluster != null) {
notificationDetails.setClusterId(cluster.getId());
notificationDetails.setClusterName(cluster.getName());
notificationDetails.setClusterStatus(cluster.getStatus().name());
Blueprint blueprint = cluster.getBlueprint();
if (blueprint != null) {
notificationDetails.setBlueprintId(blueprint.getId());
notificationDetails.setBlueprintName(blueprint.getAmbariName());
}
}
return new StructuredNotificationEvent(operationDetails, notificationDetails);
}
Aggregations