Search in sources :

Example 1 with SshHostConfiguration

use of io.fabric8.api.SshHostConfiguration in project fabric8 by jboss-fuse.

the class SshAutoScalerTest method assertMaximumContainerCountNotExceeded.

/**
 * lets assert that no host has more than its maximum number of containers
 */
public static void assertMaximumContainerCountNotExceeded(FabricRequirements requirements, Map<String, CountingMap> hostToProfileCounts) {
    for (Map.Entry<String, CountingMap> entry : hostToProfileCounts.entrySet()) {
        String hostName = entry.getKey();
        CountingMap counts = entry.getValue();
        int total = counts.total();
        SshConfiguration sshConfiguration = requirements.getSshConfiguration();
        assertNotNull("Should have a sshConfiguration!", sshConfiguration);
        SshHostConfiguration hostConfiguration = sshConfiguration.getHost(hostName);
        assertNotNull("Should have a hosts configuration for host " + hostName, hostConfiguration);
        Integer maximumContainerCount = hostConfiguration.getMaximumContainerCount();
        if (maximumContainerCount != null) {
            assertTrue("Host " + hostName + " has a maximum container count of " + maximumContainerCount + " but was " + total, total <= maximumContainerCount);
        }
    }
}
Also used : CountingMap(io.fabric8.utils.CountingMap) SshConfiguration(io.fabric8.api.SshConfiguration) SshHostConfiguration(io.fabric8.api.SshHostConfiguration) CountingMap(io.fabric8.utils.CountingMap) Map(java.util.Map)

Example 2 with SshHostConfiguration

use of io.fabric8.api.SshHostConfiguration in project fabric8 by jboss-fuse.

the class SshAutoScaler method chooseHostContainerOptions.

/**
 * This method is public for easier testing
 */
public static CreateSshContainerOptions.Builder chooseHostContainerOptions(AutoScaleRequest request, HostProfileCounter hostProfileCounter) {
    CreateSshContainerOptions.Builder builder = CreateSshContainerOptions.builder();
    FabricRequirements requirements = request.getFabricRequirements();
    ProfileRequirements profileRequirements = request.getProfileRequirements();
    SshScalingRequirements sshScalingRequirements = profileRequirements.getSshScalingRequirements();
    List<SshHostConfiguration> hosts = requirements.getSshHosts();
    SortedSet<LoadSortedHostConfiguration<SshHostConfiguration>> sortedHostConfigurations = AutoScalers.filterHosts(profileRequirements, sshScalingRequirements, hostProfileCounter, hosts);
    SshHostConfiguration sshHostConfig = null;
    if (!sortedHostConfigurations.isEmpty()) {
        LoadSortedHostConfiguration<SshHostConfiguration> first = sortedHostConfigurations.first();
        sshHostConfig = first.getConfiguration();
    }
    if (sshHostConfig == null) {
        LOG.warn("Could not create version " + request.getVersion() + " profile " + request.getProfile() + " as no matching hosts could be found for " + sshScalingRequirements);
        request.getProfileAutoScaleStatus().noSuitableHost("" + sshScalingRequirements);
        return null;
    }
    builder.configure(sshHostConfig, requirements, profileRequirements);
    return builder;
}
Also used : ProfileRequirements(io.fabric8.api.ProfileRequirements) SshHostConfiguration(io.fabric8.api.SshHostConfiguration) FabricRequirements(io.fabric8.api.FabricRequirements) LoadSortedHostConfiguration(io.fabric8.internal.autoscale.LoadSortedHostConfiguration) SshScalingRequirements(io.fabric8.api.SshScalingRequirements)

Aggregations

SshHostConfiguration (io.fabric8.api.SshHostConfiguration)2 FabricRequirements (io.fabric8.api.FabricRequirements)1 ProfileRequirements (io.fabric8.api.ProfileRequirements)1 SshConfiguration (io.fabric8.api.SshConfiguration)1 SshScalingRequirements (io.fabric8.api.SshScalingRequirements)1 LoadSortedHostConfiguration (io.fabric8.internal.autoscale.LoadSortedHostConfiguration)1 CountingMap (io.fabric8.utils.CountingMap)1 Map (java.util.Map)1