zhuzhurk commented on a change in pull request #9910: [FLINK-14405][runtime] 
Align ResourceProfile/ResourceSpec fields with the new TaskExecutor memory 
setups.
URL: https://github.com/apache/flink/pull/9910#discussion_r338528868
 
 

 ##########
 File path: 
flink-core/src/main/java/org/apache/flink/api/common/operators/ResourceSpec.java
 ##########
 @@ -198,26 +218,34 @@ public double getGPUResource() {
        }
 
        public Map<String, Resource> getExtendedResources() {
+               throwUnsupportedOperationExecptionIfUnknown();
                return extendedResources;
        }
 
+       private void throwUnsupportedOperationExecptionIfUnknown() {
+               if (this == UNKNOWN) {
+                       throw new UnsupportedOperationException();
+               }
+       }
+
        /**
         * Check whether all the field values are valid.
         *
         * @return True if all the values are equal or greater than 0, 
otherwise false.
         */
        public boolean isValid() {
-               if (this.cpuCores >= 0 && this.heapMemoryInMB >= 0 && 
this.directMemoryInMB >= 0 &&
-                               this.nativeMemoryInMB >= 0 && 
this.stateSizeInMB >= 0 && managedMemoryInMB >= 0) {
-                       for (Resource resource : extendedResources.values()) {
-                               if (resource.getValue() < 0) {
-                                       return false;
-                               }
-                       }
+               if (this == UNKNOWN) {
 
 Review comment:
   I think we should use `equals` instead of `==`.
   `UNKNOWN` resource spec can be initialized in different nodes and created by 
deserialization, which means there can be multiple `UNKNOWN` instances.

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

Reply via email to