Search in sources :

Example 1 with EventEndpoint

use of com.sequenceiq.cloudbreak.api.endpoint.v1.EventEndpoint 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)

Aggregations

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 CloudbreakEventsJson (com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson)1 HistoryEndpoint (com.sequenceiq.periscope.api.endpoint.v1.HistoryEndpoint)1