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 2019/12/03 12:40:56 UTC

[GitHub] [flink] azagrebin commented on a change in pull request #10398: [FLINK-14936][runtime] Introduce MemoryManager#computeMemorySize to calculate managed memory size from a fraction

azagrebin commented on a change in pull request #10398: [FLINK-14936][runtime] Introduce MemoryManager#computeMemorySize to calculate managed memory size from a fraction
URL: https://github.com/apache/flink/pull/10398#discussion_r353155241
 
 

 ##########
 File path: flink-runtime/src/test/java/org/apache/flink/runtime/memory/MemoryManagerTest.java
 ##########
 @@ -298,6 +299,39 @@ public void testMemoryAllocationAndReservation() throws MemoryAllocationExceptio
 		memoryManager.releaseAllMemory(owner2, type);
 	}
 
+	@Test
+	public void testComputeMemorySize() {
+		double fraction = 0.6;
+		assertEquals((long) (memoryManager.getMemorySize() * fraction), memoryManager.computeMemorySize(fraction));
+
+		fraction = 1.0;
+		assertEquals((long) (memoryManager.getMemorySize() * fraction), memoryManager.computeMemorySize(fraction));
+	}
+
+	@Test
+	public void testComputeMemorySizeInvalidFraction() {
+		try {
+			memoryManager.computeMemorySize(0.0);
 
 Review comment:
   Could we do like this instead for each case?
   ```
   @Test(Expected = IllegalArgumentException.class)
   public void testComputeMemorySizeFailForZeroFraction() {
       memoryManager.computeMemorySize(0.0);
   }
   ```

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