Search in sources :

Example 6 with CountingMap

use of io.fabric8.utils.CountingMap in project fabric8 by jboss-fuse.

the class HostProfileCounter method profileCounts.

public CountingMap profileCounts(String host) {
    CountingMap countingMap = hostToProfileCounts.get(host);
    if (countingMap == null) {
        countingMap = new CountingMap();
        hostToProfileCounts.put(host, countingMap);
    }
    return countingMap;
}
Also used : CountingMap(io.fabric8.utils.CountingMap)

Example 7 with CountingMap

use of io.fabric8.utils.CountingMap in project fabric8 by jboss-fuse.

the class SshAutoScalerTest method assertProfilesUseSeparateHost.

/**
 * lets assert that no host has more than its maximum number of containers
 */
public static void assertProfilesUseSeparateHost(FabricRequirements requirements, Map<String, CountingMap> hostToProfileCounts) {
    for (Map.Entry<String, CountingMap> entry : hostToProfileCounts.entrySet()) {
        String hostName = entry.getKey();
        CountingMap counts = entry.getValue();
        Set<String> keys = counts.keySet();
        for (String profileId : keys) {
            int count = counts.count(profileId);
            // lets see if we have a maximum number of profile count
            ProfileRequirements profileRequirement = requirements.getOrCreateProfileRequirement(profileId);
            Integer maximum = profileRequirement.getMaximumInstancesPerHost();
            if (maximum != null) {
                assertTrue("Host " + hostName + " has " + count + " instances of " + profileId + " but this is configured to have a maximium of " + maximum + " per host", count <= maximum);
            }
        }
    }
}
Also used : CountingMap(io.fabric8.utils.CountingMap) ProfileRequirements(io.fabric8.api.ProfileRequirements) CountingMap(io.fabric8.utils.CountingMap) Map(java.util.Map)

Example 8 with CountingMap

use of io.fabric8.utils.CountingMap in project fabric8 by jboss-fuse.

the class SshAutoScalerTest method dumpHostProfiles.

public static void dumpHostProfiles(HostProfileCounter hostProfileCounter) {
    for (Map.Entry<String, CountingMap> entry : hostProfileCounter.getHostToProfileCounts().entrySet()) {
        CountingMap countingMap = entry.getValue();
        String host = entry.getKey();
        LOG.info("Host " + host + " has " + countingMap);
    }
}
Also used : CountingMap(io.fabric8.utils.CountingMap) CountingMap(io.fabric8.utils.CountingMap) Map(java.util.Map)

Aggregations

CountingMap (io.fabric8.utils.CountingMap)8 Map (java.util.Map)3 ProfileRequirements (io.fabric8.api.ProfileRequirements)2 AutoScaleRequest (io.fabric8.api.AutoScaleRequest)1 Container (io.fabric8.api.Container)1 SshConfiguration (io.fabric8.api.SshConfiguration)1 SshHostConfiguration (io.fabric8.api.SshHostConfiguration)1 HostProfileCounter (io.fabric8.internal.autoscale.HostProfileCounter)1 HashMap (java.util.HashMap)1