Search in sources :

Example 16 with ClustersResourceApi

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

the class ClouderaManagerModificationService method startServices.

private int startServices() throws ApiException, CloudbreakException {
    Cluster cluster = stack.getCluster();
    ClustersResourceApi apiInstance = clouderaManagerApiFactory.getClustersResourceApi(apiClient);
    String clusterName = cluster.getName();
    LOGGER.debug("Starting all services for cluster.");
    configService.enableKnoxAutorestartIfCmVersionAtLeast(CLOUDERAMANAGER_VERSION_7_1_0, apiClient, stack.getName());
    eventService.fireCloudbreakEvent(stack.getId(), UPDATE_IN_PROGRESS.name(), CLUSTER_CM_CLUSTER_SERVICES_STARTING);
    Collection<ApiService> apiServices = readServices(stack);
    boolean anyServiceNotStarted = apiServices.stream().anyMatch(service -> !ApiServiceState.STARTED.equals(service.getServiceState()) && !ApiServiceState.STARTING.equals(service.getServiceState()) && !ApiServiceState.NA.equals(service.getServiceState()));
    ApiCommand apiCommand = null;
    if (anyServiceNotStarted) {
        apiCommand = apiInstance.startCommand(clusterName);
        ExtendedPollingResult pollingResult = clouderaManagerPollingServiceProvider.startPollingCmStartup(stack, apiClient, apiCommand.getId());
        handlePollingResult(pollingResult, "Cluster was terminated while waiting for Cloudera Runtime services to start", "Timeout while stopping Cloudera Manager services.");
    }
    eventService.fireCloudbreakEvent(stack.getId(), UPDATE_IN_PROGRESS.name(), CLUSTER_CM_CLUSTER_SERVICES_STARTED);
    return getCommandId(apiCommand);
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ApiService(com.cloudera.api.swagger.model.ApiService) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) ClustersResourceApi(com.cloudera.api.swagger.ClustersResourceApi)

Example 17 with ClustersResourceApi

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

the class ClouderaManagerModificationService method upgradeClusterRuntime.

@Override
public void upgradeClusterRuntime(Set<ClusterComponent> components, boolean patchUpgrade, Optional<String> remoteDataContext) throws CloudbreakException {
    try {
        LOGGER.info("Starting to upgrade cluster runtimes. Patch upgrade: {}", patchUpgrade);
        ClustersResourceApi clustersResourceApi = clouderaManagerApiFactory.getClustersResourceApi(apiClient);
        ParcelResourceApi parcelResourceApi = clouderaManagerApiFactory.getParcelResourceApi(apiClient);
        ClouderaManagerResourceApi clouderaManagerResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(apiClient);
        startClouderaManager();
        startAgents();
        tagHostsWithHostTemplateName();
        checkParcelApiAvailability();
        refreshRemoteDataContextFromDatalakeInCaseOfDatahub(remoteDataContext);
        Set<ClouderaManagerProduct> products = getProducts(components);
        setParcelRepo(products, clouderaManagerResourceApi);
        refreshParcelRepos(clouderaManagerResourceApi);
        restartMgmtServices();
        if (patchUpgrade) {
            downloadAndActivateParcels(products, parcelResourceApi, true);
            startServices();
            callPostClouderaRuntimeUpgradeCommandIfCMIsNewerThan751(clustersResourceApi);
            restartServices(clustersResourceApi);
        } else {
            ClouderaManagerProduct cdhProduct = clouderaManagerProductsProvider.getCdhProducts(products);
            upgradeNonCdhProducts(products, cdhProduct.getName(), parcelResourceApi, true);
            upgradeCdh(clustersResourceApi, parcelResourceApi, cdhProduct);
            startServices();
            deployConfigAndRefreshCMStaleServices(clustersResourceApi, false);
        }
        removeUnusedParcelVersions(parcelResourceApi, products);
        configService.enableKnoxAutorestartIfCmVersionAtLeast(CLOUDERAMANAGER_VERSION_7_1_0, apiClient, stack.getName());
        LOGGER.info("Cluster runtime upgrade finished");
    } catch (ApiException e) {
        LOGGER.info("Could not upgrade Cloudera Runtime services", e);
        throw new ClouderaManagerOperationFailedException(e.getMessage(), e);
    }
}
Also used : ParcelResourceApi(com.cloudera.api.swagger.ParcelResourceApi) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) ClustersResourceApi(com.cloudera.api.swagger.ClustersResourceApi) ApiException(com.cloudera.api.swagger.client.ApiException)

Example 18 with ClustersResourceApi

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

the class ClouderaManagerDeregisterService method deregisterServices.

public void deregisterServices(HttpClientConfig clientConfig, Stack stack, Optional<DatalakeDto> datalakeDto) {
    Cluster cluster = stack.getCluster();
    String user = cluster.getCloudbreakAmbariUser();
    String password = cluster.getCloudbreakAmbariPassword();
    ClouderaManagerRepo clouderaManagerRepoDetails = clusterComponentConfigProvider.getClouderaManagerRepoDetails(cluster.getId());
    try {
        CmTemplateProcessor cmTemplateProcessor = cmTemplateProcessorFactory.get(stack.getCluster().getBlueprint().getBlueprintText());
        if (CMRepositoryVersionUtil.isRangerTearDownSupported(clouderaManagerRepoDetails)) {
            if (datalakeDto.isPresent()) {
                LOGGER.info("The current cluster {} is a Data Hub cluster so teardown REQUIRED.", stack.getName());
                DatalakeDto datalake = datalakeDto.get();
                ClustersResourceApi clustersResourceApi = clouderaManagerApiFactory.getClustersResourceApi(datalakeClient(datalake));
                clustersResourceApi.tearDownWorkloadCluster(datalake.getName(), stack.getName());
            } else {
                LOGGER.info("The current cluster {} is a Data Lake cluster so teardown NOT_REQUIRED.", stack.getName());
            }
        } else {
            ApiClient client = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
            if (cmTemplateProcessor.isCMComponentExistsInBlueprint(COMPONENT_NIFI_REGISTRY_SERVER)) {
                LOGGER.info("The current cluster {} contains NIFI_REGISTRY_SERVER and ranger teardown not supported. " + "CDP will call RemoveRangerRepo command.", stack.getName());
                clouderaManagerApiFactory.getServicesResourceApi(client).serviceCommandByName(stack.getName(), "RemoveRangerRepo", SERVICE_NIFIREGISTRY);
            }
            if (cmTemplateProcessor.isCMComponentExistsInBlueprint(COMPONENT_NIFI_NODE)) {
                LOGGER.info("The current cluster {} contains NIFI_NODE and ranger teardown not supported. " + "CDP will call RemoveRangerRepo command.", stack.getName());
                clouderaManagerApiFactory.getServicesResourceApi(client).serviceCommandByName(stack.getName(), "RemoveRangerRepo", SERVICE_NIFI);
            }
        }
    } catch (Exception e) {
        LOGGER.warn("Couldn't remove services. This has to be done manually." + " It's possible that CM or the instance is not running. Notification is sent to the UI.", e);
        cloudbreakEventService.fireCloudbreakEvent(stack.getId(), stack.getStatus().name(), ResourceEvent.CLUSTER_CM_SECURITY_GROUP_TOO_STRICT, List.of(e.getMessage()));
    }
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) DatalakeDto(com.sequenceiq.cloudbreak.dto.datalake.DatalakeDto) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) ApiClient(com.cloudera.api.swagger.client.ApiClient) ClustersResourceApi(com.cloudera.api.swagger.ClustersResourceApi) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException)

Example 19 with ClustersResourceApi

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

the class ClouderaManagerRoleRefreshService method refreshClusterRoles.

void refreshClusterRoles(ApiClient client, Stack stack) throws ApiException, CloudbreakException {
    waitForGenerateCredentialsToFinish(stack, client);
    ClustersResourceApi clustersResourceApi = clouderaManagerApiFactory.getClustersResourceApi(client);
    ApiCommand refreshCommand = clustersResourceApi.refresh(stack.getCluster().getName());
    LOGGER.debug("Cluster role refresh has been started.");
    pollingRefresh(refreshCommand, client, stack);
    LOGGER.debug("Cluster role refresh finished successfully.");
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ClustersResourceApi(com.cloudera.api.swagger.ClustersResourceApi)

Aggregations

ClustersResourceApi (com.cloudera.api.swagger.ClustersResourceApi)19 ApiException (com.cloudera.api.swagger.client.ApiException)8 ApiClient (com.cloudera.api.swagger.client.ApiClient)7 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)7 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)6 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)5 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)5 BigDecimal (java.math.BigDecimal)5 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)4 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)4 ApiHost (com.cloudera.api.swagger.model.ApiHost)3 ApiService (com.cloudera.api.swagger.model.ApiService)3 ClouderaManagerClientInitException (com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException)3 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)3 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)3 HostTemplatesResourceApi (com.cloudera.api.swagger.HostTemplatesResourceApi)2 HostsResourceApi (com.cloudera.api.swagger.HostsResourceApi)2 MgmtServiceResourceApi (com.cloudera.api.swagger.MgmtServiceResourceApi)2 ParcelResourceApi (com.cloudera.api.swagger.ParcelResourceApi)2