use of com.cloudera.api.swagger.model.ApiEventQueryResult in project knox by apache.
the class PollingConfigurationAnalyzer method queryEvents.
/**
* Query the ClouderaManager instance associated with the specified client for any service start events in the
* specified cluster since the specified time.
*
* @param client A ClouderaManager API client.
* @param clusterName The name of the cluster for which events should be queried.
* @param since The ISO8601 timestamp indicating from which time to query.
*
* @return A List of ApiEvent objects representing the relevant events since the specified time.
*/
protected List<ApiEvent> queryEvents(final ApiClient client, final String clusterName, final String since) {
List<ApiEvent> events = new ArrayList<>();
// Setup the query for events
String timeFilter = (since != null) ? String.format(Locale.ROOT, EVENTS_QUERY_TIMESTAMP_FORMAT, since) : "";
String queryString = String.format(Locale.ROOT, EVENTS_QUERY_FORMAT, clusterName, timeFilter);
try {
// giving 'null' as maximum result size results in fetching all events from CM within the given time interval
ApiEventQueryResult eventsResult = (new EventsResourceApi(client)).readEvents(null, queryString, 0);
events.addAll(eventsResult.getItems());
} catch (ApiException e) {
log.clouderaManagerEventsAPIError(e);
}
return events;
}
Aggregations