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