Search in sources :

Example 1 with OperationDetails

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

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

the class StructuredEventToStructuredEventEntityConverter method convert.

@Override
public StructuredEventEntity convert(StructuredEvent source) {
    try {
        OperationDetails operationDetails = source.getOperation();
        StructuredEventEntity structuredEventEntity = new StructuredEventEntity();
        structuredEventEntity.setEventType(operationDetails.getEventType());
        structuredEventEntity.setResourceType(operationDetails.getResourceType());
        structuredEventEntity.setResourceId(operationDetails.getResourceId());
        structuredEventEntity.setTimestamp(operationDetails.getTimestamp());
        structuredEventEntity.setAccount(operationDetails.getAccount());
        structuredEventEntity.setUserId(operationDetails.getUserId());
        structuredEventEntity.setStructuredEventJson(new Json(source));
        return structuredEventEntity;
    } catch (JsonProcessingException e) {
        // TODO What should we do in case of json processing error
        return null;
    }
}
Also used : OperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.OperationDetails) StructuredEventEntity(com.sequenceiq.cloudbreak.domain.StructuredEventEntity) Json(com.sequenceiq.cloudbreak.domain.json.Json) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 3 with OperationDetails

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

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

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

the class StructuredFlowEventFactory method createStucturedFlowEvent.

public StructuredFlowEvent createStucturedFlowEvent(Long stackId, FlowDetails flowDetails, Boolean detailed, Exception exception) {
    Stack stack = stackService.getById(stackId);
    UserProfile userProfile = userProfileService.get(stack.getAccount(), stack.getOwner());
    OperationDetails operationDetails = new OperationDetails("FLOW", "STACK", stackId, stack.getAccount(), stack.getOwner(), userProfile.getUserName(), cloudbreakNodeConfig.getId(), cbVersion);
    StackDetails stackDetails = null;
    ClusterDetails clusterDetails = null;
    BlueprintDetails blueprintDetails = null;
    if (detailed) {
        stackDetails = conversionService.convert(stack, StackDetails.class);
        Cluster cluster = stack.getCluster();
        if (cluster != null) {
            clusterDetails = conversionService.convert(cluster, ClusterDetails.class);
            blueprintDetails = conversionService.convert(cluster.getBlueprint(), BlueprintDetails.class);
        }
    }
    return exception != null ? new StructuredFlowErrorEvent(operationDetails, flowDetails, stackDetails, clusterDetails, blueprintDetails, ExceptionUtils.getStackTrace(exception)) : new StructuredFlowEvent(operationDetails, flowDetails, stackDetails, clusterDetails, blueprintDetails);
}
Also used : OperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.OperationDetails) UserProfile(com.sequenceiq.cloudbreak.domain.UserProfile) BlueprintDetails(com.sequenceiq.cloudbreak.structuredevent.event.BlueprintDetails) ClusterDetails(com.sequenceiq.cloudbreak.structuredevent.event.ClusterDetails) StructuredFlowErrorEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredFlowErrorEvent) StackDetails(com.sequenceiq.cloudbreak.structuredevent.event.StackDetails) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) StructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredFlowEvent) Stack(com.sequenceiq.cloudbreak.domain.Stack)

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