Search in sources :

Example 1 with CmRequestIdProviderInterceptor

use of com.sequenceiq.cloudbreak.cm.client.tracing.CmRequestIdProviderInterceptor in project cloudbreak by hortonworks.

the class ClouderaManagerCommunicator method getRoleConfigPropertiesFromCM.

public Map<String, ApiConfig> getRoleConfigPropertiesFromCM(Cluster cluster, String serviceName, String roleGroupRef, Set roleConfigPropertyNames) {
    LOGGER.debug("Retrieving roleConfigProperties for cluster '{}', service '{}', roleGroupRef '{}'", cluster.getStackCrn(), serviceName, roleGroupRef);
    HttpClientConfig httpClientConfig = tlsHttpClientConfigurationService.buildTLSClientConfig(cluster.getStackCrn(), cluster.getClusterManager().getHost(), cluster.getTunnel());
    ClusterManager cm = cluster.getClusterManager();
    String user = secretService.get(cm.getUser());
    String pass = secretService.get(cm.getPass());
    Map<String, ApiConfig> roleConfigProperties = requestLogging.logResponseTime(() -> {
        try {
            ApiClient client = clouderaManagerApiClientProvider.getV31Client(Integer.valueOf(cm.getPort()), user, pass, httpClientConfig);
            client.getHttpClient().interceptors().add(cmOkHttpTracingInterceptor);
            client.getHttpClient().interceptors().add(cmRequestIdProviderInterceptor);
            RoleConfigGroupsResourceApi roleConfigGroupsResourceApi = clouderaManagerApiFactory.getRoleConfigGroupsResourceApi(client);
            return roleConfigGroupsResourceApi.readConfig(cluster.getStackName(), roleGroupRef, serviceName, DataView.FULL.name()).getItems().stream().filter(apiConfig -> roleConfigPropertyNames.contains(apiConfig.getName())).collect(Collectors.toMap(ApiConfig::getName, apiConfig -> apiConfig));
        } catch (Exception ex) {
            throw new RuntimeException(String.format("Error retrieving roleConfigProperties for cluster '%s', service '%s', roleGroupRef '%s'", cluster.getStackCrn(), serviceName, roleGroupRef), ex);
        }
    }, String.format("getRoleConfigPropertiesFromCM for cluster crn '%s'", cluster.getStackCrn()));
    LOGGER.debug("Retrieved roleConfigPropertyValues for cluster '{}', service '{}', roleGroupRef '{}', roleConfigProperties '{}", cluster.getStackCrn(), serviceName, roleGroupRef, roleConfigProperties.values().stream().map(apiConfig -> String.format("ApiConfig Name '%s, Value '%s', Default '%s", apiConfig.getName(), apiConfig.getValue(), apiConfig.getDefault())).collect(Collectors.toSet()));
    return roleConfigProperties;
}
Also used : RoleConfigGroupsResourceApi(com.cloudera.api.swagger.RoleConfigGroupsResourceApi) ApiConfig(com.cloudera.api.swagger.model.ApiConfig) Logger(org.slf4j.Logger) Cluster(com.sequenceiq.periscope.domain.Cluster) CmRequestIdProviderInterceptor(com.sequenceiq.cloudbreak.cm.client.tracing.CmRequestIdProviderInterceptor) CmOkHttpTracingInterceptor(com.sequenceiq.cloudbreak.cm.client.tracing.CmOkHttpTracingInterceptor) ApiClient(com.cloudera.api.swagger.client.ApiClient) LoggerFactory(org.slf4j.LoggerFactory) SecretService(com.sequenceiq.cloudbreak.service.secret.service.SecretService) Set(java.util.Set) DataView(com.sequenceiq.cloudbreak.cm.DataView) RequestLogging(com.sequenceiq.periscope.aspects.RequestLogging) HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) Collectors(java.util.stream.Collectors) Inject(javax.inject.Inject) RoleConfigGroupsResourceApi(com.cloudera.api.swagger.RoleConfigGroupsResourceApi) ClouderaManagerApiClientProvider(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerApiClientProvider) ClusterManager(com.sequenceiq.periscope.domain.ClusterManager) Service(org.springframework.stereotype.Service) Map(java.util.Map) TlsHttpClientConfigurationService(com.sequenceiq.periscope.service.security.TlsHttpClientConfigurationService) ClouderaManagerApiFactory(com.sequenceiq.cloudbreak.cm.client.retry.ClouderaManagerApiFactory) ClusterService(com.sequenceiq.periscope.service.ClusterService) HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) ApiConfig(com.cloudera.api.swagger.model.ApiConfig) ApiClient(com.cloudera.api.swagger.client.ApiClient) ClusterManager(com.sequenceiq.periscope.domain.ClusterManager)

Aggregations

RoleConfigGroupsResourceApi (com.cloudera.api.swagger.RoleConfigGroupsResourceApi)1 ApiClient (com.cloudera.api.swagger.client.ApiClient)1 ApiConfig (com.cloudera.api.swagger.model.ApiConfig)1 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)1 DataView (com.sequenceiq.cloudbreak.cm.DataView)1 ClouderaManagerApiClientProvider (com.sequenceiq.cloudbreak.cm.client.ClouderaManagerApiClientProvider)1 ClouderaManagerApiFactory (com.sequenceiq.cloudbreak.cm.client.retry.ClouderaManagerApiFactory)1 CmOkHttpTracingInterceptor (com.sequenceiq.cloudbreak.cm.client.tracing.CmOkHttpTracingInterceptor)1 CmRequestIdProviderInterceptor (com.sequenceiq.cloudbreak.cm.client.tracing.CmRequestIdProviderInterceptor)1 SecretService (com.sequenceiq.cloudbreak.service.secret.service.SecretService)1 RequestLogging (com.sequenceiq.periscope.aspects.RequestLogging)1 Cluster (com.sequenceiq.periscope.domain.Cluster)1 ClusterManager (com.sequenceiq.periscope.domain.ClusterManager)1 ClusterService (com.sequenceiq.periscope.service.ClusterService)1 TlsHttpClientConfigurationService (com.sequenceiq.periscope.service.security.TlsHttpClientConfigurationService)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Logger (org.slf4j.Logger)1