Class CGroupElasticMemoryController
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionCGroupElasticMemoryController(org.apache.hadoop.conf.Configuration conf, Context context, CGroupsHandler cgroups, boolean controlPhysicalMemory, boolean controlVirtualMemory, long limit) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks if the CGroupElasticMemoryController is available on this system.voidStop listening to the cgroup.voidwork()Main OOM listening thread.Methods inherited from class org.apache.hadoop.util.concurrent.SubjectInheritingThread
run, startMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, suspend, toString, yield
-
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 usecontext- Node manager context to out of memory handlercgroups- Cgroups handler configuredcontrolPhysicalMemory- Whether to listen to physical memory OOMcontrolVirtualMemory- Whether to listen to virtual memory OOMlimit- 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:
workin classorg.apache.hadoop.util.concurrent.SubjectInheritingThread
-