Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ public class ResourceHandlerModule {
private static volatile CpuResourceHandler
cGroupsCpuResourceHandler;

private static void initializeCGroupHandlers(Configuration conf)
throws ResourceHandlerException {
private static void initializeCGroupHandlers(Configuration conf,
CGroupsHandler.CGroupController controller) throws ResourceHandlerException {
initializeCGroupV1Handler(conf);
if (cgroupsV2Enabled) {
if (cgroupsV2Enabled && !isMountedInCGroupsV1(controller)) {
initializeCGroupV2Handler(conf);
}
}
Expand Down Expand Up @@ -110,6 +110,10 @@ private static void initializeCGroupV2Handler(Configuration conf)
}
}

private static boolean isMountedInCGroupsV1(CGroupsHandler.CGroupController controller) {
return (cGroupV1Handler != null && cGroupV1Handler.getControllerPath(controller) != null);
}

private static boolean isMountedInCGroupsV2(CGroupsHandler.CGroupController controller) {
return (cGroupV2Handler != null && cGroupV2Handler.getControllerPath(controller) != null);
}
Expand Down Expand Up @@ -174,7 +178,7 @@ private static CpuResourceHandler initCGroupsCpuResourceHandler(
if (cGroupsCpuResourceHandler == null) {
LOG.debug("Creating new cgroups cpu handler");

initializeCGroupHandlers(conf);
initializeCGroupHandlers(conf, CGroupsHandler.CGroupController.CPU);
if (isMountedInCGroupsV2(CGroupsHandler.CGroupController.CPU)) {
cGroupsCpuResourceHandler = new CGroupsV2CpuResourceHandlerImpl(cGroupV2Handler);
} else {
Expand All @@ -198,7 +202,7 @@ private static CpuResourceHandler initCGroupsCpuResourceHandler(
if (trafficControlBandwidthHandler == null) {
LOG.info("Creating new traffic control bandwidth handler.");

initializeCGroupHandlers(conf);
initializeCGroupHandlers(conf, CGroupsHandler.CGroupController.NET_CLS);
trafficControlBandwidthHandler = new
TrafficControlBandwidthHandlerImpl(PrivilegedOperationExecutor
.getInstance(conf), cGroupV1Handler,
Expand Down Expand Up @@ -235,7 +239,7 @@ public static ResourceHandler getNetworkTaggingHandler(Configuration conf)
if (networkPacketTaggingHandlerImpl == null) {
LOG.info("Creating new network-tagging-handler.");

initializeCGroupHandlers(conf);
initializeCGroupHandlers(conf, CGroupsHandler.CGroupController.NET_CLS);
networkPacketTaggingHandlerImpl =
new NetworkPacketTaggingHandlerImpl(
PrivilegedOperationExecutor.getInstance(conf), cGroupV1Handler);
Expand Down Expand Up @@ -267,7 +271,7 @@ private static CGroupsBlkioResourceHandlerImpl getCgroupsBlkioResourceHandler(
if (cGroupsBlkioResourceHandler == null) {
LOG.debug("Creating new cgroups blkio handler");

initializeCGroupHandlers(conf);
initializeCGroupHandlers(conf, CGroupsHandler.CGroupController.BLKIO);
cGroupsBlkioResourceHandler =
new CGroupsBlkioResourceHandlerImpl(cGroupV1Handler);
}
Expand All @@ -292,7 +296,7 @@ public static MemoryResourceHandler initMemoryResourceHandler(
synchronized (MemoryResourceHandler.class) {
if (cGroupsMemoryResourceHandler == null) {

initializeCGroupHandlers(conf);
initializeCGroupHandlers(conf, CGroupsHandler.CGroupController.MEMORY);
if (isMountedInCGroupsV2(CGroupsHandler.CGroupController.MEMORY)) {
cGroupsMemoryResourceHandler = new CGroupsV2MemoryResourceHandlerImpl(cGroupV2Handler);
} else {
Expand Down Expand Up @@ -359,7 +363,7 @@ private static void addHandlersFromConfiguredResourcePlugins(
}

for (ResourcePlugin plugin : pluginMap.values()) {
initializeCGroupHandlers(conf);
initializeCGroupV1Handler(conf);
addHandlerIfNotNull(handlerList,
plugin.createResourceHandler(nmContext,
cGroupV1Handler,
Expand Down
Loading