Search in sources :

Example 41 with Gateway

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.

the class ServiceEndpointCollector method getHBaseJarsUrlFromGatewayTopology.

private String getHBaseJarsUrlFromGatewayTopology(String managerIp, GatewayTopology gt, String hbaseMasterPrivateIp) {
    Gateway gateway = gt.getGateway();
    ExposedService hbaseJars = exposedServiceCollector.getHBaseJarsService();
    if (gatewayListeningOnHttpsPort(gateway)) {
        return String.format("https://%s/%s/%s%s%s", managerIp, gateway.getPath(), gt.getTopologyName(), API_TOPOLOGY_POSTFIX, hbaseJars.getKnoxUrl());
    } else {
        return String.format("https://%s:%s/%s/%s%s%s", managerIp, gateway.getGatewayPort(), gateway.getPath(), gt.getTopologyName(), API_TOPOLOGY_POSTFIX, hbaseJars.getKnoxUrl());
    }
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService)

Example 42 with Gateway

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway 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 43 with Gateway

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway 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 44 with Gateway

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway 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 45 with Gateway

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway 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)

Aggregations

Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)69 Test (org.junit.Test)30 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)20 HashSet (java.util.HashSet)17 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)15 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)15 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)15 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)13 ExposedService (com.sequenceiq.cloudbreak.api.service.ExposedService)12 GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)12 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)11 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)11 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)10 IOException (java.io.IOException)10 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)8 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)8 ArrayList (java.util.ArrayList)8 Json (com.sequenceiq.cloudbreak.common.json.Json)7 IdBroker (com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)7 ExposedServices (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices)7