flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From NicoK <...@git.apache.org>
Subject [GitHub] flink pull request #4581: [FLINK-7499][io] fix double buffer release in Spil...
Date Thu, 23 Nov 2017 17:20:47 GMT
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4581#discussion_r152850290
  
    --- Diff: flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/SpillableSubpartitionTest.java
---
    @@ -320,4 +559,40 @@ void awaitNotifications(long awaitedNumNotifiedBuffers, long timeoutMillis)
thro
     			}
     		}
     	}
    +
    +	/**
    +	 * An {@link IOManagerAsync} that creates closed {@link BufferFileWriter} instances
in its
    +	 * {@link #createBufferFileWriter(FileIOChannel.ID)} method.
    +	 *
    +	 * <p>These {@link BufferFileWriter} objects will thus throw an exception when
trying to add
    +	 * write requests, e.g. by calling {@link BufferFileWriter#writeBlock(Object)}.
    +	 */
    +	private static class IOManagerAsyncWithClosedBufferFileWriter extends IOManagerAsync
{
    +		@Override
    +		public BufferFileWriter createBufferFileWriter(FileIOChannel.ID channelID)
    +				throws IOException {
    +			BufferFileWriter bufferFileWriter = super.createBufferFileWriter(channelID);
    +			bufferFileWriter.close();
    +			return bufferFileWriter;
    +		}
    +	}
    +
    +	/**
    +	 * An {@link IOManagerAsync} that creates stalling {@link BufferFileWriter} instances
in its
    +	 * {@link #createBufferFileWriter(FileIOChannel.ID)} method.
    +	 *
    +	 * <p>These {@link BufferFileWriter} objects will accept {@link BufferFileWriter#writeBlock(Object)}
    +	 * requests but never actually perform any write operation (be sure to clean up the
buffers
    +	 * manually!).
    +	 */
    +	private static class IOManagerAsyncWithStallingBufferFileWriter extends IOManagerAsync
{
    +		@Override
    +		public BufferFileWriter createBufferFileWriter(FileIOChannel.ID channelID)
    +			throws IOException {
    +			BufferFileWriter bufferFileWriter = spy(super.createBufferFileWriter(channelID));
    --- End diff --
    
    In theory, you are right - in practice though (and that's what I tried first), `AsynchronousBufferFileWriter`
cannot be extended from anywhere outside its package due to `WriteRequest` being package-private.
Since the writer implementations I needed are not too generic, I did not want to promote them
to this package (in the tests folder, of course) nor did I want to make `WriteRequest` public...hence
Mockito.


---

Mime
View raw message