use of com.cloudera.api.swagger.client.ApiClient in project knox by apache.
the class PollingConfigurationAnalyzer method getCurrentServiceConfiguration.
/**
* Get the current configuration for the specified service.
*
* @param address The address of the ClouderaManager instance.
* @param clusterName The name of the cluster.
* @param service The name of the service.
*
* @return A ServiceConfigurationModel object with the configuration properties associated with the specified
* service.
*/
protected ServiceConfigurationModel getCurrentServiceConfiguration(final String address, final String clusterName, final String service) {
ServiceConfigurationModel currentConfig = null;
log.gettingCurrentClusterConfiguration(service, clusterName, address);
ApiClient apiClient = getApiClient(configCache.getDiscoveryConfig(address, clusterName));
ServicesResourceApi api = new ServicesResourceApi(apiClient);
try {
ApiServiceConfig svcConfig = api.readServiceConfig(clusterName, service, "full");
Map<ApiRole, ApiConfigList> roleConfigs = new HashMap<>();
RolesResourceApi rolesApi = (new RolesResourceApi(apiClient));
ApiRoleList roles = rolesApi.readRoles(clusterName, service, "", "full");
for (ApiRole role : roles.getItems()) {
ApiConfigList config = rolesApi.readRoleConfig(clusterName, role.getName(), service, "full");
roleConfigs.put(role, config);
}
currentConfig = new ServiceConfigurationModel(svcConfig, roleConfigs);
} catch (ApiException e) {
log.clouderaManagerConfigurationAPIError(e);
}
return currentConfig;
}
use of com.cloudera.api.swagger.client.ApiClient in project tbd-studio-se by Talend.
the class HadoopCMConfigurator method createClient.
private ApiClient createClient(Builder build) throws CertificateEncodingException {
ApiClient cmClient = Configuration.getDefaultApiClient();
StringBuffer sb = new StringBuffer(build.url.toString());
if (!sb.toString().endsWith("/")) {
sb.append("/");
}
sb.append("api");
cmClient.setBasePath(sb.toString());
cmClient.setUsername(build.user);
cmClient.setPassword(build.password);
// trust manager can be null for non https connection
if (build.tms != null) {
StringBuffer caCerts = new StringBuffer();
for (TrustManager tm : build.tms) {
if (tm instanceof X509TrustManager) {
X509TrustManager xtm = (X509TrustManager) tm;
buildCaCerts(caCerts, xtm);
}
}
if (caCerts.length() > 0) {
cmClient.setSslCaCert(new ByteArrayInputStream(caCerts.toString().getBytes()));
}
}
return cmClient;
}
Aggregations