use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response in project cloudbreak by hortonworks.
the class ClusterToClusterV4ResponseConverter method convert.
public ClusterV4Response convert(Cluster source) {
ClusterV4Response clusterResponse = new ClusterV4Response();
clusterResponse.setId(source.getId());
clusterResponse.setName(source.getName());
Stack stack = source.getStack();
clusterResponse.setStatus(stack.getStatus());
clusterResponse.setStatusReason(stack.getStatusReason());
setUptime(source, clusterResponse);
clusterResponse.setDescription(source.getDescription() == null ? "" : source.getDescription());
String managerAddress = stackUtil.extractClusterManagerAddress(stack);
Map<String, Collection<ClusterExposedServiceV4Response>> clusterExposedServicesForTopologies = serviceEndpointCollector.prepareClusterExposedServices(source, managerAddress);
clusterResponse.setExposedServices(clusterExposedServicesForTopologies);
convertCustomQueue(source, clusterResponse);
convertNullableProperties(source, clusterResponse);
convertContainerConfig(source, clusterResponse);
clusterResponse.setCreationFinished(source.getCreationFinished());
decorateResponseWithProxyConfig(source, clusterResponse);
clusterResponse.setCloudStorage(getCloudStorage(source));
clusterResponse.setCm(ClusterToClouderaManagerV4ResponseConverter.convert(source));
clusterResponse.setDatabases(source.getRdsConfigs().stream().filter(rds -> ResourceStatus.USER_MANAGED.equals(rds.getStatus())).map(rds -> rdsConfigToDatabaseV4ResponseConverter.convert(rds)).collect(Collectors.toList()));
clusterResponse.setWorkspace(workspaceToWorkspaceResourceV4ResponseConverter.convert(source.getWorkspace()));
clusterResponse.setBlueprint(getIfNotNull(source.getBlueprint(), blueprintToBlueprintV4ResponseConverter::convert));
clusterResponse.setExtendedBlueprintText(getExtendedBlueprintText(source));
convertDpSecrets(source, clusterResponse);
clusterResponse.setServerIp(stackUtil.extractClusterManagerIp(stack));
clusterResponse.setServerFqdn(source.getFqdn());
clusterResponse.setServerUrl(serviceEndpointCollector.getManagerServerUrl(source, managerAddress));
clusterResponse.setCustomConfigurationsName(getIfNotNull(source.getCustomConfigurations(), configurations -> configurations.getName()));
clusterResponse.setCustomConfigurationsCrn(getIfNotNull(source.getCustomConfigurations(), configurations -> configurations.getCrn()));
clusterResponse.setDatabaseServerCrn(source.getDatabaseServerCrn());
clusterResponse.setRangerRazEnabled(source.isRangerRazEnabled());
clusterResponse.setCertExpirationState(source.getCertExpirationState());
return clusterResponse;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response in project cloudbreak by hortonworks.
the class ServiceEndpointCollector method generateGatewayTopology.
private void generateGatewayTopology(Cluster cluster, String managerIp, Map<String, Collection<ClusterExposedServiceV4Response>> clusterExposedServiceMap, Collection<ExposedService> knownExposedServices, Gateway gateway, Map<String, List<String>> privateIps, GatewayTopology gatewayTopology, Optional<String> version) {
LOGGER.debug("Generating the topology for '{}' topologies", gatewayTopology.getTopologyName());
Set<String> exposedServicesInTopology = gateway.getTopologies().stream().flatMap(e -> getExposedServiceStream(e, version)).filter(Objects::nonNull).collect(Collectors.toSet());
List<ClusterExposedServiceV4Response> uiServices = new ArrayList<>();
List<ClusterExposedServiceV4Response> apiServices = new ArrayList<>();
boolean autoTlsEnabled = cluster.getAutoTlsEnabled();
LOGGER.debug("AutoTls enabled '{}' for the cluster", autoTlsEnabled);
SecurityConfig securityConfig = cluster.getStack().getSecurityConfig();
String managerServerUrl = getManagerServerUrl(cluster, managerIp);
for (ExposedService exposedService : knownExposedServices) {
if (exposedService.isCmProxied()) {
List<ClusterExposedServiceV4Response> uiServiceOnPrivateIps = createCmProxiedServiceEntries(exposedService, gateway, gatewayTopology, managerServerUrl, cluster.getName());
uiServices.addAll(uiServiceOnPrivateIps);
} else {
if (!exposedService.isApiOnly()) {
List<ClusterExposedServiceV4Response> uiServiceOnPrivateIps = createServiceEntries(exposedService, gateway, gatewayTopology, managerIp, privateIps, exposedServicesInTopology, false, autoTlsEnabled, securityConfig, version);
uiServices.addAll(uiServiceOnPrivateIps);
}
if (exposedService.isApiIncluded()) {
List<ClusterExposedServiceV4Response> apiServiceOnPrivateIps = createServiceEntries(exposedService, gateway, gatewayTopology, managerIp, privateIps, exposedServicesInTopology, true, autoTlsEnabled, securityConfig, version);
apiServices.addAll(apiServiceOnPrivateIps);
}
}
}
clusterExposedServiceMap.put(gatewayTopology.getTopologyName(), uiServices);
clusterExposedServiceMap.put(gatewayTopology.getTopologyName() + API_TOPOLOGY_POSTFIX, apiServices);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response in project cloudbreak by hortonworks.
the class ServiceEndpointCollector method createExposedServiceResponse.
private ClusterExposedServiceV4Response createExposedServiceResponse(ExposedService exposedService, Gateway gateway, Set<String> exposedServicesInTopology, boolean api, String url) {
ClusterExposedServiceV4Response service = new ClusterExposedServiceV4Response();
service.setMode(api ? SSOType.PAM : getSSOType(exposedService, gateway));
service.setDisplayName(exposedService.getDisplayName());
service.setKnoxService(exposedService.getKnoxService());
service.setServiceName(exposedService.getServiceName());
service.setOpen(isExposed(exposedService, exposedServicesInTopology));
if (isNotEmpty(url)) {
service.setServiceUrl(url);
}
return service;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response in project cloudbreak by hortonworks.
the class ServiceEndpointCollector method prepareClusterExposedServicesViews.
public Map<String, Collection<ClusterExposedServiceView>> prepareClusterExposedServicesViews(Cluster cluster, String managerIp) {
Map<String, Collection<ClusterExposedServiceView>> result = new HashMap<>();
for (Map.Entry<String, Collection<ClusterExposedServiceV4Response>> entry : prepareClusterExposedServices(cluster, managerIp).entrySet()) {
Set<ClusterExposedServiceView> views = new HashSet<>();
for (ClusterExposedServiceV4Response response : entry.getValue()) {
views.add(new ClusterExposedServiceView(response.getServiceName(), response.getDisplayName(), response.getKnoxService(), response.getServiceUrl()));
}
result.put(entry.getKey(), views);
}
return result;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response in project cloudbreak by hortonworks.
the class ServiceEndpointCollectorTest method testPrepareClusterExposedServicesByGeneratedBlueprint.
@Test
public void testPrepareClusterExposedServicesByGeneratedBlueprint() {
Cluster cluster = createClusterWithComponents(new ExposedService[] { exposedService("ATLAS") }, new ExposedService[] { exposedService("HIVE_SERVER"), exposedService("WEBHDFS") }, GatewayType.INDIVIDUAL);
cluster.getGateway().setGatewayPort(443);
cluster.setExtendedBlueprintText("extended-blueprint");
mockBlueprintTextProcessor();
mockComponentLocator(Lists.newArrayList("10.0.0.1"));
Map<String, Collection<ClusterExposedServiceV4Response>> clusterExposedServicesMap = underTest.prepareClusterExposedServices(cluster, "10.0.0.1");
assertEquals(4L, clusterExposedServicesMap.keySet().size());
Collection<ClusterExposedServiceV4Response> topology2ClusterExposedServiceV4Responses = clusterExposedServicesMap.get("topology2");
Optional<ClusterExposedServiceV4Response> webHDFS = topology2ClusterExposedServiceV4Responses.stream().filter(service -> "WEBHDFS".equals(service.getKnoxService())).findFirst();
if (webHDFS.isPresent()) {
assertEquals("https://10.0.0.1/gateway-path/topology2/webhdfs/v1", webHDFS.get().getServiceUrl());
assertEquals("WEBHDFS", webHDFS.get().getKnoxService());
assertEquals("WebHDFS", webHDFS.get().getDisplayName());
assertEquals("NAMENODE", webHDFS.get().getServiceName());
assertTrue(webHDFS.get().isOpen());
}
Optional<ClusterExposedServiceV4Response> sparkHistoryUI = topology2ClusterExposedServiceV4Responses.stream().filter(service -> "SPARKHISTORYUI".equals(service.getKnoxService())).findFirst();
if (sparkHistoryUI.isPresent()) {
assertEquals("https://10.0.0.1/gateway-path/topology2/sparkhistory/", sparkHistoryUI.get().getServiceUrl());
assertEquals("SPARKHISTORYUI", sparkHistoryUI.get().getKnoxService());
assertEquals("Spark 1.x History Server", sparkHistoryUI.get().getDisplayName());
assertEquals("SPARK_YARN_HISTORY_SERVER", sparkHistoryUI.get().getServiceName());
assertFalse(sparkHistoryUI.get().isOpen());
}
Optional<ClusterExposedServiceV4Response> hiveServer = topology2ClusterExposedServiceV4Responses.stream().filter(service -> "HIVE".equals(service.getKnoxService())).findFirst();
if (hiveServer.isPresent()) {
assertEquals("jdbc:hive2://10.0.0.1/;ssl=true;sslTrustStore=/cert/gateway.jks;trustStorePassword=${GATEWAY_JKS_PASSWORD};" + "transportMode=http;httpPath=gateway-path/topology2/hive", hiveServer.get().getServiceUrl());
assertEquals("HIVE", hiveServer.get().getKnoxService());
assertEquals("Hive Server", hiveServer.get().getDisplayName());
assertEquals("HIVE_SERVER", hiveServer.get().getServiceName());
assertTrue(hiveServer.get().isOpen());
}
}
Aggregations