Search in sources :

Example 71 with HostGroup

use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.

the class AmbariClusterUpscaleService method installServicesOnNewHosts.

public void installServicesOnNewHosts(Long stackId, String hostGroupName) throws CloudbreakException {
    Stack stack = stackService.getByIdWithLists(stackId);
    LOGGER.info("Start installing Ambari services");
    HostGroup hostGroup = hostGroupService.getByClusterIdAndName(stack.getCluster().getId(), hostGroupName);
    Set<HostMetadata> hostMetadata = hostGroupService.findEmptyHostMetadataInHostGroup(hostGroup.getId());
    ambariClusterConnector.upscaleCluster(stack, hostGroup, hostMetadata);
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Stack(com.sequenceiq.cloudbreak.domain.Stack) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata)

Example 72 with HostGroup

use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.

the class StackService method validateHostGroupAdjustment.

private void validateHostGroupAdjustment(InstanceGroupAdjustmentJson instanceGroupAdjustmentJson, Stack stack, Integer adjustment) {
    Blueprint blueprint = stack.getCluster().getBlueprint();
    Optional<HostGroup> hostGroup = stack.getCluster().getHostGroups().stream().filter(input -> input.getConstraint().getInstanceGroup().getGroupName().equals(instanceGroupAdjustmentJson.getInstanceGroup())).findFirst();
    if (!hostGroup.isPresent()) {
        throw new BadRequestException(String.format("Instancegroup '%s' not found or not part of stack '%s'", instanceGroupAdjustmentJson.getInstanceGroup(), stack.getName()));
    }
    blueprintValidator.validateHostGroupScalingRequest(blueprint, hostGroup.get(), adjustment);
}
Also used : StackView(com.sequenceiq.cloudbreak.domain.view.StackView) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) IdentityUserRole(com.sequenceiq.cloudbreak.common.model.user.IdentityUserRole) ComponentType(com.sequenceiq.cloudbreak.common.type.ComponentType) StackValidation(com.sequenceiq.cloudbreak.domain.StackValidation) Component(com.sequenceiq.cloudbreak.domain.Component) IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) InstanceMetaDataRepository(com.sequenceiq.cloudbreak.repository.InstanceMetaDataRepository) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) LoggerFactory(org.slf4j.LoggerFactory) PasswordUtil(com.sequenceiq.cloudbreak.util.PasswordUtil) Autowired(org.springframework.beans.factory.annotation.Autowired) ServiceProviderConnectorAdapter(com.sequenceiq.cloudbreak.service.stack.connector.adapter.ServiceProviderConnectorAdapter) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) CloudbreakMessagesService(com.sequenceiq.cloudbreak.service.messages.CloudbreakMessagesService) ImageService(com.sequenceiq.cloudbreak.service.image.ImageService) Strings(com.google.api.client.repackaged.com.google.common.base.Strings) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) AuthorizationService(com.sequenceiq.cloudbreak.service.AuthorizationService) SqlUtil.getProperSqlErrorMessage(com.sequenceiq.cloudbreak.util.SqlUtil.getProperSqlErrorMessage) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) OrchestratorRepository(com.sequenceiq.cloudbreak.repository.OrchestratorRepository) AmbariClusterService(com.sequenceiq.cloudbreak.service.cluster.AmbariClusterService) TxType(javax.transaction.Transactional.TxType) StackViewRepository(com.sequenceiq.cloudbreak.repository.StackViewRepository) Transactional(javax.transaction.Transactional) StackStatus(com.sequenceiq.cloudbreak.domain.StackStatus) TlsSecurityService(com.sequenceiq.cloudbreak.service.TlsSecurityService) Collection(java.util.Collection) StackTemplate(com.sequenceiq.cloudbreak.cloud.model.StackTemplate) InstanceGroupRepository(com.sequenceiq.cloudbreak.repository.InstanceGroupRepository) Set(java.util.Set) BlueprintValidator(com.sequenceiq.cloudbreak.blueprint.validation.BlueprintValidator) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) ClusterRepository(com.sequenceiq.cloudbreak.repository.ClusterRepository) List(java.util.List) STOPPED(com.sequenceiq.cloudbreak.api.model.Status.STOPPED) STOP_REQUESTED(com.sequenceiq.cloudbreak.api.model.Status.STOP_REQUESTED) InstanceStatus(com.sequenceiq.cloudbreak.api.model.InstanceStatus) SecurityConfig(com.sequenceiq.cloudbreak.domain.SecurityConfig) ComponentConfigProvider(com.sequenceiq.cloudbreak.service.ComponentConfigProvider) Optional(java.util.Optional) CloudbreakApiException(com.sequenceiq.cloudbreak.controller.CloudbreakApiException) StackStatusRepository(com.sequenceiq.cloudbreak.repository.StackStatusRepository) StackRepository(com.sequenceiq.cloudbreak.repository.StackRepository) InstanceGroupAdjustmentJson(com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson) ReactorFlowManager(com.sequenceiq.cloudbreak.core.flow2.service.ReactorFlowManager) ContainerOrchestratorResolver(com.sequenceiq.cloudbreak.core.bootstrap.service.container.ContainerOrchestratorResolver) MDCBuilder(com.sequenceiq.cloudbreak.logger.MDCBuilder) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) TypeDescriptor(org.springframework.core.convert.TypeDescriptor) Service(org.springframework.stereotype.Service) OrchestrationCredential(com.sequenceiq.cloudbreak.orchestrator.model.OrchestrationCredential) Objects.requireNonNull(java.util.Objects.requireNonNull) StackResponseDecorator(com.sequenceiq.cloudbreak.service.decorator.StackResponseDecorator) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Json(com.sequenceiq.cloudbreak.domain.json.Json) Stack(com.sequenceiq.cloudbreak.domain.Stack) Nonnull(javax.annotation.Nonnull) ConversionService(org.springframework.core.convert.ConversionService) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Logger(org.slf4j.Logger) ContainerOrchestrator(com.sequenceiq.cloudbreak.orchestrator.container.ContainerOrchestrator) CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) AVAILABLE(com.sequenceiq.cloudbreak.api.model.Status.AVAILABLE) DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) AutoscaleStackResponse(com.sequenceiq.cloudbreak.api.model.AutoscaleStackResponse) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) SecurityConfigRepository(com.sequenceiq.cloudbreak.repository.SecurityConfigRepository) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) StackUpdater(com.sequenceiq.cloudbreak.repository.StackUpdater) OpenSshPublicKeyValidator(com.sequenceiq.cloudbreak.service.credential.OpenSshPublicKeyValidator) APIResourceType(com.sequenceiq.cloudbreak.common.type.APIResourceType) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) NetworkConfigurationValidator(com.sequenceiq.cloudbreak.controller.validation.network.NetworkConfigurationValidator) StackV2Request(com.sequenceiq.cloudbreak.api.model.v2.StackV2Request) CloudbreakEventService(com.sequenceiq.cloudbreak.service.events.CloudbreakEventService) StatusRequest(com.sequenceiq.cloudbreak.api.model.StatusRequest) StopRestrictionReason(com.sequenceiq.cloudbreak.domain.StopRestrictionReason) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException)

Example 73 with HostGroup

use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.

the class BlueprintValidator method validateHostGroup.

private void validateHostGroup(JsonNode hostGroupNode, Map<String, HostGroup> hostGroupMap, Map<String, BlueprintServiceComponent> blueprintServiceComponentMap) {
    String hostGroupName = getHostGroupName(hostGroupNode);
    HostGroup hostGroup = getHostGroup(hostGroupMap, hostGroupName);
    JsonNode componentsNode = getComponentsNode(hostGroupNode);
    for (JsonNode componentNode : componentsNode) {
        validateComponent(componentNode, hostGroup, blueprintServiceComponentMap);
    }
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 74 with HostGroup

use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.

the class BlueprintValidator method validateHostGroupScalingRequest.

public void validateHostGroupScalingRequest(Blueprint blueprint, HostGroup hostGroup, Integer adjustment) {
    try {
        JsonNode hostGroupsNode = getHostGroupNode(blueprint);
        Map<String, HostGroup> hostGroupMap = createHostGroupMap(Collections.singleton(hostGroup));
        for (JsonNode hostGroupNode : hostGroupsNode) {
            if (hostGroup.getName().equals(hostGroupNode.get("name").asText())) {
                hostGroup.getConstraint().setHostCount(hostGroup.getConstraint().getHostCount() + adjustment);
                try {
                    validateHostGroup(hostGroupNode, hostGroupMap, new HashMap<>());
                } finally {
                    hostGroup.getConstraint().setHostCount(hostGroup.getConstraint().getHostCount() - adjustment);
                }
                break;
            }
        }
    } catch (IOException ignored) {
        throw new BlueprintValidationException(String.format("Blueprint [%s] can not be parsed from JSON.", blueprint.getId()));
    }
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException)

Example 75 with HostGroup

use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.

the class HdfConfigProvider method createHdfConfig.

public HdfConfigs createHdfConfig(Set<HostGroup> hostgroups, Map<String, List<InstanceMetaData>> groupInstances, String blueprintText) {
    BlueprintTextProcessor blueprintTextProcessor = createTextProcessor(blueprintText);
    Set<String> nifiMasters = collectNifiMasters(blueprintText);
    Set<InstanceGroup> nifiIgs = collectInstanceGroupsWhichContainsNifiMasters(hostgroups, nifiMasters);
    List<String> nifiFqdns = collectFqdnsByInstanceGroupName(groupInstances, nifiIgs);
    AtomicInteger index = new AtomicInteger(0);
    String nodeIdentities = nifiFqdns.stream().map(fqdn -> String.format("<property name=\"Node Identity %s\">CN=%s, OU=NIFI</property>", index.addAndGet(1), fqdn)).collect(Collectors.joining());
    return new HdfConfigs(nodeIdentities, getProxyHostsParameter(nifiIgs, blueprintTextProcessor, groupInstances));
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) BlueprintTextProcessor(com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) Set(java.util.Set) Collectors(java.util.stream.Collectors) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Inject(javax.inject.Inject) List(java.util.List) Component(org.springframework.stereotype.Component) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BlueprintProcessorFactory(com.sequenceiq.cloudbreak.blueprint.BlueprintProcessorFactory) Map(java.util.Map) Optional(java.util.Optional) StringUtils(org.springframework.util.StringUtils) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BlueprintTextProcessor(com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Aggregations

HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)94 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)33 Test (org.junit.Test)33 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)31 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)29 HashSet (java.util.HashSet)22 JsonNode (com.fasterxml.jackson.databind.JsonNode)20 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)20 List (java.util.List)20 HashMap (java.util.HashMap)19 Stack (com.sequenceiq.cloudbreak.domain.Stack)18 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)16 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)15 Map (java.util.Map)14 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)13 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)12 Constraint (com.sequenceiq.cloudbreak.domain.Constraint)11 ArrayList (java.util.ArrayList)11 Set (java.util.Set)11 Inject (javax.inject.Inject)11