Search in sources :

Example 1 with NotificationDetails

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;
}
Also used : OperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.OperationDetails) CloudbreakEventsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson) NotificationDetails(com.sequenceiq.cloudbreak.structuredevent.event.NotificationDetails)

Example 2 with NotificationDetails

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);
}
Also used : OperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.OperationDetails) NotificationDetails(com.sequenceiq.cloudbreak.structuredevent.event.NotificationDetails) StructuredNotificationEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredNotificationEvent)

Example 3 with NotificationDetails

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);
}
Also used : OperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.OperationDetails) NotificationDetails(com.sequenceiq.cloudbreak.structuredevent.event.NotificationDetails) StructuredNotificationEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredNotificationEvent)

Example 4 with NotificationDetails

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

NotificationDetails (com.sequenceiq.cloudbreak.structuredevent.event.NotificationDetails)4 OperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.OperationDetails)4 StructuredNotificationEvent (com.sequenceiq.cloudbreak.structuredevent.event.StructuredNotificationEvent)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