use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method changePrimaryGateway.
public String changePrimaryGateway(Stack stack) throws CloudbreakException {
GatewayConfig formerPrimaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
Optional<GatewayConfig> newPrimaryCandidate = gatewayConfigs.stream().filter(gc -> !gc.isPrimary()).findFirst();
if (newPrimaryCandidate.isPresent()) {
GatewayConfig newPrimary = newPrimaryCandidate.get();
Set<Node> allNodes = stackUtil.collectNodes(stack);
try {
hostOrchestrator.changePrimaryGateway(formerPrimaryGatewayConfig, newPrimary, gatewayConfigs, allNodes, clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId()));
return newPrimary.getHostname();
} catch (CloudbreakOrchestratorException ex) {
throw new CloudbreakException(ex);
}
} else {
throw new CloudbreakException("Primary gateway change is not possible because there is no available node for the action");
}
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method getRangerFqdn.
private List<String> getRangerFqdn(Cluster cluster, String primaryGatewayFqdn, List<String> rangerLocations) {
if (rangerLocations.size() > 1) {
// SDX HA has multiple ranger instances in different groups, in Knox we only want to expose the ones on the gateway.
InstanceGroup gatewayInstanceGroup = instanceGroupService.getPrimaryGatewayInstanceGroupByStackId(cluster.getStack().getId());
String gatewayGroupName = gatewayInstanceGroup.getGroupName();
List<String> hosts = rangerLocations.stream().filter(s -> s.contains(gatewayGroupName)).collect(Collectors.toList());
return hosts;
}
return rangerLocations.contains(primaryGatewayFqdn) ? asList(primaryGatewayFqdn) : asList(rangerLocations.iterator().next());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class ClusterProxyRegistrationHandler method registerCluster.
private Selectable registerCluster(ClusterProxyRegistrationRequest request) {
Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
try {
if (!clusterProxyEnablementService.isClusterProxyApplicable(request.getCloudPlatform())) {
LOGGER.info("Cluster Proxy integration is DISABLED, skipping registering with Cluster Proxy service. Cluster CRN: {}", stack.getResourceCrn());
return new ClusterProxyRegistrationSuccess(request.getResourceId());
}
ConfigRegistrationResponse registerResponse = clusterProxyService.registerCluster(stack);
Cluster cluster = stack.getCluster();
if (cluster.hasGateway()) {
LOGGER.debug("Updating Gateway for cluster {} in environment {} with public key certificate retrieved from Cluster Proxy", cluster.getId(), stack.getEnvironmentCrn());
Gateway gateway = cluster.getGateway();
gateway.setTokenCert(registerResponse.getX509Unwrapped());
gatewayService.save(gateway);
}
return new ClusterProxyRegistrationSuccess(request.getResourceId());
} catch (Exception e) {
LOGGER.error("Error occurred when registering cluster {} in environment {} to cluster proxy", stack.getCluster().getId(), stack.getEnvironmentCrn(), e);
return new ClusterProxyRegistrationFailed(request.getResourceId(), e);
}
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class ServiceEndpointCollector method getImpalaCoordinatorUrlWithHostFromGatewayTopology.
private String getImpalaCoordinatorUrlWithHostFromGatewayTopology(String managerIp, GatewayTopology gt, String impalaPrivateIp, boolean autoTlsEnabled) {
Gateway gateway = gt.getGateway();
ExposedService impalaDebugUi = exposedServiceCollector.getImpalaDebugUIService();
Integer port = autoTlsEnabled ? impalaDebugUi.getTlsPort() : impalaDebugUi.getPort();
if (gatewayListeningOnHttpsPort(gateway)) {
return String.format("https://%s/%s/%s%s?scheme=%s&host=%s&port=%s", managerIp, gateway.getPath(), gt.getTopologyName(), impalaDebugUi.getKnoxUrl(), getHttpProtocol(autoTlsEnabled), impalaPrivateIp, port);
} else {
return String.format("https://%s:%s/%s/%s%s?scheme=%s&host=%s&port=%s", managerIp, gateway.getGatewayPort(), gateway.getPath(), gt.getTopologyName(), impalaDebugUi.getKnoxUrl(), getHttpProtocol(autoTlsEnabled), impalaPrivateIp, port);
}
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class GatewayConvertUtilTest method testGatewayPathConversionWhenNoPathInGatewayJson.
@Test
public void testGatewayPathConversionWhenNoPathInGatewayJson() {
Gateway gateway = new Gateway();
GatewayV4Request gatewayJson = new GatewayV4Request();
underTest.setGatewayPathAndSsoProvider(gatewayJson, gateway);
assertEquals('/' + gateway.getPath() + "/sso/api/v1/websso", gateway.getSsoProvider());
}
Aggregations