reswqa commented on code in PR #24541:
URL: https://github.com/apache/flink/pull/24541#discussion_r1599450119
##########
flink-core/src/main/java/org/apache/flink/api/common/operators/SlotSharingGroup.java:
##########
@@ -137,6 +137,37 @@ public int hashCode() {
return result;
}
+ /** Convert a {@link SlotSharingGroupDescriptor} to {@link
SlotSharingGroup}. */
+ public static SlotSharingGroup fromDescriptor(SlotSharingGroupDescriptor
descriptor) {
+ if (descriptor.getCpuCores() != null && descriptor.getTaskHeapMemory()
!= null) {
+ MemorySize taskOffHeapMemory =
+ descriptor.getTaskOffHeapMemory() == null
+ ? MemorySize.ZERO
+ : descriptor.getTaskOffHeapMemory();
+ MemorySize managedMemory =
+ descriptor.getManagedMemory() == null
+ ? MemorySize.ZERO
+ : descriptor.getManagedMemory();
+ return new SlotSharingGroup(
+ descriptor.getName(),
+ new CPUResource(descriptor.getCpuCores()),
+ descriptor.getTaskHeapMemory(),
+ taskOffHeapMemory,
+ managedMemory,
+ descriptor.getExternalResources());
+ } else if (descriptor.getCpuCores() != null
+ || descriptor.getTaskHeapMemory() != null
+ || descriptor.getTaskOffHeapMemory() != null
+ || descriptor.getManagedMemory() != null
+ || !descriptor.getExternalResources().isEmpty()) {
+ throw new IllegalArgumentException(
+ "The cpu cores and task heap memory are required when
specifying the resource of a slot sharing group. "
+ + "You need to explicitly configure them with
positive value.");
+ } else {
+ return new SlotSharingGroup(descriptor.getName());
+ }
Review Comment:
I kind of think that these two are not equivalent transformations 🤔
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]