use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.
the class FanOutRecordPublisherTest method testSubscribeToShardIgnoresReadTimeoutInRetryPolicy.
@Test
public void testSubscribeToShardIgnoresReadTimeoutInRetryPolicy() throws Exception {
Properties efoProperties = createEfoProperties();
efoProperties.setProperty(SUBSCRIBE_TO_SHARD_RETRIES, String.valueOf(EXPECTED_SUBSCRIBE_TO_SHARD_RETRIES));
FanOutRecordPublisherConfiguration configuration = new FanOutRecordPublisherConfiguration(efoProperties, emptyList());
ReadTimeoutException retryableError = ReadTimeoutException.INSTANCE;
FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2 kinesis = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(retryableError);
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
FanOutRecordPublisher recordPublisher = new FanOutRecordPublisher(latest(), "arn", createDummyStreamShardHandle(), kinesis, configuration, backoff);
int count = 0;
while (recordPublisher.run(new TestConsumer()) == RecordPublisherRunResult.INCOMPLETE) {
if (++count > EXPECTED_SUBSCRIBE_TO_SHARD_RETRIES) {
break;
}
}
// No exception is thrown, but we still backoff.
verify(backoff, times(EXPECTED_SUBSCRIBE_TO_SHARD_RETRIES + 1)).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), anyInt());
}
use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.
the class StreamConsumerRegistrarTest method testRegisterStreamConsumerWaitsForConsumerToBecomeActive.
@Test
public void testRegisterStreamConsumerWaitsForConsumerToBecomeActive() throws Exception {
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
StreamConsumerFakeKinesis kinesis = FakeKinesisFanOutBehavioursFactory.registerExistingConsumerAndWaitToBecomeActive();
StreamConsumerRegistrar registrar = createRegistrar(kinesis, backoff);
String result = registrar.registerStreamConsumer(STREAM, "name");
// we backoff on each retry
verify(backoff, times(NUMBER_OF_DESCRIBE_REQUESTS_TO_ACTIVATE - 1)).sleep(anyLong());
assertEquals(STREAM_CONSUMER_ARN_EXISTING, result);
// We will invoke describe stream until the stream consumer is activated
assertEquals(NUMBER_OF_DESCRIBE_REQUESTS_TO_ACTIVATE, kinesis.getNumberOfDescribeStreamConsumerInvocations());
for (int i = 1; i < NUMBER_OF_DESCRIBE_REQUESTS_TO_ACTIVATE; i++) {
verify(backoff).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), eq(i));
}
}
use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.
the class StreamConsumerRegistrarTest method testRegisterStreamConsumerRegistersNewStreamConsumer.
@Test
public void testRegisterStreamConsumerRegistersNewStreamConsumer() throws Exception {
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
KinesisProxyV2Interface kinesis = FakeKinesisFanOutBehavioursFactory.streamConsumerNotFound();
StreamConsumerRegistrar registrar = createRegistrar(kinesis, backoff);
String result = registrar.registerStreamConsumer(STREAM, "name");
assertEquals(STREAM_CONSUMER_ARN_NEW, result);
}
use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.
the class StreamConsumerRegistrarTest method testDeregisterStreamConsumerArnNotFound.
@Test
public void testDeregisterStreamConsumerArnNotFound() throws Exception {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Stream consumer ARN not found for stream: not-found");
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
StreamConsumerFakeKinesis kinesis = FakeKinesisFanOutBehavioursFactory.streamConsumerNotFound();
StreamConsumerRegistrar registrar = createRegistrar(kinesis, backoff);
registrar.deregisterStreamConsumer("not-found");
}
use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.
the class StreamConsumerRegistrarTest method testRegistrationBackoff.
@Test
public void testRegistrationBackoff() throws Exception {
FanOutRecordPublisherConfiguration configuration = createConfiguration();
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
when(backoff.calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), anyInt())).thenReturn(5L);
StreamConsumerRegistrar registrar = new StreamConsumerRegistrar(mock(KinesisProxyV2Interface.class), configuration, backoff);
registrar.registrationBackoff(configuration, backoff, 10);
verify(backoff).sleep(5);
verify(backoff).calculateFullJitterBackoff(EXPECTED_REGISTRATION_BASE, EXPECTED_REGISTRATION_MAX, EXPECTED_REGISTRATION_POW, 10);
}
Aggregations