Search in sources :

Example 16 with ExposedService

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);
    }
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService)

Example 17 with ExposedService

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);
    }
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService)

Example 18 with ExposedService

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;
}
Also used : HashMap(java.util.HashMap) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List)

Example 19 with ExposedService

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;
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)

Example 20 with ExposedService

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());
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) ClusterExposedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) CmTemplateProcessorFactory(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessorFactory) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) Strings(com.google.common.base.Strings) Service(org.springframework.stereotype.Service) Map(java.util.Map) ExposedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ExposedServiceV4Response) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) ExposedServiceCollector(com.sequenceiq.cloudbreak.api.service.ExposedServiceCollector) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) ClusterExposedServiceView(com.sequenceiq.cloudbreak.template.views.ClusterExposedServiceView) Logger(org.slf4j.Logger) YARN(com.sequenceiq.cloudbreak.common.type.OrchestratorConstants.YARN) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) GatewayTopologyV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) ServiceComponent(com.sequenceiq.cloudbreak.template.model.ServiceComponent) List(java.util.List) GatewayType(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.GatewayType) Stream(java.util.stream.Stream) SecurityConfig(com.sequenceiq.cloudbreak.domain.SecurityConfig) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Optional(java.util.Optional) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) BlueprintService(com.sequenceiq.cloudbreak.service.blueprint.BlueprintService) SSOType(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.SSOType) ComponentLocatorService(com.sequenceiq.cloudbreak.service.blueprint.ComponentLocatorService) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)

Aggregations

ExposedService (com.sequenceiq.cloudbreak.api.service.ExposedService)24 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)10 ArrayList (java.util.ArrayList)8 GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)6 List (java.util.List)6 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)5 ClusterExposedServiceV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response)4 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)4 ExposedServices (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices)4 IOException (java.io.IOException)4 GatewayType (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.GatewayType)3 GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)3 ExposedServiceV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ExposedServiceV4Response)3 ExposedServiceCollector (com.sequenceiq.cloudbreak.api.service.ExposedServiceCollector)3 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)3 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)3 CmTemplateProcessorFactory (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessorFactory)3 Json (com.sequenceiq.cloudbreak.common.json.Json)3 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 BlueprintService (com.sequenceiq.cloudbreak.service.blueprint.BlueprintService)3