use of io.fabric8.internal.autoscale.HostProfileCounter 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);
}
}
use of io.fabric8.internal.autoscale.HostProfileCounter 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;
}
use of io.fabric8.internal.autoscale.HostProfileCounter in project fabric8 by jboss-fuse.
the class SshAutoScaler method createContainers.
@Override
public void createContainers(AutoScaleRequest request) throws Exception {
int count = request.getDelta();
String profile = request.getProfile();
String version = request.getVersion();
FabricService fabricService = request.getFabricService();
Container[] containers = fabricService.getContainers();
FabricRequirements requirements = request.getFabricRequirements();
List<? extends HostConfiguration> hostConfigurations = requirements.getSshHosts();
HostProfileCounter hostProfileCounter = new HostProfileCounter();
AutoScalers.createHostToProfileScaleMap(hostProfileCounter, hostConfigurations, containers);
for (int i = 0; i < count; i++) {
CreateSshContainerOptions.Builder builder = null;
NameValidator nameValidator = Containers.createNameValidator(containers);
String name = Containers.createAutoScaleContainerName(containers, profile, containerProvider.getScheme(), nameValidator);
if (fabricService != null) {
builder = createAutoScaleOptions(request, fabricService, hostProfileCounter);
}
if (builder != null) {
final CreateSshContainerOptions.Builder configuredBuilder = builder.number(1).version(version).profiles(profile);
CreateSshContainerOptions options = configuredBuilder.name(name).build();
LOG.info("Creating container name " + name + " version " + version + " profile " + profile + " " + count + " container(s)");
fabricService.createContainers(options);
}
}
}
Aggregations