Search in sources :

Example 1 with LocalNode

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;
}
Also used : LocalNode(org.objectweb.proactive.core.runtime.LocalNode) OperatingSystemMXBean(com.sun.management.OperatingSystemMXBean)

Aggregations

OperatingSystemMXBean (com.sun.management.OperatingSystemMXBean)1 LocalNode (org.objectweb.proactive.core.runtime.LocalNode)1