Search in sources :

Example 6 with OperationDetails

use of com.sequenceiq.cloudbreak.structuredevent.event.OperationDetails 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)

Example 7 with OperationDetails

use of com.sequenceiq.cloudbreak.structuredevent.event.OperationDetails in project cloudbreak by hortonworks.

the class StructuredEventFilter method createOperationDetails.

private OperationDetails createOperationDetails(Map<String, String> restParams, Long requestTime) {
    IdentityUser user = authenticatedUserService.getCbUser();
    String resoureceId = restParams.get(RESOURCE_ID);
    return new OperationDetails(requestTime, "REST", restParams.get(RESOURCE_TYPE), resoureceId != null ? Long.valueOf(resoureceId) : null, user != null ? user.getAccount() : "", user != null ? user.getUserId() : "", user != null ? user.getUsername() : "", cloudbreakNodeConfig.getId(), cbVersion);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) OperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.OperationDetails)

Aggregations

OperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.OperationDetails)7 NotificationDetails (com.sequenceiq.cloudbreak.structuredevent.event.NotificationDetails)4 StructuredNotificationEvent (com.sequenceiq.cloudbreak.structuredevent.event.StructuredNotificationEvent)3 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 Stack (com.sequenceiq.cloudbreak.domain.Stack)2 UserProfile (com.sequenceiq.cloudbreak.domain.UserProfile)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 CloudbreakEventsJson (com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson)1 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)1 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)1 StructuredEventEntity (com.sequenceiq.cloudbreak.domain.StructuredEventEntity)1 Json (com.sequenceiq.cloudbreak.domain.json.Json)1 BlueprintDetails (com.sequenceiq.cloudbreak.structuredevent.event.BlueprintDetails)1 ClusterDetails (com.sequenceiq.cloudbreak.structuredevent.event.ClusterDetails)1 StackDetails (com.sequenceiq.cloudbreak.structuredevent.event.StackDetails)1 StructuredFlowErrorEvent (com.sequenceiq.cloudbreak.structuredevent.event.StructuredFlowErrorEvent)1 StructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.StructuredFlowEvent)1