use of com.cloudera.api.swagger.client.ApiException in project knox by apache.
the class ClouderaManagerServiceDiscovery method getClusterServices.
private List<ApiService> getClusterServices(ServiceDiscoveryConfig serviceDiscoveryConfig, ServicesResourceApi servicesResourceApi) {
log.lookupClusterServicesFromRepository();
List<ApiService> services = repository.getServices(serviceDiscoveryConfig);
if (services == null || services.isEmpty()) {
try {
log.lookupClusterServicesFromCM();
final ApiServiceList serviceList = servicesResourceApi.readServices(serviceDiscoveryConfig.getCluster(), VIEW_SUMMARY);
services = serviceList == null ? new ArrayList<>() : serviceList.getItems();
// make sure that services are populated in the repository
services.forEach(service -> repository.addService(serviceDiscoveryConfig, service));
} catch (ApiException e) {
log.failedToAccessServiceConfigs(serviceDiscoveryConfig.getCluster(), e);
}
}
return services;
}
use of com.cloudera.api.swagger.client.ApiException 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