Search in sources :

Example 6 with CloudbreakEventsJson

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;
}
Also used : EventEndpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.EventEndpoint) CloudbreakEventsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson) StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) StackEndpoint(com.sequenceiq.cloudbreak.api.endpoint.common.StackEndpoint) HistoryEndpoint(com.sequenceiq.periscope.api.endpoint.v1.HistoryEndpoint) EventEndpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.EventEndpoint)

Example 7 with CloudbreakEventsJson

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));
}
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 8 with CloudbreakEventsJson

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));
}
Also used : CloudbreakEventsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson) Date(java.util.Date)

Example 9 with CloudbreakEventsJson

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));
}
Also used : CloudbreakEventsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson) StructuredNotificationEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredNotificationEvent)

Example 10 with 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"));
}
Also used : CloudbreakEventsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest) Test(org.junit.Test)

Aggregations

CloudbreakEventsJson (com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson)16 Notification (com.sequenceiq.cloudbreak.service.notification.Notification)7 Date (java.util.Date)7 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)4 Stack (com.sequenceiq.cloudbreak.domain.Stack)4 Test (org.junit.Test)4 StackEndpoint (com.sequenceiq.cloudbreak.api.endpoint.common.StackEndpoint)1 EventEndpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.EventEndpoint)1 StackV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint)1 Status (com.sequenceiq.cloudbreak.api.model.Status)1 InteractiveCredentialCreationStatus (com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveCredentialCreationStatus)1 AbstractEntityConverterTest (com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)1 NotificationDetails (com.sequenceiq.cloudbreak.structuredevent.event.NotificationDetails)1 OperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.OperationDetails)1 StructuredNotificationEvent (com.sequenceiq.cloudbreak.structuredevent.event.StructuredNotificationEvent)1 HistoryEndpoint (com.sequenceiq.periscope.api.endpoint.v1.HistoryEndpoint)1 Scheduled (org.springframework.scheduling.annotation.Scheduled)1