use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupService method prepareClouderaManagerCluster.
public List<ClusterComponent> prepareClouderaManagerCluster(ClusterV4Request request, Cluster cluster, Optional<Component> stackClouderaManagerRepoConfig, List<Component> stackCdhRepoConfig, Optional<Component> stackImageComponent) throws IOException, CloudbreakImageCatalogException {
List<ClusterComponent> components = new ArrayList<>();
long start = System.currentTimeMillis();
String blueprintCdhVersion = blueprintUtils.getCDHStackVersion(JsonUtil.readTree(cluster.getBlueprint().getBlueprintText()));
LOGGER.debug("blueprintUtils.getCDHStackVersion took {} ms", System.currentTimeMillis() - start);
Optional<ClouderaManagerRepositoryV4Request> cmRepoRequest = measure(() -> Optional.ofNullable(request.getCm()).map(ClouderaManagerV4Request::getRepository), LOGGER, "ClouderaManagerV4Request::getRepository {} ms");
start = System.currentTimeMillis();
String osType = getOsType(stackImageComponent);
String imageCatalogName = getImageCatalogName(stackImageComponent);
LOGGER.debug("getImageCatalogName took {} ms", System.currentTimeMillis() - start);
start = System.currentTimeMillis();
ClusterComponent cmRepoConfig = getCmRepoConfiguration(cluster, stackClouderaManagerRepoConfig, components, blueprintCdhVersion, cmRepoRequest, osType);
LOGGER.debug("getCmRepoConfiguration took {} ms", System.currentTimeMillis() - start);
start = System.currentTimeMillis();
checkCmStackRepositories(cmRepoConfig, stackImageComponent.get());
LOGGER.debug("checkCmStackRepositories took {} ms", System.currentTimeMillis() - start);
start = System.currentTimeMillis();
addProductComponentsToCluster(request, cluster, stackCdhRepoConfig, components, blueprintCdhVersion, osType, imageCatalogName);
LOGGER.debug("addProductComponentsToCluster took {} ms", System.currentTimeMillis() - start);
return components;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request in project cloudbreak by hortonworks.
the class StackV4RequestToTemplatePreparationObjectConverterTest method testConvertWhenCmAndProductDetailsPresent.
@Test
public void testConvertWhenCmAndProductDetailsPresent() {
final String cmBaseUrl = "http://cloudera-build-us-west-1.vpc.cloudera.com/s3/build/1677091/cm7/7.0.2/redhat7/yum/";
final String cmGpgUrl = "http://cloudera-build-us-west-1.vpc.cloudera.com/s3/build/1677091/cm7/7.0.2/redhat7/yum/RPM-GPG-KEY-cloudera";
final String cmVersion = "7.0.2";
ClouderaManagerRepositoryV4Request cmRepo = new ClouderaManagerRepositoryV4Request().withBaseUrl(cmBaseUrl).withGpgKeyUrl(cmGpgUrl).withVersion(cmVersion);
final String smmName = "STREAMS_MESSAGING_MANAGER";
final String smmVersion = "2.1.0.3.0.0.0-97";
final String smmParcel = "http://s3.amazonaws.com/dev.hortonworks.com/CSP/centos7/3.x/BUILDS/3.0.0.0-97/tars/parcel/";
final String smmCsd = "http://s3.amazonaws.com/dev.hortonworks.com/CSP/centos7/3.x/BUILDS/3.0.0.0-97/tars/parcel/STREAMS_MESSAGING_MANAGER-2.1.0.jar";
ClouderaManagerProductV4Request smm = new ClouderaManagerProductV4Request().withName(smmName).withVersion(smmVersion).withParcel(smmParcel).withCsd(List.of(smmCsd));
ClouderaManagerV4Request cm = new ClouderaManagerV4Request().withEnableAutoTls(true).withRepository(cmRepo).withProducts(List.of(smm));
when(cluster.getCm()).thenReturn(cm);
TemplatePreparationObject result = underTest.convert(source);
ProductDetailsView products = result.getProductDetailsView();
assertNotNull(products);
assertEquals(cmBaseUrl, products.getCm().getBaseUrl());
assertEquals(cmVersion, products.getCm().getVersion());
assertEquals(cmGpgUrl, products.getCm().getGpgKeyUrl());
assertEquals(1, products.getProducts().size());
ClouderaManagerProduct smmResult = products.getProducts().get(0);
assertEquals(smmName, smmResult.getName());
assertEquals(smmVersion, smmResult.getVersion());
assertEquals(smmParcel, smmResult.getParcel());
assertEquals(List.of(smmCsd), smmResult.getCsd());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request in project cloudbreak by hortonworks.
the class ClusterV4RequestToClusterConverterTest method testConvertClouderaManagerRequestWithNullProductList.
@Test
public void testConvertClouderaManagerRequestWithNullProductList() {
ClusterV4Request request = new ClusterV4Request();
request.setBlueprintName(BLUEPRINT);
blueprint.setStackType(StackType.CDH.name());
when(blueprintService.getByNameForWorkspaceAndLoadDefaultsIfNecessary(eq(BLUEPRINT), any())).thenReturn(blueprint);
ClouderaManagerV4Request cm = new ClouderaManagerV4Request();
ClouderaManagerRepositoryV4Request repository = new ClouderaManagerRepositoryV4Request();
repository.setBaseUrl("base.url");
repository.setVersion("1.0");
repository.setGpgKeyUrl("gpg.key.url");
cm.setRepository(repository);
request.setCm(cm);
Cluster cluster = underTest.convert(request);
assertFalse(cluster.getComponents().isEmpty());
assertEquals(1, cluster.getComponents().size());
ClusterComponent component = cluster.getComponents().iterator().next();
assertEquals(ComponentType.CM_REPO_DETAILS, component.getComponentType());
Json expectedRepoJson = new Json(repository);
assertEquals(expectedRepoJson.getMap().size() + 1, component.getAttributes().getMap().size());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request in project cloudbreak by hortonworks.
the class DistroXClusterToClusterConverterTest method testConvertWithEnvCmConversionShouldHappenIfInputCmIsNotNull.
@Test
void testConvertWithEnvCmConversionShouldHappenIfInputCmIsNotNull() {
ClouderaManagerV4Request cmConversionResult = new ClouderaManagerV4Request();
when(cmConverter.convert(distroXV1RequestInput.getCluster().getCm())).thenReturn(cmConversionResult);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
ClusterV4Request result = testConvertDistroXV1RequestWithEnvironment();
assertNotNull(result);
assertEquals(cmConversionResult, result.getCm());
verify(cmConverter, times(1)).convert(any(ClouderaManagerV1Request.class));
verify(cmConverter, times(1)).convert(distroXV1RequestInput.getCluster().getCm());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request in project cloudbreak by hortonworks.
the class ClusterV4RequestToClusterConverter method extractClusterManagerAndHdpRepoConfig.
private void extractClusterManagerAndHdpRepoConfig(Cluster cluster, ClusterV4Request clusterRequest) {
Set<ClusterComponent> components = new HashSet<>();
ClouderaManagerV4Request clouderaManagerRequest = clusterRequest.getCm();
if (Objects.nonNull(clouderaManagerRequest) && cluster.getBlueprint() != null && !StackType.CDH.name().equals(cluster.getBlueprint().getStackType())) {
throw new BadRequestException("Cannot process the provided Ambari blueprint with Cloudera Manager");
}
Optional.ofNullable(clouderaManagerRequest).map(ClouderaManagerV4Request::getRepository).map(ClouderaManagerRepositoryV4RequestToClouderaManagerRepoConverter::convert).map(toJsonWrapException()).map(cmRepoJson -> new ClusterComponent(ComponentType.CM_REPO_DETAILS, cmRepoJson, cluster)).ifPresent(components::add);
Optional.ofNullable(clouderaManagerRequest).map(ClouderaManagerV4Request::getProducts).orElseGet(List::of).stream().map(this::convertCMProductRequestToCMProduct).map(product -> {
Json json = toJsonWrapException().apply(product);
return new ClusterComponent(ComponentType.CDH_PRODUCT_DETAILS, product.getName(), json, cluster);
}).forEach(components::add);
cluster.setComponents(components);
}
Aggregations