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;
}
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);
}
}
}
}
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);
}
}
Aggregations