Search in sources :

Example 1 with ApiEventQueryResult

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;
}
Also used : ApiEvent(com.cloudera.api.swagger.model.ApiEvent) ArrayList(java.util.ArrayList) ApiEventQueryResult(com.cloudera.api.swagger.model.ApiEventQueryResult) EventsResourceApi(com.cloudera.api.swagger.EventsResourceApi) ApiException(com.cloudera.api.swagger.client.ApiException)

Aggregations

EventsResourceApi (com.cloudera.api.swagger.EventsResourceApi)1 ApiException (com.cloudera.api.swagger.client.ApiException)1 ApiEvent (com.cloudera.api.swagger.model.ApiEvent)1 ApiEventQueryResult (com.cloudera.api.swagger.model.ApiEventQueryResult)1 ArrayList (java.util.ArrayList)1