use of com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson in project cloudbreak by hortonworks.
the class CloudbreakUtil method waitForEvent.
public static WaitResult waitForEvent(CloudbreakClient cloudbreakClient, String stackName, String eventType, String eventMessage, long sinceTimeStamp) {
WaitResult waitResult = WaitResult.SUCCESSFUL;
Boolean exitCriteria = FALSE;
int retryCount = 0;
do {
LOGGER.info("Waiting for event type {} and event message contains {} ...", eventType, eventMessage);
sleep();
EventEndpoint eventEndpoint = cloudbreakClient.eventEndpoint();
List<CloudbreakEventsJson> list = eventEndpoint.get(sinceTimeStamp);
for (CloudbreakEventsJson event : list) {
if (event.getStackName().equals(stackName) && event.getEventMessage().contains(eventMessage) && event.getEventType().equals(eventType)) {
exitCriteria = Boolean.TRUE;
break;
}
}
retryCount++;
} while (!exitCriteria && retryCount < MAX_RETRY);
LOGGER.info("Event {} for {} happened and event message contains {}", eventType, stackName, eventMessage);
if (retryCount == MAX_RETRY) {
waitResult = WaitResult.TIMEOUT;
}
return waitResult;
}
use of com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson 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));
}
use of com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson in project cloudbreak by hortonworks.
the class NotificationController method notify.
protected final void notify(IdentityUser user, ResourceEvent resourceEvent) {
CloudbreakEventsJson notification = new CloudbreakEventsJson();
notification.setEventTimestamp(new Date().getTime());
notification.setOwner(user.getUserId());
notification.setAccount(user.getAccount());
notification.setEventType(resourceEvent.name());
notification.setEventMessage(messagesService.getMessage(resourceEvent.getMessage()));
notificationSender.send(new Notification<>(notification));
}
use of com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson in project cloudbreak by hortonworks.
the class CloudbreakEventHandler method accept.
@Override
public void accept(Event<StructuredNotificationEvent> cloudbreakEvent) {
StructuredNotificationEvent structuredNotificationEvent = cloudbreakEvent.getData();
structuredEventClient.sendStructuredEvent(structuredNotificationEvent);
CloudbreakEventsJson cloudbreakEventsJson = conversionService.convert(structuredNotificationEvent, CloudbreakEventsJson.class);
notificationSender.send(notificationAssemblingService.createNotification(cloudbreakEventsJson));
}
use of com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson in project cloudbreak by hortonworks.
the class StructuredNotificationEventToCloudbreakEventJsonConverterTest method testConvert.
@Test
public void testConvert() {
// GIVEN
// WHEN
CloudbreakEventsJson result = underTest.convert(getSource());
// THEN
assertEquals("message", result.getEventMessage());
assertAllFieldsNotNull(result, Lists.newArrayList("availabilityZone"));
}
Aggregations