Search in sources :

Example 6 with StructuredNotificationEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredNotificationEvent 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);
}
Also used : OperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.OperationDetails) NotificationDetails(com.sequenceiq.cloudbreak.structuredevent.event.NotificationDetails) UserProfile(com.sequenceiq.cloudbreak.domain.UserProfile) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) StructuredNotificationEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredNotificationEvent) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Aggregations

StructuredNotificationEvent (com.sequenceiq.cloudbreak.structuredevent.event.StructuredNotificationEvent)6 NotificationDetails (com.sequenceiq.cloudbreak.structuredevent.event.NotificationDetails)3 OperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.OperationDetails)3 CloudbreakEventsJson (com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson)1 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)1 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)1 Stack (com.sequenceiq.cloudbreak.domain.Stack)1 UserProfile (com.sequenceiq.cloudbreak.domain.UserProfile)1