Search in sources :

Example 66 with InstanceMetaData

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

the class HostMetadataSetup method setupHostMetadata.

public void setupHostMetadata(Long stackId) throws CloudbreakException {
    LOGGER.info("Setting up host metadata for the cluster.");
    Stack stack = stackService.getByIdWithLists(stackId);
    if (!orchestratorTypeResolver.resolveType(stack.getOrchestrator()).containerOrchestrator()) {
        Set<InstanceMetaData> allInstanceMetaData = stack.getRunningInstanceMetaData();
        updateWithHostData(stack, stack.getRunningInstanceMetaData());
        instanceMetaDataRepository.save(allInstanceMetaData);
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 67 with InstanceMetaData

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

the class GeneralClusterConfigsProvider method generalClusterConfigs.

public GeneralClusterConfigs generalClusterConfigs(Stack stack, Cluster cluster, IdentityUser identityUser) {
    boolean gatewayInstanceMetadataPresented = false;
    boolean instanceMetadataPresented = false;
    if (stack.getInstanceGroups() != null && !stack.getInstanceGroups().isEmpty()) {
        List<InstanceMetaData> gatewayInstanceMetadata = stack.getGatewayInstanceMetadata();
        gatewayInstanceMetadataPresented = gatewayInstanceMetadata.size() > 1;
        instanceMetadataPresented = true;
    }
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setIdentityUserEmail(identityUser.getUsername());
    generalClusterConfigs.setAmbariIp(cluster.getAmbariIp());
    generalClusterConfigs.setInstanceGroupsPresented(instanceMetadataPresented);
    generalClusterConfigs.setGatewayInstanceMetadataPresented(gatewayInstanceMetadataPresented);
    generalClusterConfigs.setClusterName(cluster.getName());
    generalClusterConfigs.setPassword(cluster.getPassword());
    generalClusterConfigs.setExecutorType(cluster.getExecutorType());
    generalClusterConfigs.setStackName(stack.getName());
    generalClusterConfigs.setUuid(stack.getUuid());
    generalClusterConfigs.setUserName(cluster.getUserName());
    generalClusterConfigs.setNodeCount(stack.getFullNodeCount());
    generalClusterConfigs.setPrimaryGatewayInstanceDiscoveryFQDN(Optional.ofNullable(stack.getPrimaryGatewayInstance().getDiscoveryFQDN()));
    return generalClusterConfigs;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) GeneralClusterConfigs(com.sequenceiq.cloudbreak.blueprint.templates.GeneralClusterConfigs)

Example 68 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.InstanceMetaData 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 69 with InstanceMetaData

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

the class ClusterToClusterResponseConverter method prepareServiceEndpointsMap.

private Map<String, String> prepareServiceEndpointsMap(Cluster cluster, String ambariIp) {
    Set<HostGroup> hostGroups = cluster.getHostGroups();
    Blueprint blueprint = cluster.getBlueprint();
    Map<String, String> result = new HashMap<>();
    List<Port> ports = NetworkUtils.getPorts(Optional.empty());
    try {
        JsonNode hostGroupsNode = blueprintValidator.getHostGroupNode(blueprint);
        Map<String, HostGroup> hostGroupMap = blueprintValidator.createHostGroupMap(hostGroups);
        for (JsonNode hostGroupNode : hostGroupsNode) {
            String hostGroupName = blueprintValidator.getHostGroupName(hostGroupNode);
            JsonNode componentsNode = blueprintValidator.getComponentsNode(hostGroupNode);
            HostGroup actualHostgroup = hostGroupMap.get(hostGroupName);
            String serviceAddress;
            if (actualHostgroup.getConstraint().getInstanceGroup() != null) {
                InstanceMetaData next = actualHostgroup.getConstraint().getInstanceGroup().getInstanceMetaData().iterator().next();
                serviceAddress = next.getPublicIpWrapper();
            } else {
                serviceAddress = actualHostgroup.getHostMetadata().iterator().next().getHostName();
            }
            for (JsonNode componentNode : componentsNode) {
                String componentName = componentNode.get("name").asText();
                StackServiceComponentDescriptor componentDescriptor = stackServiceComponentDescs.get(componentName);
                collectServicePorts(result, ports, ambariIp, serviceAddress, componentDescriptor, cluster);
            }
        }
    } catch (Exception ignored) {
        return result;
    }
    return result;
}
Also used : HashMap(java.util.HashMap) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Port(com.sequenceiq.cloudbreak.api.model.Port) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) JsonNode(com.fasterxml.jackson.databind.JsonNode) CloudbreakApiException(com.sequenceiq.cloudbreak.controller.CloudbreakApiException) IOException(java.io.IOException) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) StackServiceComponentDescriptor(com.sequenceiq.cloudbreak.blueprint.validation.StackServiceComponentDescriptor)

Example 70 with InstanceMetaData

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

the class AmbariClusterService method updateInstanceMetadataStateToRegistered.

private void updateInstanceMetadataStateToRegistered(Long stackId, HostMetadata host) {
    InstanceMetaData instanceMetaData = instanceMetaDataRepository.findHostInStack(stackId, host.getHostName());
    if (instanceMetaData != null) {
        instanceMetaData.setInstanceStatus(InstanceStatus.REGISTERED);
        instanceMetadataRepository.save(instanceMetaData);
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData)

Aggregations

InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)71 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)24 Stack (com.sequenceiq.cloudbreak.domain.Stack)23 ArrayList (java.util.ArrayList)18 HashSet (java.util.HashSet)17 Map (java.util.Map)16 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)14 Test (org.junit.Test)14 HashMap (java.util.HashMap)13 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)12 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)12 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)11 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)9 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)9 List (java.util.List)9 Set (java.util.Set)9 Inject (javax.inject.Inject)8 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)7 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)7 Matchers.anyString (org.mockito.Matchers.anyString)7