Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!resources.mem().isSome()) {
- // No memory specified so probe OS or resort to DEFAULT_MEM.
- Bytes mem;
- Try<os::Memory> mem_ = os::memory();
- if (mem_.isError()) {
- LOG(WARNING) << "Failed to auto-detect the size of main memory: '"
- << mem_.error()
- << "' ; defaulting to DEFAULT_MEM";
- mem = DEFAULT_MEM;
- } else {
- mem = mem_.get().total;
- // Leave 1 GB free if we have more than 1 GB, otherwise, use all!
- // TODO(benh): Have better default scheme (e.g., % of mem not greater
- // than 1 GB?)
- if (mem > Gigabytes(1)) {
- mem = mem - Gigabytes(1);
- }
- }
- resources += Resources::parse(
- "mem",
- stringify(mem.megabytes()),
- flags.default_role).get();
- } else {
- // If memory specified
- Bytes mem ;
- // value of memory provided by user
- mem = resources.mem().get();
- Try<os::Memory> mem_ = os::memory();
- if (mem_.isError()) {
- //Error in main memory detection so using the default memory
- //check if the user specified memory is more than the Default memory
- if (mem > DEFAULT_MEM ) {
- LOG(WARNING) << "Failed to auto-detect the size of main memory: '"
- << mem_.error()
- << "' ; defaulting to DEFAULT_MEM"
- << "Resources specifies more than the default memory '"
- << DEFAULT_MEM
- << "' Defaulting to DEFAULT_MEM";
- mem = DEFAULT_MEM ;
- }
- } else {
- if (mem > mem_.get().total ) {
- LOG(WARNING) << "Resources specifies more than the main memory '"
- << mem_.get().total.megabytes()
- << "' Defaulting to main memory";
- mem = mem_.get().total ;
- }
- }
- //subtract the already parsed resources( memory ) and then
- resources -= Resources::parse(
- "mem",
- stringify(resources.mem().get().megabytes()),
- flags.default_role).get();
- //add the new value of resources
- resources += Resources::parse(
- "mem",
- stringify(mem.megabytes()),
- flags.default_role).get();
- }
Advertisement
Add Comment
Please, Sign In to add comment