Search in sources :

Example 1 with PartitionRequestClient

use of org.apache.flink.runtime.io.network.netty.PartitionRequestClient in project flink by apache.

the class RemoteInputChannelTest method testRetriggerWithoutPartitionRequest.

@Test(expected = IllegalStateException.class)
public void testRetriggerWithoutPartitionRequest() throws Exception {
    Tuple2<Integer, Integer> backoff = new Tuple2<Integer, Integer>(500, 3000);
    PartitionRequestClient connClient = mock(PartitionRequestClient.class);
    SingleInputGate inputGate = mock(SingleInputGate.class);
    RemoteInputChannel ch = createRemoteInputChannel(inputGate, connClient, backoff);
    ch.retriggerSubpartitionRequest(0);
}
Also used : Tuple2(scala.Tuple2) PartitionRequestClient(org.apache.flink.runtime.io.network.netty.PartitionRequestClient) Test(org.junit.Test)

Example 2 with PartitionRequestClient

use of org.apache.flink.runtime.io.network.netty.PartitionRequestClient in project flink by apache.

the class RemoteInputChannelTest method testPartitionRequestSingleBackoff.

@Test
public void testPartitionRequestSingleBackoff() throws Exception {
    // Config
    Tuple2<Integer, Integer> backoff = new Tuple2<Integer, Integer>(500, 500);
    // Setup
    PartitionRequestClient connClient = mock(PartitionRequestClient.class);
    SingleInputGate inputGate = mock(SingleInputGate.class);
    RemoteInputChannel ch = createRemoteInputChannel(inputGate, connClient, backoff);
    // No delay for first request
    ch.requestSubpartition(0);
    verify(connClient).requestSubpartition(eq(ch.partitionId), eq(0), eq(ch), eq(0));
    // Initial delay for second request
    ch.retriggerSubpartitionRequest(0);
    verify(connClient).requestSubpartition(eq(ch.partitionId), eq(0), eq(ch), eq(backoff._1()));
    // Exception after backoff is greater than the maximum backoff.
    try {
        ch.retriggerSubpartitionRequest(0);
        ch.getNextBuffer();
        fail("Did not throw expected exception.");
    } catch (Exception expected) {
    }
}
Also used : Tuple2(scala.Tuple2) PartitionRequestClient(org.apache.flink.runtime.io.network.netty.PartitionRequestClient) ProducerFailedException(org.apache.flink.runtime.io.network.partition.ProducerFailedException) CancelTaskException(org.apache.flink.runtime.execution.CancelTaskException) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with PartitionRequestClient

use of org.apache.flink.runtime.io.network.netty.PartitionRequestClient in project flink by apache.

the class RemoteInputChannelTest method testPartitionRequestNoBackoff.

@Test
public void testPartitionRequestNoBackoff() throws Exception {
    // Config
    Tuple2<Integer, Integer> backoff = new Tuple2<Integer, Integer>(0, 0);
    // Setup
    PartitionRequestClient connClient = mock(PartitionRequestClient.class);
    SingleInputGate inputGate = mock(SingleInputGate.class);
    RemoteInputChannel ch = createRemoteInputChannel(inputGate, connClient, backoff);
    // No delay for first request
    ch.requestSubpartition(0);
    verify(connClient).requestSubpartition(eq(ch.partitionId), eq(0), eq(ch), eq(0));
    // Exception, because backoff is disabled.
    try {
        ch.retriggerSubpartitionRequest(0);
        ch.getNextBuffer();
        fail("Did not throw expected exception.");
    } catch (Exception expected) {
    }
}
Also used : Tuple2(scala.Tuple2) PartitionRequestClient(org.apache.flink.runtime.io.network.netty.PartitionRequestClient) ProducerFailedException(org.apache.flink.runtime.io.network.partition.ProducerFailedException) CancelTaskException(org.apache.flink.runtime.execution.CancelTaskException) IOException(java.io.IOException) Test(org.junit.Test)

Example 4 with PartitionRequestClient

use of org.apache.flink.runtime.io.network.netty.PartitionRequestClient in project flink by apache.

the class InputChannelTestUtils method createDummyConnectionManager.

public static ConnectionManager createDummyConnectionManager() throws Exception {
    final PartitionRequestClient mockClient = mock(PartitionRequestClient.class);
    final ConnectionManager connManager = mock(ConnectionManager.class);
    when(connManager.createPartitionRequestClient(any(ConnectionID.class))).thenReturn(mockClient);
    return connManager;
}
Also used : ConnectionID(org.apache.flink.runtime.io.network.ConnectionID) ConnectionManager(org.apache.flink.runtime.io.network.ConnectionManager) PartitionRequestClient(org.apache.flink.runtime.io.network.netty.PartitionRequestClient)

Example 5 with PartitionRequestClient

use of org.apache.flink.runtime.io.network.netty.PartitionRequestClient in project flink by apache.

the class RemoteInputChannelTest method testPartitionRequestExponentialBackoff.

@Test
public void testPartitionRequestExponentialBackoff() throws Exception {
    // Config
    Tuple2<Integer, Integer> backoff = new Tuple2<Integer, Integer>(500, 3000);
    // Start with initial backoff, then keep doubling, and cap at max.
    int[] expectedDelays = { backoff._1(), 1000, 2000, backoff._2() };
    // Setup
    PartitionRequestClient connClient = mock(PartitionRequestClient.class);
    SingleInputGate inputGate = mock(SingleInputGate.class);
    RemoteInputChannel ch = createRemoteInputChannel(inputGate, connClient, backoff);
    // Initial request
    ch.requestSubpartition(0);
    verify(connClient).requestSubpartition(eq(ch.partitionId), eq(0), eq(ch), eq(0));
    // Request subpartition and verify that the actual requests are delayed.
    for (int expected : expectedDelays) {
        ch.retriggerSubpartitionRequest(0);
        verify(connClient).requestSubpartition(eq(ch.partitionId), eq(0), eq(ch), eq(expected));
    }
    // Exception after backoff is greater than the maximum backoff.
    try {
        ch.retriggerSubpartitionRequest(0);
        ch.getNextBuffer();
        fail("Did not throw expected exception.");
    } catch (Exception expected) {
    }
}
Also used : Tuple2(scala.Tuple2) PartitionRequestClient(org.apache.flink.runtime.io.network.netty.PartitionRequestClient) ProducerFailedException(org.apache.flink.runtime.io.network.partition.ProducerFailedException) CancelTaskException(org.apache.flink.runtime.execution.CancelTaskException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

PartitionRequestClient (org.apache.flink.runtime.io.network.netty.PartitionRequestClient)5 Test (org.junit.Test)4 Tuple2 (scala.Tuple2)4 IOException (java.io.IOException)3 CancelTaskException (org.apache.flink.runtime.execution.CancelTaskException)3 ProducerFailedException (org.apache.flink.runtime.io.network.partition.ProducerFailedException)3 ConnectionID (org.apache.flink.runtime.io.network.ConnectionID)1 ConnectionManager (org.apache.flink.runtime.io.network.ConnectionManager)1