KarmaGYZ commented on a change in pull request #14983:
URL: https://github.com/apache/flink/pull/14983#discussion_r580718071



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/slotmanager/SlotManagerUtils.java
##########
@@ -34,6 +34,18 @@ public static ResourceProfile 
generateDefaultSlotResourceProfile(
                 .build();
     }
 
+    public static ResourceProfile generateDefaultSlotResourceProfile(
+            ResourceProfile resourceProfile, int numSlotsPerWorker) {
+        return ResourceProfile.newBuilder()
+                
.setCpuCores(resourceProfile.getCpuCores().divide(numSlotsPerWorker))
+                
.setTaskHeapMemory(resourceProfile.getTaskHeapMemory().divide(numSlotsPerWorker))
+                .setTaskOffHeapMemory(
+                        
resourceProfile.getTaskOffHeapMemory().divide(numSlotsPerWorker))
+                
.setManagedMemory(resourceProfile.getManagedMemory().divide(numSlotsPerWorker))
+                
.setNetworkMemory(resourceProfile.getNetworkMemory().divide(numSlotsPerWorker))
+                .build();
+    }

Review comment:
       I wonder how can we ensure the resulting profile is the same with the 
output of`TaskExecutorResourceUtils#generateDefaultSlotResourceProfile`? Maybe 
we can add an UT at the moment.

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/slotmanager/SlotManagerUtils.java
##########
@@ -34,6 +34,18 @@ public static ResourceProfile 
generateDefaultSlotResourceProfile(
                 .build();
     }
 
+    public static ResourceProfile generateDefaultSlotResourceProfile(
+            ResourceProfile resourceProfile, int numSlotsPerWorker) {
+        return ResourceProfile.newBuilder()
+                
.setCpuCores(resourceProfile.getCpuCores().divide(numSlotsPerWorker))
+                
.setTaskHeapMemory(resourceProfile.getTaskHeapMemory().divide(numSlotsPerWorker))
+                .setTaskOffHeapMemory(
+                        
resourceProfile.getTaskOffHeapMemory().divide(numSlotsPerWorker))
+                
.setManagedMemory(resourceProfile.getManagedMemory().divide(numSlotsPerWorker))
+                
.setNetworkMemory(resourceProfile.getNetworkMemory().divide(numSlotsPerWorker))
+                .build();
+    }

Review comment:
       Maybe also add a JavaDoc to explain the relationship in case someone 
breaks that assumption.




----------------------------------------------------------------
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]


Reply via email to