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);
}
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) {
}
}
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) {
}
}
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;
}
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) {
}
}
Aggregations