You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/02/28 18:24:25 UTC

[GitHub] [flink] tillrohrmann commented on a change in pull request #10299: [FLINK-14560] [runtime] The value of taskmanager.memory.size in flink…

tillrohrmann commented on a change in pull request #10299: [FLINK-14560] [runtime] The value of taskmanager.memory.size in flink…
URL: https://github.com/apache/flink/pull/10299#discussion_r385840577
 
 

 ##########
 File path: flink-runtime/src/main/java/org/apache/flink/runtime/util/ConfigurationParserUtils.java
 ##########
 @@ -42,25 +42,20 @@
 	 * @return managed memory size (in megabytes)
 	 */
 	public static long getManagedMemorySize(Configuration configuration) {
-		long managedMemorySize;
-		String managedMemorySizeDefaultVal = TaskManagerOptions.MANAGED_MEMORY_SIZE.defaultValue();
-		if (!configuration.getString(TaskManagerOptions.MANAGED_MEMORY_SIZE).equals(managedMemorySizeDefaultVal)) {
+		long managedMemorySize = 0L;
+		if(configuration.contains(TaskManagerOptions.MANAGED_MEMORY_SIZE)){
 			try {
 				managedMemorySize = MemorySize.parse(
 					configuration.getString(TaskManagerOptions.MANAGED_MEMORY_SIZE), MEGA_BYTES).getMebiBytes();
 			} catch (IllegalArgumentException e) {
 				throw new IllegalConfigurationException("Could not read " + TaskManagerOptions.MANAGED_MEMORY_SIZE.key(), e);
 			}
-		} else {
-			managedMemorySize = Long.valueOf(managedMemorySizeDefaultVal);
-		}
-
-		checkConfigParameter(configuration.getString(
-			TaskManagerOptions.MANAGED_MEMORY_SIZE).equals(TaskManagerOptions.MANAGED_MEMORY_SIZE.defaultValue()) || managedMemorySize > 0,
-			managedMemorySize, TaskManagerOptions.MANAGED_MEMORY_SIZE.key(),
-			"MemoryManager needs at least one MB of memory. " +
-				"If you leave this config parameter empty, the system automatically pick a fraction of the available memory.");
 
+			checkConfigParameter( managedMemorySize > 0,
+				managedMemorySize, TaskManagerOptions.MANAGED_MEMORY_SIZE.key(),
+				"MemoryManager needs at least one MB of memory. " +
+					"If you leave this config parameter empty, the system automatically pick a fraction of the available memory.");
+		}
 		return managedMemorySize;
 	}
 
 Review comment:
   Would this work instead?
   
   ```
   public static long getManagedMemorySize(Configuration configuration) {
   		final MemorySize defaultManagedMemory = MemorySize.parse(TaskManagerOptions.MANAGED_MEMORY_SIZE.defaultValue());
   
   		final String managedMemoryValue = configuration.getString(TaskManagerOptions.MANAGED_MEMORY_SIZE);
   		final MemorySize configuredManagedMemory;
   
   		try {
   			configuredManagedMemory = MemorySize.parse(managedMemoryValue, MEGA_BYTES);
   		} catch (IllegalArgumentException e) {
   			throw new IllegalConfigurationException("Could not read " + TaskManagerOptions.MANAGED_MEMORY_SIZE.key(), e);
   		}
   
   		checkConfigParameter(defaultManagedMemory.equals(configuredManagedMemory) || configuredManagedMemory.getMebiBytes() > 0,
   			managedMemoryValue, TaskManagerOptions.MANAGED_MEMORY_SIZE.key(),
   			"MemoryManager needs at least one MB of memory. " +
   				"If you leave this config parameter empty, the system automatically pick a fraction of the available memory.");
   
   		return configuredManagedMemory.getMebiBytes();
   	}
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services