azagrebin commented on a change in pull request #10330: [FLINK-14189][runtime]
Extend TaskExecutor to support dynamic slot allocation
URL: https://github.com/apache/flink/pull/10330#discussion_r352227509
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/slot/TaskSlotUtils.java
##########
@@ -69,6 +70,22 @@ public static ResourceProfile
createDefaultSlotResourceProfile() {
return DEFAULT_RESOURCE_PROFILE;
}
+ public static ResourceProfile createTotalResourceProfile(int
numberOfSlots) {
+ return createTotalResourceProfile(numberOfSlots,
DEFAULT_RESOURCE_PROFILE);
+ }
+
+ public static ResourceProfile createTotalResourceProfile(int
numberOfSlots, ResourceProfile defaultResourceProfile) {
+ ResourceProfile result = defaultResourceProfile;
+ while (numberOfSlots > 1) {
+ result = result.merge(result);
+ if (numberOfSlots % 2 != 0) {
+ result = result.merge(defaultResourceProfile);
+ }
+ numberOfSlots = numberOfSlots / 2;
Review comment:
I would keep it as simple loop merging `defaultResourceProfile`
`numberOfSlots - 1` times for simpler readability.
----------------------------------------------------------------
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