xintongsong commented on a change in pull request #11320: [FLINK-16437][runtime] Make SlotManager allocate resource from ResourceManager at the worker granularity. URL: https://github.com/apache/flink/pull/11320#discussion_r388872808
########## File path: flink-yarn/src/main/java/org/apache/flink/yarn/entrypoint/YarnResourceManagerFactory.java ########## @@ -81,4 +91,27 @@ public static YarnResourceManagerFactory getInstance() { webInterfaceUrl, resourceManagerMetricGroup); } + + @Override + protected CPUResource getDefaultCpus(final Configuration configuration) { + int fallback = configuration.getInteger(YarnConfigOptions.VCORES); + double cpuCoresDouble = TaskExecutorProcessUtils.getCpuCoresWithFallback(configuration, fallback).getValue().doubleValue(); + @SuppressWarnings("NumericCastThatLosesPrecision") + long cpuCoresLong = Math.max((long) Math.ceil(cpuCoresDouble), 1L); + //noinspection FloatingPointEquality + if (cpuCoresLong != cpuCoresDouble) { + LOG.info( + "The amount of cpu cores must be a positive integer on Yarn. Rounding {} up to the closest positive integer {}.", + cpuCoresDouble, + cpuCoresLong); + } + if (cpuCoresLong > Integer.MAX_VALUE) { Review comment: @TisonKun Not sure what do you mean. Are you suggesting simplify this code with a `Preconditions.checkstate()`? I remember the reason we implemented it like this in `YarnResourceManager` at the first place, is to get an `IllegalConfigurationException` instead of a `IllegalStateException`, for better readability to the users. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services