Search in sources :

Example 1 with ClusterComponent

use of com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent 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 2 with ClusterComponent

use of com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent 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 3 with ClusterComponent

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

the class ClusterUpgradeHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeRequest> event) {
    LOGGER.debug("Accepting Cluster upgrade event..");
    ClusterUpgradeRequest request = event.getData();
    Long stackId = request.getResourceId();
    Selectable result;
    try {
        Stack stack = stackService.getByIdWithClusterInTransaction(stackId);
        Optional<String> remoteDataContext = getRemoteDataContext(stack);
        ClusterApi connector = clusterApiConnectors.getConnector(stack);
        Set<ClusterComponent> components = parcelService.getParcelComponentsByBlueprint(stack);
        connector.upgradeClusterRuntime(components, request.isPatchUpgrade(), remoteDataContext);
        ParcelOperationStatus parcelOperationStatus = parcelService.removeUnusedParcelComponents(stack, components);
        if (parcelOperationStatus.getFailed().isEmpty()) {
            result = new ClusterUpgradeSuccess(request.getResourceId());
        } else {
            LOGGER.info("There are failed parcel removals: {}", parcelOperationStatus);
            CloudbreakException exception = new CloudbreakException(format("Failed to remove the following parcels: %s", parcelOperationStatus.getFailed()));
            result = new ClusterUpgradeFailedEvent(request.getResourceId(), exception, DetailedStackStatus.CLUSTER_UPGRADE_FAILED);
        }
    } catch (Exception e) {
        LOGGER.error("Cluster upgrade event failed", e);
        result = new ClusterUpgradeFailedEvent(request.getResourceId(), e, DetailedStackStatus.CLUSTER_UPGRADE_FAILED);
    }
    return result;
}
Also used : ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ClusterUpgradeRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeRequest) ClusterUpgradeFailedEvent(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeFailedEvent) ClusterUpgradeSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeSuccess) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ParcelOperationStatus(com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException)

Example 4 with ClusterComponent

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

the class ClouderaManagerClusterCreationSetupService method determineCmRepoConfig.

private ClusterComponent determineCmRepoConfig(Optional<Component> stackClouderaManagerRepoConfig, String osType, Cluster cluster, String cdhStackVersion) throws CloudbreakImageCatalogException {
    Json json;
    if (Objects.isNull(stackClouderaManagerRepoConfig) || stackClouderaManagerRepoConfig.isEmpty()) {
        ImageCatalogPlatform platform = platformStringTransformer.getPlatformStringForImageCatalog(cluster.getStack().getCloudPlatform(), cluster.getStack().getPlatformVariant());
        ClouderaManagerRepo clouderaManagerRepo = defaultClouderaManagerRepoService.getDefault(osType, StackType.CDH.name(), cdhStackVersion, platform);
        if (clouderaManagerRepo == null) {
            throw new BadRequestException(String.format("Couldn't determine Cloudera Manager repo for the stack: %s", cluster.getStack().getName()));
        }
        json = new Json(clouderaManagerRepo);
    } else {
        json = stackClouderaManagerRepoConfig.get().getAttributes();
    }
    return new ClusterComponent(ComponentType.CM_REPO_DETAILS, json, cluster);
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ImageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Json(com.sequenceiq.cloudbreak.common.json.Json)

Example 5 with ClusterComponent

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

the class ClusterCreationSetupService method prepare.

public Cluster prepare(ClusterV4Request request, Stack stack, Blueprint blueprint, User user) 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), 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)

Aggregations

ClusterComponent (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)47 Json (com.sequenceiq.cloudbreak.common.json.Json)15 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)14 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)13 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)13 Set (java.util.Set)10 Test (org.junit.Test)10 ParcelOperationStatus (com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus)9 List (java.util.List)9 IOException (java.io.IOException)8 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)7 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)7 HashSet (java.util.HashSet)7 Optional (java.util.Optional)7 Collectors (java.util.stream.Collectors)7 Test (org.junit.jupiter.api.Test)7 ComponentType (com.sequenceiq.cloudbreak.common.type.ComponentType)6 Map (java.util.Map)6 Collections (java.util.Collections)5 HashMap (java.util.HashMap)5