use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response in project cloudbreak by hortonworks.
the class SdxServiceTest method testUpdateRuntimeVersionFromStackResponse.
@Test
public void testUpdateRuntimeVersionFromStackResponse() {
SdxCluster sdxCluster = getSdxCluster();
StackV4Response stackV4Response = new StackV4Response();
ClusterV4Response clusterV4Response = new ClusterV4Response();
ClouderaManagerV4Response cm = new ClouderaManagerV4Response();
ClouderaManagerProductV4Response cdpResponse = new ClouderaManagerProductV4Response();
cdpResponse.setName("CDH");
cdpResponse.setVersion("7.2.1-1.32.123-123");
cm.setProducts(Collections.singletonList(cdpResponse));
clusterV4Response.setCm(cm);
stackV4Response.setCluster(clusterV4Response);
underTest.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response);
ArgumentCaptor<SdxCluster> sdxClusterArgumentCaptor = ArgumentCaptor.forClass(SdxCluster.class);
verify(sdxClusterRepository, times(1)).save(sdxClusterArgumentCaptor.capture());
assertEquals("7.2.1", sdxClusterArgumentCaptor.getValue().getRuntime());
cdpResponse.setVersion("7.1.0");
underTest.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response);
verify(sdxClusterRepository, times(2)).save(sdxClusterArgumentCaptor.capture());
assertEquals("7.1.0", sdxClusterArgumentCaptor.getValue().getRuntime());
cdpResponse.setVersion("7.0.2-valami");
underTest.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response);
verify(sdxClusterRepository, times(3)).save(sdxClusterArgumentCaptor.capture());
assertEquals("7.0.2", sdxClusterArgumentCaptor.getValue().getRuntime());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response in project cloudbreak by hortonworks.
the class SdxUpgradeServiceTest method getStackV4Response.
private StackV4Response getStackV4Response() {
ClouderaManagerProductV4Response cdp = new ClouderaManagerProductV4Response();
cdp.setName("CDH");
cdp.setVersion("7.2.1-1.cdh7.2.0.p0.3758356");
ClouderaManagerProductV4Response cfm = new ClouderaManagerProductV4Response();
cfm.setName("CFM");
cfm.setVersion("2.0.0.0");
ClouderaManagerProductV4Response spark3 = new ClouderaManagerProductV4Response();
spark3.setName("SPARK3");
spark3.setVersion("3.0.0.2.99.7110.0-18-1.p0.3525631");
ClouderaManagerV4Response cm = new ClouderaManagerV4Response();
cm.setProducts(List.of(cdp, cfm, spark3));
ClusterV4Response clusterV4Response = new ClusterV4Response();
clusterV4Response.setCm(cm);
StackV4Response stackV4Response = new StackV4Response();
stackV4Response.setName("test-sdx-cluster");
stackV4Response.setCluster(clusterV4Response);
return stackV4Response;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response in project cloudbreak by hortonworks.
the class SdxService method getCdpVersion.
private Optional<String> getCdpVersion(StackV4Response stack) {
String stackName = stack.getName();
ClusterV4Response cluster = stack.getCluster();
if (cluster != null) {
ClouderaManagerV4Response cm = cluster.getCm();
if (cm != null) {
LOGGER.info("Repository details are available for cluster: {}: {}", stackName, cm);
List<ClouderaManagerProductV4Response> products = cm.getProducts();
if (products != null && !products.isEmpty()) {
Optional<ClouderaManagerProductV4Response> cdpOpt = products.stream().filter(p -> "CDH".equals(p.getName())).findFirst();
if (cdpOpt.isPresent()) {
return getRuntimeVersionFromCdpVersion(cdpOpt.get().getVersion());
}
}
}
}
return Optional.empty();
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response in project cloudbreak by hortonworks.
the class ClusterToClouderaManagerV4ResponseConverter method convert.
public static ClouderaManagerV4Response convert(Cluster cluster) {
Predicate<ClusterComponent> cmRepoFilter = component -> ComponentType.CM_REPO_DETAILS.equals(component.getComponentType());
Set<ClusterComponent> components = cluster.getComponents();
if (components.stream().noneMatch(cmRepoFilter)) {
return null;
}
return new ClouderaManagerV4Response().withRepository(components.stream().filter(cmRepoFilter).map(ClusterComponent::getAttributes).map(toAttributeClass(ClouderaManagerRepo.class)).map(ClouderaManagerRepoToClouderaManagerRepositoryV4Response::convert).findFirst().orElse(null)).withProducts(components.stream().filter(component -> ComponentType.CDH_PRODUCT_DETAILS.equals(component.getComponentType())).map(ClusterComponent::getAttributes).map(toAttributeClass(ClouderaManagerProduct.class)).map(ClouderaManagerProductToClouderaManagerProductV4Response::convert).collect(Collectors.toList())).withTlsEnabled(cluster.getAutoTlsEnabled());
}
Aggregations