java.lang.Object
java.lang.Thread
org.apache.hadoop.util.concurrent.SubjectInheritingThread
org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.CGroupElasticMemoryController
All Implemented Interfaces:
Runnable

public class CGroupElasticMemoryController extends org.apache.hadoop.util.concurrent.SubjectInheritingThread
This thread controls memory usage using cgroups. It listens to out of memory events of all the containers together, and if we go over the limit picks a container to kill. The algorithm that picks the container is a plugin.
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
  • Constructor Details

    • CGroupElasticMemoryController

      public CGroupElasticMemoryController(org.apache.hadoop.conf.Configuration conf, Context context, CGroupsHandler cgroups, boolean controlPhysicalMemory, boolean controlVirtualMemory, long limit) throws org.apache.hadoop.yarn.exceptions.YarnException
      Default constructor.
      Parameters:
      conf - Yarn configuration to use
      context - Node manager context to out of memory handler
      cgroups - Cgroups handler configured
      controlPhysicalMemory - Whether to listen to physical memory OOM
      controlVirtualMemory - Whether to listen to virtual memory OOM
      limit - memory limit in bytes
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException - Could not instantiate class
  • Method Details

    • stopListening

      public void stopListening()
      Stop listening to the cgroup.
    • isAvailable

      public static boolean isAvailable()
      Checks if the CGroupElasticMemoryController is available on this system. This assumes that Linux container executor is already initialized. We need to have CGroups enabled.
      Returns:
      True if CGroupElasticMemoryController is available. False otherwise.
    • work

      public void work()
      Main OOM listening thread. It uses an external process to listen to Linux events. The external process does not need to run as root, so it is not related to container-executor. We do not use JNI for security reasons.
      Overrides:
      work in class org.apache.hadoop.util.concurrent.SubjectInheritingThread