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_r343469112
 
 

 ##########
 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:
   That's right. But I thin using it like this is causing confusions and should 
be avoided if possible. Another case is "== ANY" in ResourceProfile(while ANY 
is not handled in ResourceProfile#readResolve), see my other comment.

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