Search in sources :

Example 1 with Notification

use of com.sequenceiq.cloudbreak.service.notification.Notification in project cloudbreak by hortonworks.

the class ImageStatusCheckerTask method getImageCopyNotification.

private Notification<CloudbreakEventsJson> getImageCopyNotification(ImageStatusResult result, Stack stack) {
    CloudbreakEventsJson notification = new CloudbreakEventsJson();
    notification.setEventType("IMAGE_COPY_STATE");
    notification.setEventTimestamp(new Date().getTime());
    notification.setEventMessage(String.valueOf(result.getStatusProgressValue()));
    notification.setOwner(stack.getOwner());
    notification.setAccount(stack.getAccount());
    notification.setCloud(stack.cloudPlatform());
    notification.setRegion(stack.getRegion());
    notification.setStackId(stack.getId());
    notification.setStackName(stack.getDisplayName());
    notification.setStackStatus(stack.getStatus());
    return new Notification<>(notification);
}
Also used : CloudbreakEventsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson) Date(java.util.Date) Notification(com.sequenceiq.cloudbreak.service.notification.Notification)

Example 2 with Notification

use of com.sequenceiq.cloudbreak.service.notification.Notification in project cloudbreak by hortonworks.

the class AmbariOperationsStatusCheckerTask method getAmbariProgressNotification.

private Notification<CloudbreakEventsJson> getAmbariProgressNotification(Long progressValue, Stack stack, AmbariOperationType ambariOperationType) {
    CloudbreakEventsJson notification = new CloudbreakEventsJson();
    notification.setEventType(ambariOperationType.name());
    notification.setEventTimestamp(new Date().getTime());
    notification.setEventMessage(String.valueOf(progressValue));
    notification.setOwner(stack.getOwner());
    notification.setAccount(stack.getAccount());
    notification.setCloud(stack.cloudPlatform());
    notification.setRegion(stack.getRegion());
    notification.setStackId(stack.getId());
    notification.setStackName(stack.getDisplayName());
    notification.setStackStatus(stack.getStatus());
    if (stack.getCluster() != null) {
        notification.setClusterId(stack.getCluster().getId());
        notification.setClusterName(stack.getCluster().getName());
    }
    return new Notification<>(notification);
}
Also used : CloudbreakEventsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson) Date(java.util.Date) Notification(com.sequenceiq.cloudbreak.service.notification.Notification)

Example 3 with Notification

use of com.sequenceiq.cloudbreak.service.notification.Notification in project cloudbreak by hortonworks.

the class StackCreationService method getImageCopyNotification.

private Notification<CloudbreakEventsJson> getImageCopyNotification(CheckImageResult result, Stack stack) {
    CloudbreakEventsJson notification = new CloudbreakEventsJson();
    notification.setEventType("IMAGE_COPY_STATE");
    notification.setEventTimestamp(new Date().getTime());
    notification.setEventMessage(String.valueOf(result.getStatusProgressValue()));
    notification.setOwner(stack.getOwner());
    notification.setAccount(stack.getAccount());
    notification.setCloud(stack.cloudPlatform());
    notification.setRegion(stack.getRegion());
    notification.setStackId(stack.getId());
    notification.setStackName(stack.getDisplayName());
    notification.setStackStatus(stack.getStatus());
    return new Notification<>(notification);
}
Also used : CloudbreakEventsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson) Date(java.util.Date) Notification(com.sequenceiq.cloudbreak.service.notification.Notification)

Example 4 with Notification

use of com.sequenceiq.cloudbreak.service.notification.Notification in project cloudbreak by hortonworks.

the class UptimeNotifierTest method notificationSendingWhenEverythingWorkFine.

@Test
public void notificationSendingWhenEverythingWorkFine() {
    doNothing().when(notificationSender).send(any(Notification.class));
    List<Cluster> clusters = TestUtil.generateCluster(1);
    when(clusterRepository.findByStatuses(any())).thenReturn(Collections.singletonList(clusters.get(0)));
    Stack stack1 = TestUtil.stack();
    when(stackRepository.findStackForCluster(anyLong())).thenReturn(stack1);
    underTest.sendUptime();
    ArgumentCaptor<Notification> argument1 = ArgumentCaptor.forClass(Notification.class);
    verify(notificationSender).send(argument1.capture());
    Notification<CloudbreakEventsJson> notification = argument1.getValue();
    assertEquals(GCP, notification.getNotification().getCloud());
    assertEquals("null", notification.getNotification().getBlueprintName());
    assertEquals(null, notification.getNotification().getBlueprintId());
    verify(notificationSender, times(1)).send(any(Notification.class));
}
Also used : CloudbreakEventsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) Notification(com.sequenceiq.cloudbreak.service.notification.Notification) Stack(com.sequenceiq.cloudbreak.domain.Stack) Test(org.junit.Test)

Example 5 with Notification

use of com.sequenceiq.cloudbreak.service.notification.Notification in project cloudbreak by hortonworks.

the class UptimeNotifierTest method notificationSendingWhenBlueprintNotNullEverythingWorkFine.

@Test
public void notificationSendingWhenBlueprintNotNullEverythingWorkFine() {
    doNothing().when(notificationSender).send(any(Notification.class));
    List<Cluster> clusters = TestUtil.generateCluster(1);
    when(clusterRepository.findByStatuses(any())).thenReturn(Collections.singletonList(clusters.get(0)));
    Stack stack2 = TestUtil.stack();
    stack2.setCluster(clusters.get(0));
    when(stackRepository.findStackForCluster(anyLong())).thenReturn(stack2);
    underTest.sendUptime();
    ArgumentCaptor<Notification> argument2 = ArgumentCaptor.forClass(Notification.class);
    verify(notificationSender).send(argument2.capture());
    Notification<CloudbreakEventsJson> notification = argument2.getValue();
    assertEquals(GCP, notification.getNotification().getCloud());
    assertEquals("multi-node-yarn", notification.getNotification().getBlueprintName());
    assertEquals(Long.valueOf(1), notification.getNotification().getBlueprintId());
    verify(notificationSender, times(1)).send(any(Notification.class));
}
Also used : CloudbreakEventsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) Notification(com.sequenceiq.cloudbreak.service.notification.Notification) Stack(com.sequenceiq.cloudbreak.domain.Stack) Test(org.junit.Test)

Aggregations

CloudbreakEventsJson (com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson)7 Notification (com.sequenceiq.cloudbreak.service.notification.Notification)7 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)3 Stack (com.sequenceiq.cloudbreak.domain.Stack)3 Date (java.util.Date)3 Test (org.junit.Test)3