use of com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson 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));
}
use of com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson in project cloudbreak by hortonworks.
the class UptimeNotifierTest method notificationSendingWhenCredentialNullEverythingWorkFine.
@Test
public void notificationSendingWhenCredentialNullEverythingWorkFine() {
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));
stack2.setCredential(null);
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("null", 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));
}
use of com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson in project cloudbreak by hortonworks.
the class CredentialService method sendCredentialNotification.
private void sendCredentialNotification(Credential credential, ResourceEvent resourceEvent) {
CloudbreakEventsJson notification = new CloudbreakEventsJson();
notification.setEventType(resourceEvent.name());
notification.setEventTimestamp(new Date().getTime());
notification.setEventMessage(resourceEvent.getMessage());
notification.setOwner(credential.getOwner());
notification.setAccount(credential.getAccount());
notification.setCloud(credential.cloudPlatform());
notificationSender.send(new Notification<>(notification));
}
use of com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson in project cloudbreak by hortonworks.
the class InteractiveCredentialCreationStatusHandler method accept.
@Override
public void accept(Event<InteractiveCredentialCreationStatus> interactiveCredentialCreationFailedEvent) {
InteractiveCredentialCreationStatus interactiveCredentialCreationStatus = interactiveCredentialCreationFailedEvent.getData();
String message = interactiveCredentialCreationStatus.getMessage();
CloudbreakEventsJson notification = new CloudbreakEventsJson();
if (interactiveCredentialCreationStatus.isError()) {
notification.setEventType("CREDENTIAL_CREATE_FAILED");
} else {
notification.setEventType("INTERACTIVE_CREDENTIAL_STATUS");
}
notification.setEventTimestamp(new Date().getTime());
notification.setEventMessage(message);
notification.setOwner(interactiveCredentialCreationStatus.getCloudContext().getOwner());
notification.setAccount(interactiveCredentialCreationStatus.getExtendedCloudCredential().getAccount());
notification.setCloud(interactiveCredentialCreationStatus.getExtendedCloudCredential().getCloudPlatform());
notificationSender.send(new Notification<>(notification));
}
use of com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson in project cloudbreak by hortonworks.
the class UptimeNotifier method sendUptime.
@Scheduled(fixedDelay = 60000)
public void sendUptime() {
EnumSet<Status> statuses = EnumSet.complementOf(EnumSet.of(Status.DELETE_COMPLETED));
List<Cluster> clusters = clusterRepository.findByStatuses(statuses);
for (Cluster cluster : clusters) {
Stack stack = stackRepository.findStackForCluster(cluster.getId());
if (stack != null && !stack.isDeleteCompleted()) {
Long uptime = stackUtil.getUptimeForCluster(cluster, cluster.isAvailable());
Notification<CloudbreakEventsJson> notification = createUptimeNotification(stack, uptime);
notificationSender.send(notification);
}
}
}
Aggregations