int minCores = max(strategyMinCores, contextMinCores);
LOG.info("Provisioning strategy RAM {}, cores {}", minRam, minCores);
List<DockerHostLocation> available = MutableList.of();
for (DockerHostLocation location : locations) {
HardwareDetails details = location.getMachine().getMachineDetails().getHardwareDetails();
if (details.getCpuCount() > minCores && details.getRam() > minRam) {
// Look up other entities already using this location and their requirements
Iterable<Entity> entities = getBrooklynManagementContext().getEntityManager().findEntities(EntityPredicates.withLocation(location));
int ramUsed = 0, coresUsed = 0;
for (Entity entity : entities) {
Map<String,Object> entityFlags = entity.getConfig(SoftwareProcess.PROVISIONING_PROPERTIES);
LOG.info("Checking provisioning flags on {}: {}", entity, entityFlags);
if (entityFlags == null || entityFlags.isEmpty()) continue;
Integer entityMinRam = (Integer) entityFlags.get("minRam");
Integer entityMinCores = (Integer) entityFlags.get("minCores");
ramUsed += entityMinRam == null ? 0 : entityMinRam;
coresUsed += entityMinCores == null ? 0 : entityMinCores;
}
if ((details.getCpuCount() - coresUsed) > minCores && (details.getRam() - ramUsed) > minRam) {
available.add(location);
}
}
}
return available;