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#calculateNetworkBufferMemory(long, Configuration)} using mixed
	 * old/new configurations.
	 */
Test for  TaskManagerServices#calculateNetworkBufferMemory(long, Configuration) using mixed
old/new configurations.
Test for TaskManagerServices#calculateNetworkBufferMemory ( long Configuration ) using mixed old / new configurations .
@SuppressWarnings("deprecation")
	@Test
	public void calculateNetworkBufMixed() throws Exception {
		Configuration config = new Configuration();
		config.setInteger(TaskManagerOptions.NETWORK_NUM_BUFFERS, 1);
		final Float defaultFrac = TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION.defaultValue();
		final Long defaultMin = TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN.defaultValue();
		final Long defaultMax = TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX.defaultValue();
		Configuration config1 = config.clone();
		config1.setFloat(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION, 0.1f);
		assertEquals(enforceBounds((long) (0.1f * (10L << 20)), defaultMin, defaultMax),
			TaskManagerServices.calculateNetworkBufferMemory((64L << 20 + 1), config1));
		assertEquals(enforceBounds((long) (0.1f * (10L << 30)), defaultMin, defaultMax),
			TaskManagerServices.calculateNetworkBufferMemory((10L << 30), config1));
		config1 = config.clone();
		long newMin = TaskManagerOptions.MEMORY_SEGMENT_SIZE.defaultValue(); 
		config1.setLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN, newMin);
		assertEquals(enforceBounds((long) (defaultFrac * (10L << 20)), newMin, defaultMax),
			TaskManagerServices.calculateNetworkBufferMemory((10L << 20), config1));
		assertEquals(enforceBounds((long) (defaultFrac * (10L << 30)), newMin, defaultMax),
			TaskManagerServices.calculateNetworkBufferMemory((10L << 30), config1));
		config1 = config.clone();
		long newMax = Math.max(64L << 20 + 1, TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN.defaultValue());
		config1.setLong(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX, newMax);
		assertEquals(enforceBounds((long) (defaultFrac * (10L << 20)), defaultMin, newMax),
			TaskManagerServices.calculateNetworkBufferMemory((64L << 20 + 1), config1));
		assertEquals(enforceBounds((long) (defaultFrac * (10L << 30)), defaultMin, newMax),
			TaskManagerServices.calculateNetworkBufferMemory((10L << 30), config1));
		assertTrue(TaskManagerServicesConfiguration.hasNewNetworkBufConf(config1));
		calculateNetworkBufNew(config);
	}
@ SuppressWarnings ( "deprecation" ) @ Test public void calculateNetworkBufMixed ( ) throws Exception { Configuration config = new Configuration ( ) ; config . setInteger ( TaskManagerOptions . NETWORK_NUM_BUFFERS , 1 ) ; final Float defaultFrac = TaskManagerOptions . NETWORK_BUFFERS_MEMORY_FRACTION . defaultValue ( ) ; final Long defaultMin = TaskManagerOptions . NETWORK_BUFFERS_MEMORY_MIN . defaultValue ( ) ; final Long defaultMax = TaskManagerOptions . NETWORK_BUFFERS_MEMORY_MAX . defaultValue ( ) ; Configuration config1 = config . clone ( ) ; config1 . setFloat ( TaskManagerOptions . NETWORK_BUFFERS_MEMORY_FRACTION , 0.1f ) ; assertEquals ( enforceBounds ( ( long ) ( 0.1f * ( 10L << 20 ) ) , defaultMin , defaultMax ) , TaskManagerServices . calculateNetworkBufferMemory ( ( 64L << 20 + 1 ) , config1 ) ) ; assertEquals ( enforceBounds ( ( long ) ( 0.1f * ( 10L << 30 ) ) , defaultMin , defaultMax ) , TaskManagerServices . calculateNetworkBufferMemory ( ( 10L << 30 ) , config1 ) ) ; config1 = config . clone ( ) ; long newMin = TaskManagerOptions . MEMORY_SEGMENT_SIZE . defaultValue ( ) ; config1 . setLong ( TaskManagerOptions . NETWORK_BUFFERS_MEMORY_MIN , newMin ) ; assertEquals ( enforceBounds ( ( long ) ( defaultFrac * ( 10L << 20 ) ) , newMin , defaultMax ) , TaskManagerServices . calculateNetworkBufferMemory ( ( 10L << 20 ) , config1 ) ) ; assertEquals ( enforceBounds ( ( long ) ( defaultFrac * ( 10L << 30 ) ) , newMin , defaultMax ) , TaskManagerServices . calculateNetworkBufferMemory ( ( 10L << 30 ) , config1 ) ) ; config1 = config . clone ( ) ; long newMax = Math . max ( 64L << 20 + 1 , TaskManagerOptions . NETWORK_BUFFERS_MEMORY_MIN . defaultValue ( ) ) ; config1 . setLong ( TaskManagerOptions . NETWORK_BUFFERS_MEMORY_MAX , newMax ) ; assertEquals ( enforceBounds ( ( long ) ( defaultFrac * ( 10L << 20 ) ) , defaultMin , newMax ) , TaskManagerServices . calculateNetworkBufferMemory ( ( 64L << 20 + 1 ) , config1 ) ) ; assertEquals ( enforceBounds ( ( long ) ( defaultFrac * ( 10L << 30 ) ) , defaultMin , newMax ) , TaskManagerServices . calculateNetworkBufferMemory ( ( 10L << 30 ) , config1 ) ) ; assertTrue ( TaskManagerServicesConfiguration . hasNewNetworkBufConf ( config1 ) ) ; calculateNetworkBufNew ( config ) ; }
Test for {@link TaskManagerServices#calculateNetworkBufferMemory(long, Configuration)} using mixed
 old/new configurations.
Test for { @link TaskManagerServices#calculateNetworkBufferMemory ( long Configuration ) } using mixed old / new configurations .
// old + 1 new parameter = new: // smallest value possible // old + any new parameter = new: