Search in sources :

Example 71 with InstanceGroup

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

the class StackResponseHardwareInfoProvider method providerEntriesToStackResponse.

@Override
public StackResponse providerEntriesToStackResponse(Stack stack, StackResponse stackResponse) {
    Set<HardwareInfoResponse> hardwareInfoResponses = new HashSet<>();
    for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
        for (InstanceMetaData instanceMetaData : instanceGroup.getAllInstanceMetaData()) {
            HostMetadata hostMetadata = null;
            if (stack.getCluster() != null && instanceMetaData.getDiscoveryFQDN() != null) {
                hostMetadata = hostMetadataRepository.findHostInClusterByName(stack.getCluster().getId(), instanceMetaData.getDiscoveryFQDN());
            }
            HardwareInfoResponse hardwareInfoResponse = new HardwareInfoResponse();
            hardwareInfoResponse.setInstanceMetaData(conversionService.convert(instanceMetaData, InstanceMetaDataJson.class));
            hardwareInfoResponse.setHostMetadata(conversionService.convert(hostMetadata, HostMetadataResponse.class));
            hardwareInfoResponses.add(hardwareInfoResponse);
        }
    }
    stackResponse.setHardwareInfos(hardwareInfoResponses);
    return stackResponse;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) HostMetadataResponse(com.sequenceiq.cloudbreak.api.model.HostMetadataResponse) InstanceMetaDataJson(com.sequenceiq.cloudbreak.api.model.InstanceMetaDataJson) HardwareInfoResponse(com.sequenceiq.cloudbreak.api.model.HardwareInfoResponse) HashSet(java.util.HashSet) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata)

Example 72 with InstanceGroup

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

the class NetworkUtils method createACLRules.

private static List<EndpointRule> createACLRules(Stack stack) {
    List<EndpointRule> rules = new LinkedList<>();
    for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
        for (SecurityRule rule : instanceGroup.getSecurityGroup().getSecurityRules()) {
            rules.add(new EndpointRule(Action.PERMIT.getText(), rule.getCidr()));
        }
    }
    EndpointRule internalRule = new EndpointRule(Action.PERMIT.toString(), stack.getNetwork().getSubnetCIDR());
    rules.add(internalRule);
    rules.add(EndpointRule.DENY_RULE);
    return rules;
}
Also used : EndpointRule(com.sequenceiq.cloudbreak.api.model.EndpointRule) SecurityRule(com.sequenceiq.cloudbreak.domain.SecurityRule) LinkedList(java.util.LinkedList) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 73 with InstanceGroup

use of com.sequenceiq.cloudbreak.domain.InstanceGroup 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)

Example 74 with InstanceGroup

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

the class StackRequestToStackConverter method convertInstanceGroups.

private Set<InstanceGroup> convertInstanceGroups(StackRequest source, Stack stack) {
    List<InstanceGroupRequest> instanceGroupRequests = source.getInstanceGroups();
    Set<InstanceGroup> convertedSet = new HashSet<>();
    for (InstanceGroupRequest instanceGroupRequest : instanceGroupRequests) {
        InstanceGroup instanceGroup = getConversionService().convert(instanceGroupRequest, InstanceGroup.class);
        if (instanceGroup != null) {
            convertedSet.add(getConversionService().convert(instanceGroupRequest, InstanceGroup.class));
        }
    }
    boolean gatewaySpecified = false;
    for (InstanceGroup instanceGroup : convertedSet) {
        instanceGroup.setStack(stack);
        if (!gatewaySpecified) {
            if (InstanceGroupType.GATEWAY.equals(instanceGroup.getInstanceGroupType())) {
                gatewaySpecified = true;
            }
        }
    }
    boolean containerOrchestrator;
    try {
        containerOrchestrator = orchestratorTypeResolver.resolveType(source.getOrchestrator().getType()).containerOrchestrator();
    } catch (CloudbreakException ignored) {
        throw new BadRequestException("Orchestrator not supported.");
    }
    if (!gatewaySpecified && !containerOrchestrator) {
        throw new BadRequestException("Ambari server must be specified");
    }
    return convertedSet;
}
Also used : InstanceGroupRequest(com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) HashSet(java.util.HashSet)

Example 75 with InstanceGroup

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

the class StackToStackResponseConverter method addNodeCount.

private void addNodeCount(Stack source, StackResponse stackJson) {
    int nodeCount = 0;
    for (InstanceGroup instanceGroup : source.getInstanceGroups()) {
        nodeCount += instanceGroup.getNodeCount();
    }
    stackJson.setNodeCount(nodeCount);
}
Also used : InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Aggregations

InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)89 Test (org.junit.Test)32 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)27 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)27 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)24 HashSet (java.util.HashSet)16 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 Stack (com.sequenceiq.cloudbreak.domain.Stack)14 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)9 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)8 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)8 Constraint (com.sequenceiq.cloudbreak.domain.Constraint)8 Matchers.anyString (org.mockito.Matchers.anyString)8 Orchestrator (com.sequenceiq.cloudbreak.domain.Orchestrator)6 StackAuthentication (com.sequenceiq.cloudbreak.domain.StackAuthentication)6 Template (com.sequenceiq.cloudbreak.domain.Template)6 ArrayList (java.util.ArrayList)6 InstanceGroupRequest (com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest)5 StackAuthenticationRequest (com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest)5 FailurePolicy (com.sequenceiq.cloudbreak.domain.FailurePolicy)5