Search in sources :

Example 16 with ClouderaManagerClientInitException

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

the class ClouderaManagerSetupService method waitForHostsHealthy.

@Override
public void waitForHostsHealthy(Set<InstanceMetaData> hostsInCluster) throws ClusterClientInitException {
    Cluster cluster = stack.getCluster();
    String user = cluster.getCloudbreakAmbariUser();
    String password = cluster.getCloudbreakAmbariPassword();
    ApiClient client;
    try {
        client = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
    } catch (ClouderaManagerClientInitException e) {
        throw new ClusterClientInitException(e);
    }
    clouderaManagerPollingServiceProvider.startPollingCmHostStatusHealthy(stack, client, hostsInCluster.stream().map(x -> x.getDiscoveryFQDN()).collect(Collectors.toUnmodifiableSet()));
}
Also used : ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) ApiCluster(com.cloudera.api.swagger.model.ApiCluster) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) ApiClient(com.cloudera.api.swagger.client.ApiClient)

Example 17 with ClouderaManagerClientInitException

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

the class ClouderaManagerSetupService method setupRemoteDataContext.

@Override
public String setupRemoteDataContext(String sdxContext) {
    Cluster cluster = stack.getCluster();
    String user = cluster.getCloudbreakAmbariUser();
    String password = cluster.getCloudbreakAmbariPassword();
    try {
        ApiClient rootClient = clouderaManagerApiClientProvider.getRootClient(stack.getGatewayPort(), user, password, clientConfig);
        CdpResourceApi cdpResourceApi = clouderaManagerApiFactory.getCdpResourceApi(rootClient);
        ApiRemoteDataContext apiRemoteDataContext = JsonUtil.readValue(sdxContext, ApiRemoteDataContext.class);
        LOGGER.debug("Posting remote context to workload. EndpointId: {}", apiRemoteDataContext.getEndPointId());
        return cdpResourceApi.postRemoteContext(apiRemoteDataContext).getEndPointId();
    } catch (ApiException | ClouderaManagerClientInitException e) {
        LOGGER.info("Error while creating data context using: {}", sdxContext, e);
        throw new ClouderaManagerOperationFailedException(String.format("Error while creating data context: %s", e.getMessage()), e);
    } catch (IOException e) {
        LOGGER.info("Failed to parse SDX context to CM API object.", e);
        throw new ClouderaManagerOperationFailedException(String.format("Failed to parse SDX context to CM API object: %s", e.getMessage()), e);
    }
}
Also used : ApiRemoteDataContext(com.cloudera.api.swagger.model.ApiRemoteDataContext) ApiCluster(com.cloudera.api.swagger.model.ApiCluster) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) IOException(java.io.IOException) ApiClient(com.cloudera.api.swagger.client.ApiClient) CdpResourceApi(com.cloudera.api.swagger.CdpResourceApi) ApiException(com.cloudera.api.swagger.client.ApiException)

Example 18 with ClouderaManagerClientInitException

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

the class ClouderaManagerSetupService method getSdxContext.

@Override
public String getSdxContext() {
    Cluster cluster = stack.getCluster();
    String user = cluster.getCloudbreakAmbariUser();
    String password = cluster.getCloudbreakAmbariPassword();
    try {
        ApiClient rootClient = clouderaManagerApiClientProvider.getRootClient(stack.getGatewayPort(), user, password, clientConfig);
        CdpResourceApi cdpResourceApi = clouderaManagerApiFactory.getCdpResourceApi(rootClient);
        LOGGER.info("Get remote context from Datalake cluster: {}", stack.getName());
        ApiRemoteDataContext remoteDataContext = cdpResourceApi.getRemoteContextByCluster(stack.getName());
        return JsonUtil.writeValueAsString(remoteDataContext);
    } catch (ApiException | ClouderaManagerClientInitException e) {
        LOGGER.error("Error while getting remote context of Datalake cluster: {}", stack.getName(), e);
        throw new ClouderaManagerOperationFailedException("Error while getting remote context of Datalake cluster", e);
    } catch (JsonProcessingException e) {
        LOGGER.error("Failed to serialize remote context.", e);
        throw new ClouderaManagerOperationFailedException("Failed to serialize remote context.", e);
    }
}
Also used : ApiRemoteDataContext(com.cloudera.api.swagger.model.ApiRemoteDataContext) ApiCluster(com.cloudera.api.swagger.model.ApiCluster) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) ApiClient(com.cloudera.api.swagger.client.ApiClient) CdpResourceApi(com.cloudera.api.swagger.CdpResourceApi) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ApiException(com.cloudera.api.swagger.client.ApiException)

Example 19 with ClouderaManagerClientInitException

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

the class ClouderaManagerSetupService method initApiClient.

@PostConstruct
public void initApiClient() throws ClusterClientInitException {
    Cluster cluster = stack.getCluster();
    String user = cluster.getCloudbreakAmbariUser();
    String password = cluster.getCloudbreakAmbariPassword();
    try {
        ClouderaManagerRepo clouderaManagerRepoDetails = clusterComponentProvider.getClouderaManagerRepoDetails(cluster.getId());
        if (isVersionNewerOrEqualThanLimited(clouderaManagerRepoDetails::getVersion, CLOUDERAMANAGER_VERSION_7_1_0)) {
            apiClient = clouderaManagerApiClientProvider.getV40Client(stack.getGatewayPort(), user, password, clientConfig);
        } else {
            apiClient = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
        }
    } catch (ClouderaManagerClientInitException e) {
        throw new ClusterClientInitException(e);
    }
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) ApiCluster(com.cloudera.api.swagger.model.ApiCluster) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) PostConstruct(javax.annotation.PostConstruct)

Example 20 with ClouderaManagerClientInitException

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

the class ClouderaManagerClusterCommissionService method initApiClient.

@PostConstruct
public void initApiClient() throws ClusterClientInitException {
    Cluster cluster = stack.getCluster();
    String user = cluster.getCloudbreakAmbariUser();
    String password = cluster.getCloudbreakAmbariPassword();
    try {
        client = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
    } catch (ClouderaManagerClientInitException e) {
        throw new ClusterClientInitException(e);
    }
}
Also used : ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) PostConstruct(javax.annotation.PostConstruct)

Aggregations

ClouderaManagerClientInitException (com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException)22 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)18 ClusterClientInitException (com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException)15 ApiClient (com.cloudera.api.swagger.client.ApiClient)14 ApiException (com.cloudera.api.swagger.client.ApiException)11 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)9 ToolsResourceApi (com.cloudera.api.swagger.ToolsResourceApi)5 UsersResourceApi (com.cloudera.api.swagger.UsersResourceApi)5 ApiCluster (com.cloudera.api.swagger.model.ApiCluster)5 PostConstruct (javax.annotation.PostConstruct)5 BatchResourceApi (com.cloudera.api.swagger.BatchResourceApi)4 HostsResourceApi (com.cloudera.api.swagger.HostsResourceApi)4 ApiBatchRequest (com.cloudera.api.swagger.model.ApiBatchRequest)4 ApiBatchResponse (com.cloudera.api.swagger.model.ApiBatchResponse)4 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)4 ApiHostList (com.cloudera.api.swagger.model.ApiHostList)4 ApiUser2 (com.cloudera.api.swagger.model.ApiUser2)4 ApiUser2List (com.cloudera.api.swagger.model.ApiUser2List)4 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)4 ApiAuthRoleRef (com.cloudera.api.swagger.model.ApiAuthRoleRef)3