File tree Expand file tree Collapse file tree 4 files changed +36
-4
lines changed
aix/native/libmanagement_ext
linux/native/libmanagement_ext
macosx/native/libmanagement_ext
unix/classes/com/sun/management/internal Expand file tree Collapse file tree 4 files changed +36
-4
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2008, 2019 , Oracle and/or its affiliates. All rights reserved.
3- * Copyright (c) 2015 SAP SE. All rights reserved.
2+ * Copyright (c) 2008, 2020 , Oracle and/or its affiliates. All rights reserved.
3+ * Copyright (c) 2015, 2020 SAP SE. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
66 * This code is free software; you can redistribute it and/or modify it
@@ -57,3 +57,10 @@ Java_com_sun_management_internal_OperatingSystemImpl_getHostConfiguredCpuCount0
5757{
5858 return -1 ;
5959}
60+
61+ JNIEXPORT jint JNICALL
62+ Java_com_sun_management_internal_OperatingSystemImpl_getHostOnlineCpuCount0
63+ (JNIEnv * env , jobject mbean )
64+ {
65+ return -1 ;
66+ }
Original file line number Diff line number Diff line change @@ -364,3 +364,15 @@ Java_com_sun_management_internal_OperatingSystemImpl_getHostConfiguredCpuCount0
364364 return -1 ;
365365 }
366366}
367+
368+ JNIEXPORT jint JNICALL
369+ Java_com_sun_management_internal_OperatingSystemImpl_getHostOnlineCpuCount0
370+ (JNIEnv * env , jobject mbean )
371+ {
372+ int n = sysconf (_SC_NPROCESSORS_ONLN );
373+ if (n <= 0 ) {
374+ n = 1 ;
375+ }
376+ return n ;
377+ }
378+
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2011, 2019 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2011, 2020 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -173,3 +173,11 @@ Java_com_sun_management_internal_OperatingSystemImpl_getHostConfiguredCpuCount0
173173{
174174 return -1 ;
175175}
176+
177+ JNIEXPORT jint JNICALL
178+ Java_com_sun_management_internal_OperatingSystemImpl_getHostOnlineCpuCount0
179+ (JNIEnv * env , jobject mbean )
180+ {
181+ return -1 ;
182+ }
183+
Original file line number Diff line number Diff line change @@ -158,6 +158,10 @@ public double getSystemCpuLoad() {
158158 return getSystemCpuLoad0 ();
159159 } else {
160160 int [] cpuSet = containerMetrics .getEffectiveCpuSetCpus ();
161+ // in case the effectiveCPUSetCpus are not available, attempt to use just cpusets.cpus
162+ if (cpuSet == null || cpuSet .length <= 0 ) {
163+ cpuSet = containerMetrics .getCpuSetCpus ();
164+ }
161165 if (cpuSet != null && cpuSet .length > 0 ) {
162166 double systemLoad = 0.0 ;
163167 for (int cpu : cpuSet ) {
@@ -182,7 +186,7 @@ public double getProcessCpuLoad() {
182186
183187 private boolean isCpuSetSameAsHostCpuSet () {
184188 if (containerMetrics != null ) {
185- return containerMetrics .getCpuSetCpus ().length == getHostConfiguredCpuCount0 ();
189+ return containerMetrics .getCpuSetCpus ().length == getHostOnlineCpuCount0 ();
186190 }
187191 return false ;
188192 }
@@ -200,6 +204,7 @@ private boolean isCpuSetSameAsHostCpuSet() {
200204 private native long getTotalSwapSpaceSize0 ();
201205 private native double getSingleCpuLoad0 (int cpuNum );
202206 private native int getHostConfiguredCpuCount0 ();
207+ private native int getHostOnlineCpuCount0 ();
203208
204209 static {
205210 initialize0 ();
You can’t perform that action at this time.
0 commit comments