flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskManagerServicesTest.java
/**
	 * Test for {@link TaskManagerServices#calculateHeapSizeMB(long, Configuration)} with some
	 * manually calculated scenarios.
	 */
Test for  TaskManagerServices#calculateHeapSizeMB(long, Configuration) with some
manually calculated scenarios.
Test for TaskManagerServices#calculateHeapSizeMB ( long Configuration ) with some manually calculated scenarios .
@Test
	public void calculateHeapSizeMB() throws Exception {
		Configuration config = new Configuration();
		config.setFloat(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION, 0.1f);
		config.setLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN, 64L << 20); 
		config.setLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX, 1L << 30); 
		config.setBoolean(TaskManagerOptions.MEMORY_OFF_HEAP, false);
		assertEquals(1000, TaskManagerServices.calculateHeapSizeMB(1000, config));
		config.setBoolean(TaskManagerOptions.MEMORY_OFF_HEAP, true);
		config.setLong(TaskManagerOptions.MANAGED_MEMORY_SIZE, 10); 
		assertEquals(890, TaskManagerServices.calculateHeapSizeMB(1000, config));
		config.setLong(TaskManagerOptions.MANAGED_MEMORY_SIZE, -1); 
		config.setFloat(TaskManagerOptions.MANAGED_MEMORY_FRACTION, 0.1f); 
		assertEquals(810, TaskManagerServices.calculateHeapSizeMB(1000, config));
	}
@ Test public void calculateHeapSizeMB ( ) throws Exception { Configuration config = new Configuration ( ) ; config . setFloat ( TaskManagerOptions . NETWORK_BUFFERS_MEMORY_FRACTION , 0.1f ) ; config . setLong ( TaskManagerOptions . NETWORK_BUFFERS_MEMORY_MIN , 64L << 20 ) ; config . setLong ( TaskManagerOptions . NETWORK_BUFFERS_MEMORY_MAX , 1L << 30 ) ; config . setBoolean ( TaskManagerOptions . MEMORY_OFF_HEAP , false ) ; assertEquals ( 1000 , TaskManagerServices . calculateHeapSizeMB ( 1000 , config ) ) ; config . setBoolean ( TaskManagerOptions . MEMORY_OFF_HEAP , true ) ; config . setLong ( TaskManagerOptions . MANAGED_MEMORY_SIZE , 10 ) ; assertEquals ( 890 , TaskManagerServices . calculateHeapSizeMB ( 1000 , config ) ) ; config . setLong ( TaskManagerOptions . MANAGED_MEMORY_SIZE , - 1 ) ; config . setFloat ( TaskManagerOptions . MANAGED_MEMORY_FRACTION , 0.1f ) ; assertEquals ( 810 , TaskManagerServices . calculateHeapSizeMB ( 1000 , config ) ) ; }
Test for {@link TaskManagerServices#calculateHeapSizeMB(long, Configuration)} with some
 manually calculated scenarios.
Test for { @link TaskManagerServices#calculateHeapSizeMB ( long Configuration ) } with some manually calculated scenarios .
// 64MB // 1GB // 10MB // use fraction of given memory // 10%