use of com.sequenceiq.cloudbreak.api.service.ExposedService in project cloudbreak by hortonworks.
the class ServiceEndpointCollector method getHdfsUIUrlWithHostParameterFromGatewayTopology.
private String getHdfsUIUrlWithHostParameterFromGatewayTopology(String managerIp, GatewayTopology gt, String nameNodePrivateIp, boolean autoTlsEnabled) {
Gateway gateway = gt.getGateway();
ExposedService namenode = exposedServiceCollector.getNameNodeService();
Integer port = autoTlsEnabled ? namenode.getTlsPort() : namenode.getPort();
if (gatewayListeningOnHttpsPort(gateway)) {
return String.format("https://%s/%s/%s%s?host=%s://%s:%s", managerIp, gateway.getPath(), gt.getTopologyName(), namenode.getKnoxUrl(), getHttpProtocol(autoTlsEnabled), nameNodePrivateIp, port);
} else {
return String.format("https://%s:%s/%s/%s%s?host=%s://%s:%s", managerIp, gateway.getGatewayPort(), gateway.getPath(), gt.getTopologyName(), namenode.getKnoxUrl(), getHttpProtocol(autoTlsEnabled), nameNodePrivateIp, port);
}
}
use of com.sequenceiq.cloudbreak.api.service.ExposedService in project cloudbreak by hortonworks.
the class ServiceEndpointCollector method getKuduUrlWithHostFromGatewayTopology.
private String getKuduUrlWithHostFromGatewayTopology(String managerIp, GatewayTopology gt, String kuduPrivateIp, boolean autoTlsEnabled) {
Gateway gateway = gt.getGateway();
ExposedService kudu = exposedServiceCollector.getKuduService();
Integer port = autoTlsEnabled ? kudu.getTlsPort() : kudu.getPort();
if (gatewayListeningOnHttpsPort(gateway)) {
return String.format("https://%s/%s/%s%s?scheme=%s&host=%s&port=%s", managerIp, gateway.getPath(), gt.getTopologyName(), kudu.getKnoxUrl(), getHttpProtocol(autoTlsEnabled), kuduPrivateIp, port);
} else {
return String.format("https://%s:%s/%s/%s%s?scheme=%s&host=%s&port=%s", managerIp, gateway.getGatewayPort(), gateway.getPath(), gt.getTopologyName(), kudu.getKnoxUrl(), getHttpProtocol(autoTlsEnabled), kuduPrivateIp, port);
}
}
use of com.sequenceiq.cloudbreak.api.service.ExposedService in project cloudbreak by hortonworks.
the class ServiceEndpointCollector method prepareClusterExposedServices.
public Map<String, Collection<ClusterExposedServiceV4Response>> prepareClusterExposedServices(Cluster cluster, String managerIp) {
String blueprintText = getBlueprintString(cluster);
Map<String, Collection<ClusterExposedServiceV4Response>> clusterExposedServiceMap = new HashMap<>();
if (!Strings.isNullOrEmpty(blueprintText)) {
BlueprintTextProcessor processor = cmTemplateProcessorFactory.get(blueprintText);
Collection<ExposedService> knownExposedServices = getExposedServices(blueprintText, entitlementService.getEntitlements(cluster.getWorkspace().getTenant().getName()));
Gateway gateway = cluster.getGateway();
Optional<String> version = Optional.ofNullable(cluster.getBlueprint()).map(Blueprint::getStackVersion);
Map<String, List<String>> privateIps = componentLocatorService.getComponentLocation(cluster.getId(), processor, knownExposedServices.stream().map(ExposedService::getServiceName).collect(Collectors.toSet()));
LOGGER.debug("The private IPs in the cluster {}", privateIps);
if (privateIps.containsKey(exposedServiceCollector.getImpalaService().getServiceName())) {
setImpalaDebugUIToCoordinator(cluster, privateIps);
}
if (gateway != null) {
for (GatewayTopology gatewayTopology : gateway.getTopologies()) {
generateGatewayTopology(cluster, managerIp, clusterExposedServiceMap, knownExposedServices, gateway, privateIps, gatewayTopology, version);
}
}
}
return clusterExposedServiceMap;
}
use of com.sequenceiq.cloudbreak.api.service.ExposedService in project cloudbreak by hortonworks.
the class ServiceEndpointCollector method getManagerServerUrl.
public String getManagerServerUrl(Cluster cluster, String managerIp) {
if (managerIp != null) {
String orchestrator = cluster.getStack().getOrchestrator().getType();
if (YARN.equals(orchestrator)) {
return String.format("http://%s:8080", managerIp);
} else {
Gateway gateway = cluster.getGateway();
if (gateway != null) {
Optional<String> version = Optional.ofNullable(cluster.getBlueprint()).map(Blueprint::getStackVersion);
ExposedService exposedService = exposedServiceCollector.getClouderaManagerUIService();
Optional<GatewayTopology> gatewayTopology = getGatewayTopologyForService(gateway, exposedService, version);
Optional<String> managerUrl = gatewayTopology.map(t -> getExposedServiceUrl(managerIp, gateway, t.getTopologyName(), exposedService, false));
// when knox gateway is enabled, but cm is not exposed, use the default url
return managerUrl.orElse(String.format("https://%s/", managerIp));
}
return String.format("https://%s/clouderamanager/", managerIp);
}
}
return null;
}
use of com.sequenceiq.cloudbreak.api.service.ExposedService in project cloudbreak by hortonworks.
the class ServiceEndpointCollector method getExposedServices.
/**
* Get all exposed services for blueprint, there are filtered by visibility
*
* @param blueprintText given blueprintText
* @return all visible exposed services for the given blueprint
*/
private Collection<ExposedService> getExposedServices(String blueprintText, List<String> entitlements) {
CmTemplateProcessor processor = cmTemplateProcessorFactory.get(blueprintText);
List<String> components = processor.getAllComponents().stream().map(ServiceComponent::getComponent).collect(Collectors.toList());
return exposedServiceCollector.knoxServicesForComponents(processor.getVersion(), components).stream().filter(ExposedService::isVisible).filter(e -> serviceEndpointCollectorEntitlementComparator.entitlementSupported(entitlements, e.getEntitlement())).collect(Collectors.toList());
}
Aggregations