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;
}
Aggregations