use of org.objectweb.proactive.core.runtime.LocalNode in project scheduling by ow2-proactive.
the class RamCompute method getAvailableRAMInGB.
/**
* @return the total GIGA of RAM available in a machine minus the RAM preallocated by a task.
*/
public double getAvailableRAMInGB() {
OperatingSystemMXBean bean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
double totRAMAvailable = ((double) bean.getTotalPhysicalMemorySize()) / GIGABYTE;
double totalRAMUsed = 0;
for (LocalNode localNode : ProActiveRuntimeImpl.getProActiveRuntime().getLocalNodes()) {
if (localNode.getProperty(RamSchedulingPolicy.RAM_VARIABLE_NAME) != null) {
totalRAMUsed += Double.parseDouble(localNode.getProperty(RamSchedulingPolicy.RAM_VARIABLE_NAME));
}
}
double ramInBytes = totRAMAvailable - totalRAMUsed;
return ramInBytes;
}
Aggregations