Search in sources :

Example 11 with RoleConfigGroupsResourceApi

use of com.cloudera.api.swagger.RoleConfigGroupsResourceApi in project cloudbreak by hortonworks.

the class ClouderaManagerClientActions method checkCmHdfsDatanodeRoleConfigGroups.

public DistroXTestDto checkCmHdfsDatanodeRoleConfigGroups(DistroXTestDto testDto, String user, String password, Set<String> mountPoints) {
    String serverIp = testDto.getResponse().getCluster().getServerIp();
    ApiClient apiClient = getCmApiClientWithTimeoutDisabled(serverIp, testDto.getName(), V_43, user, password);
    // CHECKSTYLE:OFF
    RoleConfigGroupsResourceApi roleConfigGroupsResourceApi = new RoleConfigGroupsResourceApi(apiClient);
    // CHECKSTYLE:ON
    try {
        ApiConfigList hdfsConfigs = roleConfigGroupsResourceApi.readConfig(testDto.getName(), "hdfs-DATANODE-BASE", "hdfs", "summary");
        hdfsConfigs.getItems().forEach(config -> {
            String hdfsConfigName = config.getName();
            String mappingsFromHdfsConfig = config.getValue();
            if ("dfs_data_dir_list".equalsIgnoreCase(hdfsConfigName)) {
                if (mountPoints.stream().anyMatch(mappingsFromHdfsConfig::startsWith)) {
                    LOGGER.error("{} contains ephemeral volume mapping '{}'!", hdfsConfigName, mappingsFromHdfsConfig);
                    throw new TestFailException(String.format("%s contains ephemeral volume mapping '%s'!", hdfsConfigName, mappingsFromHdfsConfig));
                } else {
                    Log.log(LOGGER, format(" '%s' does not contain the ephemeral mapping '%s', as expected. ", hdfsConfigName, mappingsFromHdfsConfig));
                }
            }
        });
        if (hdfsConfigs.getItems().isEmpty()) {
            LOGGER.error("Datanode mappings are NOT exist!");
            throw new TestFailException("Datanode mappings are NOT exist!");
        }
    } catch (ApiException e) {
        LOGGER.error("Exception when calling RoleConfigGroupsResourceApi#readConfig. Response: {}", e.getResponseBody(), e);
        String message = format("Exception when calling RoleConfigGroupsResourceApi#readConfig at %s. Response: %s", apiClient.getBasePath(), e.getResponseBody());
        throw new TestFailException(message, e);
    } catch (Exception e) {
        LOGGER.error("Can't read config at: '{}'!", apiClient.getBasePath());
        throw new TestFailException("Can't read config at: " + apiClient.getBasePath(), e);
    }
    return testDto;
}
Also used : RoleConfigGroupsResourceApi(com.cloudera.api.swagger.RoleConfigGroupsResourceApi) ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) ApiClient(com.cloudera.api.swagger.client.ApiClient) ApiException(com.cloudera.api.swagger.client.ApiException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) ApiException(com.cloudera.api.swagger.client.ApiException)

Aggregations

RoleConfigGroupsResourceApi (com.cloudera.api.swagger.RoleConfigGroupsResourceApi)11 ApiConfigList (com.cloudera.api.swagger.model.ApiConfigList)8 ServicesResourceApi (com.cloudera.api.swagger.ServicesResourceApi)6 ApiService (com.cloudera.api.swagger.model.ApiService)6 ApiClient (com.cloudera.api.swagger.client.ApiClient)5 ApiException (com.cloudera.api.swagger.client.ApiException)5 ApiRoleConfigGroupList (com.cloudera.api.swagger.model.ApiRoleConfigGroupList)5 Test (org.junit.Test)5 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)4 ApiConfig (com.cloudera.api.swagger.model.ApiConfig)2 ClouderaManagerApiFactory (com.sequenceiq.cloudbreak.cm.client.retry.ClouderaManagerApiFactory)2 Map (java.util.Map)2 Inject (javax.inject.Inject)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Service (org.springframework.stereotype.Service)2 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)1 ApiServiceConfig (com.cloudera.api.swagger.model.ApiServiceConfig)1 ApiServiceList (com.cloudera.api.swagger.model.ApiServiceList)1 ApiVersionInfo (com.cloudera.api.swagger.model.ApiVersionInfo)1