Search in sources :

Example 1 with RoundRobinChannelSelector

use of org.apache.flink.runtime.io.network.api.writer.RoundRobinChannelSelector in project flink by apache.

the class StreamRecordWriterTest method testPropagateAsyncFlushError.

/**
	 * Verifies that exceptions during flush from the output flush thread are
	 * recognized in the writer.
	 */
@Test
public void testPropagateAsyncFlushError() {
    FailingWriter<LongValue> testWriter = null;
    try {
        ResultPartitionWriter mockResultPartitionWriter = getMockWriter(5);
        // test writer that flushes every 5ms and fails after 3 flushes
        testWriter = new FailingWriter<LongValue>(mockResultPartitionWriter, new RoundRobinChannelSelector<LongValue>(), 5, 3);
        try {
            // in max 20 seconds (conservative)
            long deadline = System.currentTimeMillis() + 20000;
            long l = 0L;
            while (System.currentTimeMillis() < deadline) {
                testWriter.emit(new LongValue(l++));
            }
            fail("This should have failed with an exception");
        } catch (IOException e) {
            assertNotNull(e.getCause());
            assertTrue(e.getCause().getMessage().contains("Test Exception"));
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    } finally {
        if (testWriter != null) {
            testWriter.close();
        }
    }
}
Also used : ResultPartitionWriter(org.apache.flink.runtime.io.network.api.writer.ResultPartitionWriter) LongValue(org.apache.flink.types.LongValue) RoundRobinChannelSelector(org.apache.flink.runtime.io.network.api.writer.RoundRobinChannelSelector) IOException(java.io.IOException) IOException(java.io.IOException) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with RoundRobinChannelSelector

use of org.apache.flink.runtime.io.network.api.writer.RoundRobinChannelSelector in project flink by apache.

the class DefaultChannelSelectorTest method channelSelect.

/**
 * This test checks the channel selection.
 */
@Test
public void channelSelect() {
    final StringValue dummyRecord = new StringValue("abc");
    final RoundRobinChannelSelector<StringValue> selector = new RoundRobinChannelSelector<>();
    selector.setup(2);
    assertSelectedChannel(selector, dummyRecord, 0);
    assertSelectedChannel(selector, dummyRecord, 1);
}
Also used : RoundRobinChannelSelector(org.apache.flink.runtime.io.network.api.writer.RoundRobinChannelSelector) StringValue(org.apache.flink.types.StringValue) Test(org.junit.Test)

Aggregations

RoundRobinChannelSelector (org.apache.flink.runtime.io.network.api.writer.RoundRobinChannelSelector)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 ResultPartitionWriter (org.apache.flink.runtime.io.network.api.writer.ResultPartitionWriter)1 LongValue (org.apache.flink.types.LongValue)1 StringValue (org.apache.flink.types.StringValue)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1