gabrywu edited a comment on issue #2927: URL: https://github.com/apache/incubator-dolphinscheduler/issues/2927#issuecomment-643027268
> > but accordin to the API doc of getSystemCpuLoad, it will return [0.0,1.0], how can it return Nan? > > Can you paste the API doc of getSystemCpuLoad, I do not find the description about [0.0,1.0] when I check the source code java doc. But it actually returns NaN in my laptop. I think maybe this exception occurs depending on different laptop hardware environments. So I think there are two things need to do. > > 1.Find why it returns NaN. And I found the issue [naver/pinpoint#914](https://github.com/naver/pinpoint/issues/914), and it use the same `OperatingSystemMXBean.getSystemCpuLoad()`, and also returns NaN. > 2.I think whatever the reason is, it's better to add Double.isNaN check. /** * Returns the "recent cpu usage" for the whole system from * {@link com.sun.management.OperatingSystemMXBean#getSystemCpuLoad()} if a * user is running the Oracle JVM. This value is a double in the [0.0,1.0] * interval. A value of 0.0 means that all CPUs were idle during the recent * period of time observed, while a value of 1.0 means that all CPUs were * actively running 100% of the time during the recent period being * observed. All values between 0.0 and 1.0 are possible depending of the * activities going on in the system. If the system recent cpu usage is not * available, the method returns a negative value. Calling this method * immediately upon instantiating the {@link CentralProcessor} may give * unreliable results. If a user is not running the Oracle JVM, this method * will default to the behavior and return value of * {@link #getSystemCpuLoadBetweenTicks()}. * * @return the "recent cpu usage" for the whole system; a negative value if * not available. */ @SuppressWarnings("restriction") ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
