Search in sources :

Example 11 with GatewayTopology

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

the class OpdbServiceEndpointCollectorTest method createClusterWithComponents.

private Cluster createClusterWithComponents(GatewayType gatewayType) {
    Cluster cluster = clusterWithOrchestrator("ANY");
    GatewayTopology topology1 = gatewayTopology("proxy");
    topology1.setGateway(cluster.getGateway());
    cluster.getGateway().setTopologies(Collections.singleton(topology1));
    cluster.getGateway().setGatewayType(gatewayType);
    Workspace workspace = new Workspace();
    Tenant tenant = new Tenant();
    tenant.setName("tenant");
    workspace.setTenant(tenant);
    cluster.setWorkspace(workspace);
    return cluster;
}
Also used : Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 12 with GatewayTopology

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

the class ServiceEndpointCollectorTest method createClusterWithComponents.

private Cluster createClusterWithComponents(ExposedService[] topology1Services, ExposedService[] topology2Services, GatewayType gatewayType) {
    Cluster cluster = clusterkWithOrchestrator("ANY");
    GatewayTopology topology1 = gatewayTopology("topology1", topology1Services);
    topology1.setGateway(cluster.getGateway());
    GatewayTopology topology2 = gatewayTopology("topology2", topology2Services);
    topology2.setGateway(cluster.getGateway());
    cluster.getGateway().setTopologies(Sets.newHashSet(topology1, topology2));
    cluster.getGateway().setGatewayType(gatewayType);
    Workspace workspace = new Workspace();
    Tenant tenant = new Tenant();
    tenant.setName("tenant");
    workspace.setTenant(tenant);
    cluster.setWorkspace(workspace);
    return cluster;
}
Also used : Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 13 with GatewayTopology

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

the class ServiceEndpointCollectorTest method gatewayTopology.

private GatewayTopology gatewayTopology(String name, ExposedService... services) {
    GatewayTopologyV4Request gatewayTopologyJson = new GatewayTopologyV4Request();
    gatewayTopologyJson.setTopologyName(name);
    gatewayTopologyJson.setExposedServices(Arrays.stream(services).map(ExposedService::getKnoxService).collect(Collectors.toList()));
    ExposedServices exposedServices = exposedServicesConverter.convert(gatewayTopologyJson);
    GatewayTopology gatewayTopology = new GatewayTopology();
    gatewayTopology.setTopologyName(name);
    gatewayTopology.setExposedServices(new Json(exposedServices));
    return gatewayTopology;
}
Also used : ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) GatewayTopologyV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request) ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Json(com.sequenceiq.cloudbreak.common.json.Json)

Example 14 with GatewayTopology

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

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

GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)23 Test (org.junit.Test)11 ExposedServices (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices)9 Json (com.sequenceiq.cloudbreak.common.json.Json)7 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)7 GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)5 GatewayTopologyV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response)3 ExposedService (com.sequenceiq.cloudbreak.api.service.ExposedService)3 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)3 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)2 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)2 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)2 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)2 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)2 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)2 IdBroker (com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)2 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)2 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)2 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)2 Tenant (com.sequenceiq.cloudbreak.workspace.model.Tenant)2