java.lang.Object
org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.DefaultOOMHandler
All Implemented Interfaces:
Runnable

@Public @Evolving public class DefaultOOMHandler extends Object implements Runnable
A very basic OOM handler implementation. See the javadoc on the run() method for details.
  • Field Details

    • LOG

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

    • DefaultOOMHandler

      public DefaultOOMHandler(Context context, boolean enforceVirtualMemory)
      Create an OOM handler. This has to be public to be able to construct through reflection.
      Parameters:
      context - node manager context to work with
      enforceVirtualMemory - true if virtual memory needs to be checked, false if physical memory needs to be checked instead
  • Method Details

    • getCGroupsHandler

      @VisibleForTesting protected CGroupsHandler getCGroupsHandler()
    • run

      public void run()
      It is called when the node is under an OOM condition. All processes in all sub-cgroups are suspended. We need to act fast, so that we do not affect the overall system utilization. In general we try to find a newly launched container that exceeded its limits. The justification is cost, since probably this is the one that has accumulated the least amount of uncommitted data so far. OPPORTUNISTIC containers are always killed before any GUARANTEED containers are considered. We continue the process until the OOM is resolved.
      Specified by:
      run in interface Runnable
    • killContainer

      protected boolean killContainer()
      Choose and kill a container in case of OOM. We try to find the most recently launched OPPORTUNISTIC container that exceeds its limit and fall back to the most recently launched OPPORTUNISTIC container If there is no such container found, we choose to kill a GUARANTEED container in the same way.
      Returns:
      true if a container is killed, false otherwise