azagrebin commented on a change in pull request #10146: [FLINK-14188][runtime]
TaskExecutor derive and register with default slot resource profile
URL: https://github.com/apache/flink/pull/10146#discussion_r353818711
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/TaskExecutorResourceUtils.java
##########
@@ -526,7 +545,8 @@ private static CPUResource getCpuCores(final Configuration
config) {
}
return new CPUResource(cpuCores);
} else {
- return new
CPUResource(config.getInteger(TaskManagerOptions.NUM_TASK_SLOTS));
+ final BigDecimal defaultSlotFraction =
getDefaultSlotFraction(config);
+ return new
CPUResource(BigDecimal.valueOf(1.0).divide(defaultSlotFraction, 16,
RoundingMode.DOWN).doubleValue());
Review comment:
Strange that we have to convert `BigDecimal` to `double` and then back to
`BigDecimal`, it would be nice to avoid this. Not sure about value of having a
factory method `CPUResource#create` and private constructor for
`CPUResource(BigDecimal)`. I would either then use only constructors or factory
methods with detailed names like: `createFromBigDecimal`. Also the factory
method already belongs to `CPUResource` so it could also return a concrete
`CPUResource`.
Then this line would be something like (w/o `.doubleValue()`):
`new CPUResource(BigDecimal.valueOf(1.0).divide(defaultSlotFraction, 16,
RoundingMode.DOWN))`
----------------------------------------------------------------
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]
With regards,
Apache Git Services