Search in sources :

Example 1 with ApiClusterTemplate

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

the class ClouderaManagerSetupService method installCluster.

@Override
public void installCluster(String template) {
    Cluster cluster = stack.getCluster();
    try {
        Optional<ApiCluster> cmCluster = getCmClusterByName(cluster.getName());
        boolean prewarmed = isPrewarmed(cluster.getId());
        Optional<ClusterCommand> importCommand = clusterCommandRepository.findTopByClusterIdAndClusterCommandType(cluster.getId(), ClusterCommandType.IMPORT_CLUSTER);
        if (cmCluster.isEmpty() || importCommand.isEmpty()) {
            ApiClusterTemplate apiClusterTemplate = JsonUtil.readValue(template, ApiClusterTemplate.class);
            cluster.setExtendedBlueprintText(getExtendedBlueprintText(apiClusterTemplate));
            ClouderaManagerResourceApi clouderaManagerResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(apiClient);
            LOGGER.info("Generated Cloudera cluster template: {}", AnonymizerUtil.anonymize(template));
            // addRepositories - if true the parcels repositories in the cluster template
            // will be added.
            ApiCommand apiCommand = clouderaManagerResourceApi.importClusterTemplate(calculateAddRepositories(apiClusterTemplate, prewarmed), apiClusterTemplate);
            ClusterCommand clusterCommand = new ClusterCommand();
            clusterCommand.setClusterId(cluster.getId());
            clusterCommand.setCommandId(apiCommand.getId());
            clusterCommand.setClusterCommandType(ClusterCommandType.IMPORT_CLUSTER);
            importCommand = Optional.of(clusterCommandRepository.save(clusterCommand));
            LOGGER.debug("Cloudera cluster template has been submitted, cluster install is in progress");
        }
        importCommand.ifPresent(cmd -> clouderaManagerPollingServiceProvider.startPollingCmTemplateInstallation(stack, apiClient, cmd.getCommandId()));
    } catch (ApiException e) {
        String msg = "Installation of CDP with Cloudera Manager has failed: " + extractMessage(e);
        throw new ClouderaManagerOperationFailedException(msg, e);
    } catch (CloudStorageConfigurationFailedException e) {
        LOGGER.info("Error while configuring cloud storage. Message: {}", e.getMessage(), e);
        throw new ClouderaManagerOperationFailedException(mapStorageError(e, stack.getResourceCrn(), stack.cloudPlatform(), cluster), e);
    } catch (Exception e) {
        throw mapException(e);
    }
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ApiCluster(com.cloudera.api.swagger.model.ApiCluster) ApiCluster(com.cloudera.api.swagger.model.ApiCluster) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) ApiException(com.cloudera.api.swagger.client.ApiException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) CloudStorageConfigurationFailedException(com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) ClusterCommand(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterCommand) CloudStorageConfigurationFailedException(com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException) ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate) ApiException(com.cloudera.api.swagger.client.ApiException)

Example 2 with ApiClusterTemplate

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

the class ClouderaManagerSetupService method prepareTemplate.

@Override
public String prepareTemplate(Map<HostGroup, List<InstanceMetaData>> instanceMetaDataByHostGroup, TemplatePreparationObject templatePreparationObject, String sdxContext, String sdxCrn, KerberosConfig kerberosConfig) {
    Long clusterId = stack.getCluster().getId();
    try {
        Set<InstanceMetaData> instances = instanceMetaDataByHostGroup.values().stream().flatMap(Collection::stream).collect(Collectors.toSet());
        waitForHosts(instances);
        String sdxContextName = Optional.ofNullable(sdxContext).map(this::setupRemoteDataContext).orElse(null);
        ClouderaManagerRepo clouderaManagerRepoDetails = clusterComponentProvider.getClouderaManagerRepoDetails(clusterId);
        ApiClusterTemplate apiClusterTemplate = getCmTemplate(templatePreparationObject, sdxContextName, instanceMetaDataByHostGroup, clouderaManagerRepoDetails, clusterId);
        return getExtendedBlueprintText(apiClusterTemplate);
    } catch (CancellationException cancellationException) {
        throw cancellationException;
    } catch (Exception e) {
        throw mapException(e);
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) ApiException(com.cloudera.api.swagger.client.ApiException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) CloudStorageConfigurationFailedException(com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate)

Example 3 with ApiClusterTemplate

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

the class ClouderaManagerShowBlueprintTest method checkValidClouderaManagerTemplate.

private StackTestDto checkValidClouderaManagerTemplate(TestContext testContext, StackTestDto stackTestDto, CloudbreakClient cloudbreakClient) {
    String extendedBlueprintText = stackTestDto.getResponse().getCluster().getExtendedBlueprintText();
    ApiClusterTemplate cmTemplate = parseCmTemplate(extendedBlueprintText);
    checkHostNumberGreaterThanZero(cmTemplate);
    return stackTestDto;
}
Also used : ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate)

Example 4 with ApiClusterTemplate

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

the class CentralCmTemplateUpdaterTest method configsAreInjected.

@Test
public void configsAreInjected() {
    List<ApiClusterTemplateConfig> serviceConfigs = List.of(config("service_config_name", "service_config_value"));
    List<ApiClusterTemplateConfig> roleConfigs = List.of(config("role_config_name", "role_config_value"));
    ReflectionTestUtils.setField(cmTemplateConfigInjectorProcessor, "injectors", List.of(new CmTemplateConfigInjector() {

        @Override
        public List<ApiClusterTemplateConfig> getServiceConfigs(ApiClusterTemplateService service, TemplatePreparationObject source) {
            return serviceConfigs;
        }

        @Override
        public List<ApiClusterTemplateConfig> getRoleConfigs(ApiClusterTemplateRoleConfigGroup roleConfigGroup, ApiClusterTemplateService service, TemplatePreparationObject source) {
            return roleConfigs;
        }
    }));
    when(blueprintView.getBlueprintText()).thenReturn(getBlueprintText("input/namenode-ha.bp"));
    ApiClusterTemplate generated = testGetCmTemplate();
    assertMatchesBlueprintAtPath("output/namenode-ha-injected.bp", generated);
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate) Test(org.junit.Test)

Example 5 with ApiClusterTemplate

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

the class CentralCmTemplateUpdaterTest method getCmTemplateNoMetastoreWithTemplateParams.

@Test
public void getCmTemplateNoMetastoreWithTemplateParams() {
    when(blueprintView.getBlueprintText()).thenReturn(getBlueprintText("input/clouderamanager-fixparam.bp"));
    ApiClusterTemplate generated = testGetCmTemplate();
    assertMatchesBlueprintAtPath("output/clouderamanager-fixparam.bp", generated);
}
Also used : ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate) Test(org.junit.Test)

Aggregations

ApiClusterTemplate (com.cloudera.api.swagger.model.ApiClusterTemplate)15 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)3 ApiException (com.cloudera.api.swagger.client.ApiException)2 ApiClusterTemplateRoleConfigGroup (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)2 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)2 ClusterClientInitException (com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException)2 ClouderaManagerClientInitException (com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException)2 CloudStorageConfigurationFailedException (com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException)2 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)2 StorageLocation (com.sequenceiq.cloudbreak.domain.StorageLocation)2 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)2 StorageLocationView (com.sequenceiq.cloudbreak.template.filesystem.StorageLocationView)2 S3FileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.s3.S3FileSystemConfigurationsView)2 S3FileSystem (com.sequenceiq.common.api.filesystem.S3FileSystem)2 IOException (java.io.IOException)2 List (java.util.List)2 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)1