@@ -76,10 +76,10 @@ public class ResourceHandlerModule {
76
76
private static volatile CpuResourceHandler
77
77
cGroupsCpuResourceHandler ;
78
78
79
- private static void initializeCGroupHandlers (Configuration conf )
80
- throws ResourceHandlerException {
79
+ private static void initializeCGroupHandlers (Configuration conf ,
80
+ CGroupsHandler . CGroupController controller ) throws ResourceHandlerException {
81
81
initializeCGroupV1Handler (conf );
82
- if (cgroupsV2Enabled ) {
82
+ if (cgroupsV2Enabled && ! isMountedInCGroupsV1 ( controller ) ) {
83
83
initializeCGroupV2Handler (conf );
84
84
}
85
85
}
@@ -110,6 +110,10 @@ private static void initializeCGroupV2Handler(Configuration conf)
110
110
}
111
111
}
112
112
113
+ private static boolean isMountedInCGroupsV1 (CGroupsHandler .CGroupController controller ) {
114
+ return (cGroupV1Handler != null && cGroupV1Handler .getControllerPath (controller ) != null );
115
+ }
116
+
113
117
private static boolean isMountedInCGroupsV2 (CGroupsHandler .CGroupController controller ) {
114
118
return (cGroupV2Handler != null && cGroupV2Handler .getControllerPath (controller ) != null );
115
119
}
@@ -174,7 +178,7 @@ private static CpuResourceHandler initCGroupsCpuResourceHandler(
174
178
if (cGroupsCpuResourceHandler == null ) {
175
179
LOG .debug ("Creating new cgroups cpu handler" );
176
180
177
- initializeCGroupHandlers (conf );
181
+ initializeCGroupHandlers (conf , CGroupsHandler . CGroupController . CPU );
178
182
if (isMountedInCGroupsV2 (CGroupsHandler .CGroupController .CPU )) {
179
183
cGroupsCpuResourceHandler = new CGroupsV2CpuResourceHandlerImpl (cGroupV2Handler );
180
184
} else {
@@ -198,7 +202,7 @@ private static CpuResourceHandler initCGroupsCpuResourceHandler(
198
202
if (trafficControlBandwidthHandler == null ) {
199
203
LOG .info ("Creating new traffic control bandwidth handler." );
200
204
201
- initializeCGroupHandlers (conf );
205
+ initializeCGroupHandlers (conf , CGroupsHandler . CGroupController . NET_CLS );
202
206
trafficControlBandwidthHandler = new
203
207
TrafficControlBandwidthHandlerImpl (PrivilegedOperationExecutor
204
208
.getInstance (conf ), cGroupV1Handler ,
@@ -235,7 +239,7 @@ public static ResourceHandler getNetworkTaggingHandler(Configuration conf)
235
239
if (networkPacketTaggingHandlerImpl == null ) {
236
240
LOG .info ("Creating new network-tagging-handler." );
237
241
238
- initializeCGroupHandlers (conf );
242
+ initializeCGroupHandlers (conf , CGroupsHandler . CGroupController . NET_CLS );
239
243
networkPacketTaggingHandlerImpl =
240
244
new NetworkPacketTaggingHandlerImpl (
241
245
PrivilegedOperationExecutor .getInstance (conf ), cGroupV1Handler );
@@ -267,7 +271,7 @@ private static CGroupsBlkioResourceHandlerImpl getCgroupsBlkioResourceHandler(
267
271
if (cGroupsBlkioResourceHandler == null ) {
268
272
LOG .debug ("Creating new cgroups blkio handler" );
269
273
270
- initializeCGroupHandlers (conf );
274
+ initializeCGroupHandlers (conf , CGroupsHandler . CGroupController . BLKIO );
271
275
cGroupsBlkioResourceHandler =
272
276
new CGroupsBlkioResourceHandlerImpl (cGroupV1Handler );
273
277
}
@@ -292,7 +296,7 @@ public static MemoryResourceHandler initMemoryResourceHandler(
292
296
synchronized (MemoryResourceHandler .class ) {
293
297
if (cGroupsMemoryResourceHandler == null ) {
294
298
295
- initializeCGroupHandlers (conf );
299
+ initializeCGroupHandlers (conf , CGroupsHandler . CGroupController . MEMORY );
296
300
if (isMountedInCGroupsV2 (CGroupsHandler .CGroupController .MEMORY )) {
297
301
cGroupsMemoryResourceHandler = new CGroupsV2MemoryResourceHandlerImpl (cGroupV2Handler );
298
302
} else {
@@ -359,7 +363,7 @@ private static void addHandlersFromConfiguredResourcePlugins(
359
363
}
360
364
361
365
for (ResourcePlugin plugin : pluginMap .values ()) {
362
- initializeCGroupHandlers (conf );
366
+ initializeCGroupV1Handler (conf );
363
367
addHandlerIfNotNull (handlerList ,
364
368
plugin .createResourceHandler (nmContext ,
365
369
cGroupV1Handler ,
0 commit comments