flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/SpillableSubpartitionTest.java
/**
	 * Tests {@link SpillableSubpartition#add(Buffer)} with a finished partition.
	 *
	 * @param spilled
	 * 		whether the partition should be spilled to disk (<tt>true</tt>) or not (<tt>false</tt>,
	 * 		spillable).
	 */
Tests  SpillableSubpartition#add(Buffer) with a finished partition.
@param spilled
whether the partition should be spilled to disk (true) or not (false,
spillable).
Tests SpillableSubpartition#add ( Buffer ) with a finished partition . @param spilled whether the partition should be spilled to disk ( true ) or not ( false spillable ) .
private void testAddOnFinishedPartition(boolean spilled) throws Exception {
		SpillableSubpartition partition = createSubpartition();
		if (spilled) {
			assertEquals(0, partition.releaseMemory());
		}
		partition.finish();
		assertEquals(1, partition.getTotalNumberOfBuffers());
		assertEquals(4, partition.getTotalNumberOfBytes());
		Buffer buffer = new Buffer(MemorySegmentFactory.allocateUnpooledSegment(4096),
			FreeingBufferRecycler.INSTANCE);
		try {
			partition.add(buffer);
		} finally {
			if (!buffer.isRecycled()) {
				buffer.recycle();
				Assert.fail("buffer not recycled");
			}
			assertEquals(1, partition.getTotalNumberOfBuffers());
			assertEquals(4, partition.getTotalNumberOfBytes());
		}
	}
private void testAddOnFinishedPartition ( boolean spilled ) throws Exception { SpillableSubpartition partition = createSubpartition ( ) ; if ( spilled ) { assertEquals ( 0 , partition . releaseMemory ( ) ) ; } partition . finish ( ) ; assertEquals ( 1 , partition . getTotalNumberOfBuffers ( ) ) ; assertEquals ( 4 , partition . getTotalNumberOfBytes ( ) ) ; Buffer buffer = new Buffer ( MemorySegmentFactory . allocateUnpooledSegment ( 4096 ) , FreeingBufferRecycler . INSTANCE ) ; try { partition . add ( buffer ) ; } finally { if ( ! buffer . isRecycled ( ) ) { buffer . recycle ( ) ; Assert . fail ( "buffer not recycled" ) ; } assertEquals ( 1 , partition . getTotalNumberOfBuffers ( ) ) ; assertEquals ( 4 , partition . getTotalNumberOfBytes ( ) ) ; } }
Tests {@link SpillableSubpartition#add(Buffer)} with a finished partition.
Tests { @link SpillableSubpartition#add ( Buffer ) } with a finished partition .
// finish adds an EndOfPartitionEvent // still same statistics