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 spilled partition where adding the
	 * write request fails with an exception.
	 */
Tests  SpillableSubpartition#add(Buffer) with a spilled partition where adding the
write request fails with an exception.
Tests SpillableSubpartition#add ( Buffer ) with a spilled partition where adding the write request fails with an exception .
@Test
	public void testAddOnSpilledPartitionWithSlowWriter() throws Exception {
		IOManager ioManager = new IOManagerAsyncWithNoOpBufferFileWriter();
		SpillableSubpartition partition = createSubpartition(ioManager);
		assertEquals(0, partition.releaseMemory());
		Buffer buffer = new Buffer(MemorySegmentFactory.allocateUnpooledSegment(4096),
			FreeingBufferRecycler.INSTANCE);
		try {
			partition.add(buffer);
		} finally {
			ioManager.shutdown();
			if (buffer.isRecycled()) {
				Assert.fail("buffer recycled before the write operation completed");
			}
			buffer.recycle();
			assertEquals(1, partition.getTotalNumberOfBuffers());
			assertEquals(4096, partition.getTotalNumberOfBytes());
		}
	}
@ Test public void testAddOnSpilledPartitionWithSlowWriter ( ) throws Exception { IOManager ioManager = new IOManagerAsyncWithNoOpBufferFileWriter ( ) ; SpillableSubpartition partition = createSubpartition ( ioManager ) ; assertEquals ( 0 , partition . releaseMemory ( ) ) ; Buffer buffer = new Buffer ( MemorySegmentFactory . allocateUnpooledSegment ( 4096 ) , FreeingBufferRecycler . INSTANCE ) ; try { partition . add ( buffer ) ; } finally { ioManager . shutdown ( ) ; if ( buffer . isRecycled ( ) ) { Assert . fail ( "buffer recycled before the write operation completed" ) ; } buffer . recycle ( ) ; assertEquals ( 1 , partition . getTotalNumberOfBuffers ( ) ) ; assertEquals ( 4096 , partition . getTotalNumberOfBytes ( ) ) ; } }
Tests {@link SpillableSubpartition#add(Buffer)} with a spilled partition where adding the
 write request fails with an exception.
Tests { @link SpillableSubpartition#add ( Buffer ) } with a spilled partition where adding the write request fails with an exception .
// simulate slow writer by a no-op write operation