Github user dawidwys commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5448#discussion_r191199370
  
    --- Diff: 
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerServicesConfiguration.java
 ---
    @@ -223,9 +224,17 @@ public static TaskManagerServicesConfiguration 
fromConfiguration(
                                parseQueryableStateConfiguration(configuration);
     
                // extract memory settings
    -           long configuredMemory = 
configuration.getLong(TaskManagerOptions.MANAGED_MEMORY_SIZE);
    +           long configuredMemory = 
Long.valueOf(TaskManagerOptions.MANAGED_MEMORY_SIZE.defaultValue());
    +           if 
(!configuration.getString(TaskManagerOptions.MANAGED_MEMORY_SIZE).equals(TaskManagerOptions.MANAGED_MEMORY_SIZE.defaultValue()))
 {
    +                   try {
    +                           configuredMemory = 
MemorySize.parse(configuration.getString(TaskManagerOptions.MANAGED_MEMORY_SIZE)).getMebiBytes();
    +                   } catch (IllegalArgumentException e) {
    +
    +                   }
    +           }
    --- End diff --
    
    Same comments as before.  How about code like this:
    
        long configuredMemory;
        String managedMemorySizeDefaultVal = 
TaskManagerOptions.MANAGED_MEMORY_SIZE.defaultValue();
        if 
(!config.getString(TaskManagerOptions.MANAGED_MEMORY_SIZE).equals(managedMemorySizeDefaultVal))
 {
                try {
                        configuredMemory = 
MemorySize.parse(config.getString(TaskManagerOptions.MANAGED_MEMORY_SIZE))
                                .getMebiBytes();
                } catch (IllegalArgumentException e) {
                        throw new IllegalConfigurationException(
                                "Could not read " + 
TaskManagerOptions.MANAGED_MEMORY_SIZE.key(), e);
                }
        } else {
                configuredMemory = Long.valueOf(managedMemorySizeDefaultVal);
        }


---

Reply via email to