Search in sources :

Example 6 with Cluster

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

the class ClusterCreationSetupService method prepare.

public Cluster prepare(ClusterV4Request request, Stack stack, Blueprint blueprint, User user, String parentEnvironmentCloudPlatform) throws IOException, CloudbreakImageCatalogException, TransactionExecutionException {
    String stackName = stack.getName();
    Cluster clusterStub = stack.getCluster();
    stack.setCluster(null);
    if (request.getCloudStorage() != null) {
        FileSystem fileSystem = cloudStorageConverter.requestToFileSystem(request.getCloudStorage());
        measure(() -> fileSystemConfigService.createWithMdcContextRestore(fileSystem, stack.getWorkspace(), user), LOGGER, "File system saving took {} ms for stack {}", stackName);
    }
    clusterStub.setStack(stack);
    clusterStub.setWorkspace(stack.getWorkspace());
    Cluster cluster = measure(() -> clusterDecorator.decorate(clusterStub, request, blueprint, user, stack.getWorkspace(), stack, parentEnvironmentCloudPlatform), LOGGER, "Cluster decorator {} ms for stack {}", stackName);
    List<ClusterComponent> components = multiCheckedMeasure((MultiCheckedSupplier<List<ClusterComponent>, IOException, CloudbreakImageCatalogException>) () -> {
        if (blueprint != null) {
            Set<Component> allComponent = componentConfigProviderService.getAllComponentsByStackIdAndType(stack.getId(), Sets.newHashSet(ComponentType.CM_REPO_DETAILS, ComponentType.CDH_PRODUCT_DETAILS, ComponentType.IMAGE));
            Optional<Component> stackCmRepoConfig = allComponent.stream().filter(c -> c.getComponentType().equals(ComponentType.CM_REPO_DETAILS)).findAny();
            List<Component> stackCdhRepoConfig = allComponent.stream().filter(c -> c.getComponentType().equals(ComponentType.CDH_PRODUCT_DETAILS)).collect(Collectors.toList());
            Optional<Component> stackImageComponent = allComponent.stream().filter(c -> c.getComponentType().equals(ComponentType.IMAGE) && c.getName().equalsIgnoreCase(ComponentType.IMAGE.name())).findAny();
            return clouderaManagerClusterCreationSetupService.prepareClouderaManagerCluster(request, cluster, stackCmRepoConfig, stackCdhRepoConfig, stackImageComponent);
        }
        return Collections.emptyList();
    }, LOGGER, "Cluster components saved in {} ms for stack {}", stackName);
    return clusterOperationService.create(stack, cluster, components, user);
}
Also used : Set(java.util.Set) Optional(java.util.Optional) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) List(java.util.List) IOException(java.io.IOException) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)

Example 7 with Cluster

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

the class ClusterToClusterV4ResponseConverter method convert.

public ClusterV4Response convert(Cluster source) {
    ClusterV4Response clusterResponse = new ClusterV4Response();
    clusterResponse.setId(source.getId());
    clusterResponse.setName(source.getName());
    Stack stack = source.getStack();
    clusterResponse.setStatus(stack.getStatus());
    clusterResponse.setStatusReason(stack.getStatusReason());
    setUptime(source, clusterResponse);
    clusterResponse.setDescription(source.getDescription() == null ? "" : source.getDescription());
    String managerAddress = stackUtil.extractClusterManagerAddress(stack);
    Map<String, Collection<ClusterExposedServiceV4Response>> clusterExposedServicesForTopologies = serviceEndpointCollector.prepareClusterExposedServices(source, managerAddress);
    clusterResponse.setExposedServices(clusterExposedServicesForTopologies);
    convertCustomQueue(source, clusterResponse);
    convertNullableProperties(source, clusterResponse);
    convertContainerConfig(source, clusterResponse);
    clusterResponse.setCreationFinished(source.getCreationFinished());
    decorateResponseWithProxyConfig(source, clusterResponse);
    clusterResponse.setCloudStorage(getCloudStorage(source));
    clusterResponse.setCm(ClusterToClouderaManagerV4ResponseConverter.convert(source));
    clusterResponse.setDatabases(source.getRdsConfigs().stream().filter(rds -> ResourceStatus.USER_MANAGED.equals(rds.getStatus())).map(rds -> rdsConfigToDatabaseV4ResponseConverter.convert(rds)).collect(Collectors.toList()));
    clusterResponse.setWorkspace(workspaceToWorkspaceResourceV4ResponseConverter.convert(source.getWorkspace()));
    clusterResponse.setBlueprint(getIfNotNull(source.getBlueprint(), blueprintToBlueprintV4ResponseConverter::convert));
    clusterResponse.setExtendedBlueprintText(getExtendedBlueprintText(source));
    convertDpSecrets(source, clusterResponse);
    clusterResponse.setServerIp(stackUtil.extractClusterManagerIp(stack));
    clusterResponse.setServerFqdn(source.getFqdn());
    clusterResponse.setServerUrl(serviceEndpointCollector.getManagerServerUrl(source, managerAddress));
    clusterResponse.setCustomConfigurationsName(getIfNotNull(source.getCustomConfigurations(), configurations -> configurations.getName()));
    clusterResponse.setCustomConfigurationsCrn(getIfNotNull(source.getCustomConfigurations(), configurations -> configurations.getCrn()));
    clusterResponse.setDatabaseServerCrn(source.getDatabaseServerCrn());
    clusterResponse.setRangerRazEnabled(source.isRangerRazEnabled());
    clusterResponse.setCertExpirationState(source.getCertExpirationState());
    return clusterResponse;
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) AwsStorageParameters(com.sequenceiq.common.api.cloudstorage.AwsStorageParameters) NullUtil.getIfNotNull(com.sequenceiq.cloudbreak.util.NullUtil.getIfNotNull) ResourceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus) ClusterExposedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response) AwsEfsParameters(com.sequenceiq.common.api.cloudstorage.AwsEfsParameters) ClusterToClouderaManagerV4ResponseConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.cluster.clouderamanager.ClusterToClouderaManagerV4ResponseConverter) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ProxyConfigDtoService(com.sequenceiq.cloudbreak.service.proxy.ProxyConfigDtoService) StringUtils(org.apache.commons.lang3.StringUtils) StringToSecretResponseConverter(com.sequenceiq.cloudbreak.service.secret.model.StringToSecretResponseConverter) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) CUSTOM_QUEUE(com.sequenceiq.cloudbreak.domain.ClusterAttributes.CUSTOM_QUEUE) Map(java.util.Map) RDSConfigToDatabaseV4ResponseConverter(com.sequenceiq.cloudbreak.converter.v4.database.RDSConfigToDatabaseV4ResponseConverter) WorkspaceToWorkspaceResourceV4ResponseConverter(com.sequenceiq.cloudbreak.converter.v4.workspaces.WorkspaceToWorkspaceResourceV4ResponseConverter) AnonymizerUtil.anonymize(com.sequenceiq.cloudbreak.common.anonymizer.AnonymizerUtil.anonymize) GatewayV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.GatewayV4Response) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException) Logger(org.slf4j.Logger) Collection(java.util.Collection) CustomContainerV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.customcontainer.CustomContainerV4Response) CloudStorageResponse(com.sequenceiq.common.api.cloudstorage.CloudStorageResponse) IOException(java.io.IOException) BlueprintToBlueprintV4ResponseConverter(com.sequenceiq.cloudbreak.converter.v4.blueprint.BlueprintToBlueprintV4ResponseConverter) Collectors(java.util.stream.Collectors) Json(com.sequenceiq.cloudbreak.common.json.Json) Component(org.springframework.stereotype.Component) StackUtil(com.sequenceiq.cloudbreak.util.StackUtil) ServiceEndpointCollector(com.sequenceiq.cloudbreak.service.ServiceEndpointCollector) Entry(java.util.Map.Entry) ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) GatewayToGatewayV4ResponseConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.cluster.gateway.GatewayToGatewayV4ResponseConverter) ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) Collection(java.util.Collection) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 8 with Cluster

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

the class ClusterBootstrapper method bootstrapNewNodesOnHost.

private void bootstrapNewNodesOnHost(Stack stack, List<GatewayConfig> allGatewayConfigs, Set<Node> nodes, Set<Node> allNodes) throws CloudbreakOrchestratorException {
    LOGGER.info("Bootstrap new nodes: {}", nodes);
    Cluster cluster = stack.getCluster();
    Boolean enableKnox = cluster.getGateway() != null;
    for (InstanceMetaData gateway : stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata()) {
        GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gateway, enableKnox);
        ExtendedPollingResult bootstrapApiPolling = hostBootstrapApiPollingService.pollWithAbsoluteTimeout(hostBootstrapApiCheckerTask, new HostBootstrapApiContext(stack, gatewayConfig, hostOrchestrator), POLL_INTERVAL, MAX_POLLING_ATTEMPTS);
        validatePollingResultForCancellation(bootstrapApiPolling.getPollingResult(), "Polling of bootstrap API was cancelled.");
    }
    byte[] stateZip = null;
    ClusterComponent stateComponent = clusterComponentProvider.getComponent(cluster.getId(), ComponentType.SALT_STATE);
    if (stateComponent != null) {
        String content = (String) stateComponent.getAttributes().getMap().getOrDefault(ComponentType.SALT_STATE.name(), "");
        if (!content.isEmpty()) {
            stateZip = Base64.decodeBase64(content);
        }
    }
    BootstrapParams params = createBootstrapParams(stack);
    hostOrchestrator.bootstrapNewNodes(allGatewayConfigs, nodes, allNodes, stateZip, params, clusterDeletionBasedModel(stack.getId(), null));
    InstanceMetaData primaryGateway = stack.getPrimaryGatewayInstance();
    GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, primaryGateway, enableKnox);
    ExtendedPollingResult allNodesAvailabilityPolling = hostClusterAvailabilityPollingService.pollWithAbsoluteTimeout(hostClusterAvailabilityCheckerTask, new HostOrchestratorClusterContext(stack, hostOrchestrator, gatewayConfig, nodes), POLL_INTERVAL, MAX_POLLING_ATTEMPTS);
    validatePollingResultForCancellation(allNodesAvailabilityPolling.getPollingResult(), "Polling of new nodes availability was cancelled.");
    if (allNodesAvailabilityPolling.isTimeout()) {
        clusterBootstrapperErrorHandler.terminateFailedNodes(hostOrchestrator, null, stack, gatewayConfig, nodes);
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HostOrchestratorClusterContext(com.sequenceiq.cloudbreak.core.bootstrap.service.host.context.HostOrchestratorClusterContext) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) BootstrapParams(com.sequenceiq.cloudbreak.orchestrator.model.BootstrapParams) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) HostBootstrapApiContext(com.sequenceiq.cloudbreak.core.bootstrap.service.host.context.HostBootstrapApiContext) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 9 with Cluster

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

the class ClusterServiceRunner method redeployGatewayCertificate.

public void redeployGatewayCertificate(Long stackId) {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    Long clusterId = stack.getCluster().getId();
    Cluster cluster = clusterService.findOneWithLists(clusterId).orElseThrow(NotFoundException.notFound("Cluster", clusterId));
    hostRunner.redeployGatewayCertificate(stack, cluster);
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 10 with Cluster

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

the class ClusterServiceRunner method redeployGatewayPillar.

public void redeployGatewayPillar(Long stackId) {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    Long clusterId = stack.getCluster().getId();
    Cluster cluster = clusterService.findOneWithLists(clusterId).orElseThrow(NotFoundException.notFound("Cluster", clusterId));
    hostRunner.redeployGatewayPillarOnly(stack, cluster);
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)407 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)248 Test (org.junit.jupiter.api.Test)125 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)63 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)60 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)58 Optional (java.util.Optional)51 Test (org.junit.Test)50 List (java.util.List)49 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)47 Set (java.util.Set)43 Json (com.sequenceiq.cloudbreak.common.json.Json)39 Map (java.util.Map)39 Collectors (java.util.stream.Collectors)39 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)37 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)36 Inject (javax.inject.Inject)36 Logger (org.slf4j.Logger)36 LoggerFactory (org.slf4j.LoggerFactory)36 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)35