final Map<String, String> attributes = machineConfig.getAttributes(); String configuredLimit = attributes.get(MEMORY_LIMIT_ATTRIBUTE); String configuredRequest = attributes.get(MEMORY_REQUEST_ATTRIBUTE);
/** * Parses (and fetches if needed) recipe of environment and sums RAM size of all machines in * environment in megabytes. */ public long calculate(@Nullable Environment environment) throws ServerException { if (environment == null) { return 0; } try { return getInternalEnvironment(environment) .getMachines() .values() .stream() .mapToLong( m -> parseMemoryAttributeValue(m.getAttributes().get(MEMORY_LIMIT_ATTRIBUTE))) .sum() / BYTES_TO_MEGABYTES_DIVIDER; } catch (InfrastructureException | ValidationException | NotFoundException ex) { throw new ServerException(ex.getMessage(), ex); } }
if (machineConfig.getAttributes() != null) { String memoryLimit = machineConfig.getAttributes().get(MEMORY_LIMIT_ATTRIBUTE); String memoryRequest = machineConfig.getAttributes().get(MEMORY_REQUEST_ATTRIBUTE); if (memoryLimit != null && memoryRequest != null) { checkArgument(
.getMachines() .values() .forEach(m -> m.getAttributes().put(CONTAINER_SOURCE_ATTRIBUTE, RECIPE_CONTAINER_SOURCE));