Search in sources :

Example 1 with TemporaryStorage

use of com.sequenceiq.cloudbreak.common.type.TemporaryStorage in project cloudbreak by hortonworks.

the class StackUtil method collectNewNodesWithDiskData.

public Set<Node> collectNewNodesWithDiskData(Stack stack, Set<String> newNodeAddresses) {
    Set<Node> agents = new HashSet<>();
    List<Resource> volumeSets = stack.getDiskResources();
    Map<String, Map<String, Object>> instanceToVolumeInfoMap = createInstanceToVolumeInfoMap(volumeSets);
    for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
        if (instanceGroup.getNodeCount() != 0) {
            for (InstanceMetaData im : instanceGroup.getNotDeletedAndNotZombieInstanceMetaDataSet()) {
                if (im.getDiscoveryFQDN() != null && (newNodeAddresses.isEmpty() || newNodeAddresses.contains(im.getPrivateIp()))) {
                    String instanceId = im.getInstanceId();
                    String instanceType = instanceGroup.getTemplate().getInstanceType();
                    String dataVolumes = getOrDefault(instanceToVolumeInfoMap, instanceId, "dataVolumes", "");
                    String serialIds = getOrDefault(instanceToVolumeInfoMap, instanceId, "serialIds", "");
                    String fstab = getOrDefault(instanceToVolumeInfoMap, instanceId, "fstab", "");
                    String uuids = getOrDefault(instanceToVolumeInfoMap, instanceId, "uuids", "");
                    Integer databaseVolumeIndex = getOrDefault(instanceToVolumeInfoMap, instanceId, "dataBaseVolumeIndex", -1);
                    TemporaryStorage temporaryStorage = Optional.ofNullable(instanceGroup.getTemplate().getTemporaryStorage()).orElse(TemporaryStorage.ATTACHED_VOLUMES);
                    NodeVolumes nodeVolumes = new NodeVolumes(databaseVolumeIndex, dataVolumes, serialIds, fstab, uuids);
                    agents.add(new Node(im.getPrivateIp(), im.getPublicIp(), instanceId, instanceType, im.getDiscoveryFQDN(), im.getInstanceGroupName(), nodeVolumes, temporaryStorage));
                }
            }
        }
    }
    return agents;
}
Also used : Node(com.sequenceiq.cloudbreak.common.orchestration.Node) Resource(com.sequenceiq.cloudbreak.domain.Resource) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) NodeVolumes(com.sequenceiq.cloudbreak.common.orchestration.NodeVolumes) TemporaryStorage(com.sequenceiq.cloudbreak.common.type.TemporaryStorage) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

Node (com.sequenceiq.cloudbreak.common.orchestration.Node)1 NodeVolumes (com.sequenceiq.cloudbreak.common.orchestration.NodeVolumes)1 TemporaryStorage (com.sequenceiq.cloudbreak.common.type.TemporaryStorage)1 Resource (com.sequenceiq.cloudbreak.domain.Resource)1 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)1 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1