Search in sources :

Example 51 with InstanceMetaData

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

the class ClusterContainerRunner method getGatewayPrivateIp.

private String getGatewayPrivateIp(Stack stack) {
    String gatewayHostname = "";
    if (stack.getInstanceGroups() != null && !stack.getInstanceGroups().isEmpty()) {
        InstanceMetaData gatewayInstance = stack.getPrimaryGatewayInstance();
        gatewayHostname = gatewayInstance.getPrivateIp();
    }
    return gatewayHostname;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData)

Example 52 with InstanceMetaData

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

the class ClusterContainerRunner method getGatewayHostName.

private String getGatewayHostName(Stack stack) {
    String gatewayHostname = "";
    if (stack.getInstanceGroups() != null && !stack.getInstanceGroups().isEmpty()) {
        if (stack.getPrimaryGatewayInstance() != null) {
            InstanceMetaData gatewayInstance = stack.getPrimaryGatewayInstance();
            gatewayHostname = gatewayInstance.getDiscoveryFQDN();
        }
    }
    return gatewayHostname;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData)

Example 53 with InstanceMetaData

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

the class ContainerConstraintFactory method collectUpscaleCandidates.

private List<String> collectUpscaleCandidates(Long clusterId, String hostGroupName, Integer adjustment) {
    HostGroup hostGroup = hostGroupRepository.findHostGroupInClusterByName(clusterId, hostGroupName);
    if (hostGroup.getConstraint().getInstanceGroup() != null) {
        Long instanceGroupId = hostGroup.getConstraint().getInstanceGroup().getId();
        Set<InstanceMetaData> unusedHostsInInstanceGroup = instanceMetaDataRepository.findUnusedHostsInInstanceGroup(instanceGroupId);
        List<String> hostNames = new ArrayList<>();
        for (InstanceMetaData instanceMetaData : unusedHostsInInstanceGroup) {
            hostNames.add(instanceMetaData.getDiscoveryFQDN());
            if (hostNames.size() >= adjustment) {
                break;
            }
        }
        return hostNames;
    }
    return null;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) ArrayList(java.util.ArrayList) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup)

Example 54 with InstanceMetaData

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

the class StackToCloudStackConverter method getFirstValidPrivateId.

private Long getFirstValidPrivateId(Iterable<InstanceGroup> instanceGroups) {
    LOGGER.info("Get first valid PrivateId of instanceGroups");
    long highest = 0;
    for (InstanceGroup instanceGroup : instanceGroups) {
        LOGGER.info("Checking of instanceGroup: {}", instanceGroup.getGroupName());
        for (InstanceMetaData metaData : instanceGroup.getAllInstanceMetaData()) {
            Long privateId = metaData.getPrivateId();
            LOGGER.info("InstanceMetaData metaData: privateId: {}, instanceGroupName: {}, instanceId: {}, status: {}", privateId, metaData.getInstanceGroupName(), metaData.getInstanceId(), metaData.getInstanceStatus());
            if (privateId == null) {
                continue;
            }
            if (privateId > highest) {
                highest = privateId;
            }
        }
    }
    LOGGER.info("highest privateId: {}", highest);
    return highest == 0 ? 0 : highest + 1;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 55 with InstanceMetaData

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

the class InstanceMetadataService method updateInstanceStatus.

public void updateInstanceStatus(Iterable<InstanceGroup> instanceGroup, com.sequenceiq.cloudbreak.api.model.InstanceStatus newStatus, Collection<String> candidateAddresses) {
    for (InstanceGroup group : instanceGroup) {
        for (InstanceMetaData instanceMetaData : group.getInstanceMetaData()) {
            if (candidateAddresses.contains(instanceMetaData.getDiscoveryFQDN())) {
                instanceMetaData.setInstanceStatus(newStatus);
                instanceMetaDataRepository.save(instanceMetaData);
            }
        }
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

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