Search in sources :

Example 41 with Cluster

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

the class StackUpdater method doUpdateStackStatus.

private Stack doUpdateStackStatus(Long stackId, Status newStatus, DetailedStackStatus newDetailedStatus, String statusReason) {
    Stack stack = stackService.getByIdWithTransaction(stackId);
    StackStatus actualStackStatus = stack.getStackStatus();
    LOGGER.info("Update stack status from: {}/{} to: {}/{} stack: {} reason: {}", actualStackStatus.getStatus(), actualStackStatus.getDetailedStackStatus(), newStatus, newDetailedStatus, stackId, statusReason);
    if (actualStackStatus.getStatus().equals(newStatus)) {
        LOGGER.debug("New status is the same as previous status {}/{}, skip status update.", actualStackStatus.getStatus(), actualStackStatus.getDetailedStackStatus());
        return stack;
    } else if (!stack.isDeleteCompleted()) {
        stack.setStackStatus(new StackStatus(stack, newStatus, statusReason, newDetailedStatus));
        Cluster cluster = stack.getCluster();
        if (newStatus.isRemovableStatus()) {
            InMemoryStateStore.deleteStack(stackId);
            if (cluster != null) {
                InMemoryStateStore.deleteCluster(cluster.getId());
            }
        } else {
            InMemoryStateStore.putStack(stackId, statusToPollGroupConverter.convert(newStatus));
            if (cluster != null) {
                InMemoryStateStore.putCluster(cluster.getId(), statusToPollGroupConverter.convert(newStatus));
            }
        }
        stack = stackService.save(stack);
        saveDeprecatedClusterStatus(statusReason, stack, newStatus);
        usageLoggingUtil.logClusterStatusChangeUsageEvent(actualStackStatus.getStatus(), newStatus, cluster);
    } else {
        LOGGER.info("Stack is in DELETE_COMPLETED status, cannot update status.");
    }
    return stack;
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 42 with Cluster

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

the class IdBrokerService method generateIdBrokerSignKey.

public void generateIdBrokerSignKey(Long stackId) {
    Cluster cluster = clusterService.findOneByStackIdOrNotFoundError(stackId);
    IdBroker idBroker = repository.findByClusterId(cluster.getId());
    if (idBroker == null) {
        LOGGER.debug("Generate IdBroker sign keys for the cluster");
        idBroker = idBrokerConverterUtil.generateIdBrokerSignKeys(cluster);
        repository.save(idBroker);
    } else {
        LOGGER.debug("IdBroker sign keysh have already been created");
    }
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) IdBroker(com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)

Example 43 with Cluster

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

the class GatewayPublicEndpointManagementService method updateDnsEntryForCluster.

public String updateDnsEntryForCluster(Stack stack) {
    String fqdn = updateDnsEntry(stack, null);
    if (fqdn != null) {
        Cluster cluster = stack.getCluster();
        cluster.setFqdn(fqdn);
        clusterService.save(cluster);
        LOGGER.info("The '{}' domain name has been generated, registered through PEM service and saved for the cluster.", fqdn);
    }
    return fqdn;
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)

Example 44 with Cluster

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

the class RedbeamsDbCertificateProvider method getDatalakeDatabaseRootCerts.

private void getDatalakeDatabaseRootCerts(Stack stack, Set<String> result) {
    if (StackType.WORKLOAD.equals(stack.getType())) {
        Optional<Stack> datalakeStack = datalakeService.getDatalakeStackByDatahubStack(stack);
        LOGGER.debug("Gathering datalake and its database if exists for the cluster");
        if (datalakeStack.isPresent()) {
            Cluster dataLakeCluster = datalakeStack.get().getCluster();
            result.addAll(getDatabaseRootCerts(dataLakeCluster));
        } else {
            LOGGER.info("There is no datalake resource could be found for the cluster.");
        }
    }
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 45 with Cluster

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

the class MountDisks method mountDisks.

private void mountDisks(Stack stack, Set<Node> nodesWithDiskData, Set<Node> allNodes) throws CloudbreakException {
    Cluster cluster = stack.getCluster();
    try {
        List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
        ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), cluster.getId());
        Map<String, Map<String, String>> mountInfo;
        if (isCbVersionPostOptimisation(stack)) {
            mountInfo = hostOrchestrator.formatAndMountDisksOnNodes(stack, gatewayConfigs, nodesWithDiskData, allNodes, exitCriteriaModel, stack.getPlatformVariant());
        } else {
            mountInfo = hostOrchestrator.formatAndMountDisksOnNodesLegacy(gatewayConfigs, nodesWithDiskData, allNodes, exitCriteriaModel, stack.getPlatformVariant());
        }
        mountInfo.forEach((hostname, value) -> {
            Optional<String> instanceIdOptional = stack.getInstanceMetaDataAsList().stream().filter(instanceMetaData -> hostname.equals(instanceMetaData.getDiscoveryFQDN())).filter(instanceMetaData -> InstanceStatus.CREATED.equals(instanceMetaData.getInstanceStatus())).map(InstanceMetaData::getInstanceId).findFirst();
            if (instanceIdOptional.isPresent()) {
                String uuids = value.getOrDefault("uuids", "");
                String fstab = value.getOrDefault("fstab", "");
                if (!StringUtils.isEmpty(uuids) && !StringUtils.isEmpty(fstab)) {
                    persistUuidAndFstab(stack, instanceIdOptional.get(), hostname, uuids, fstab);
                }
            }
        });
    } catch (CloudbreakOrchestratorFailedException e) {
        LOGGER.error("Failed to mount disks", e);
        throw new CloudbreakSecuritySetupException(e);
    }
}
Also used : ExitCriteriaModel(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) LoggerFactory(org.slf4j.LoggerFactory) ComponentConfigProviderService(com.sequenceiq.cloudbreak.service.ComponentConfigProviderService) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ResourceService(com.sequenceiq.cloudbreak.service.resource.ResourceService) Service(org.springframework.stereotype.Service) Map(java.util.Map) CloudbreakSecuritySetupException(com.sequenceiq.cloudbreak.core.CloudbreakSecuritySetupException) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel) Logger(org.slf4j.Logger) CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) ResourceAttributeUtil(com.sequenceiq.cloudbreak.cluster.util.ResourceAttributeUtil) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) Set(java.util.Set) ExitCriteriaModel(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel) VersionComparator(com.sequenceiq.cloudbreak.util.VersionComparator) VolumeSetAttributes(com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes) Collectors(java.util.stream.Collectors) GatewayConfigService(com.sequenceiq.cloudbreak.service.GatewayConfigService) List(java.util.List) StackUtil(com.sequenceiq.cloudbreak.util.StackUtil) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Optional(java.util.Optional) StringUtils.substringBefore(org.apache.commons.lang3.StringUtils.substringBefore) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) StringUtils(org.springframework.util.StringUtils) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) CloudbreakSecuritySetupException(com.sequenceiq.cloudbreak.core.CloudbreakSecuritySetupException) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Map(java.util.Map) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

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