use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.
the class FanOutRecordPublisherTest method testSubscribeToShardBacksOffAttemptIncreases.
@Test
public void testSubscribeToShardBacksOffAttemptIncreases() throws Exception {
LimitExceededException retryableError = LimitExceededException.builder().build();
SubscriptionErrorKinesisV2 kinesis = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(retryableError);
FanOutRecordPublisherConfiguration configuration = createConfiguration();
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
FanOutRecordPublisher recordPublisher = new FanOutRecordPublisher(latest(), "arn", createDummyStreamShardHandle(), kinesis, configuration, backoff);
recordPublisher.run(new TestConsumer());
recordPublisher.run(new TestConsumer());
recordPublisher.run(new TestConsumer());
verify(backoff).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), eq(1));
verify(backoff).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), eq(2));
verify(backoff).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), eq(3));
verify(backoff, never()).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), eq(0));
verify(backoff, never()).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), eq(4));
}
use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.
the class FanOutRecordPublisherTest method testSubscribeToShardBacksOffForRetryableError.
@Test
public void testSubscribeToShardBacksOffForRetryableError() throws Exception {
LimitExceededException retryableError = LimitExceededException.builder().build();
SubscriptionErrorKinesisV2 kinesis = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(retryableError);
FanOutRecordPublisherConfiguration configuration = createConfiguration();
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
when(backoff.calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), anyInt())).thenReturn(100L);
new FanOutRecordPublisher(latest(), "arn", createDummyStreamShardHandle(), kinesis, configuration, backoff).run(new TestConsumer());
verify(backoff).calculateFullJitterBackoff(EXPECTED_SUBSCRIBE_TO_SHARD_BASE, EXPECTED_SUBSCRIBE_TO_SHARD_MAX, EXPECTED_SUBSCRIBE_TO_SHARD_POW, 1);
verify(backoff).sleep(100L);
}
use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.
the class FanOutRecordPublisherTest method testBackOffAttemptResetsWithSuccessfulSubscription.
@Test
public void testBackOffAttemptResetsWithSuccessfulSubscription() throws Exception {
SubscriptionErrorKinesisV2 kinesis = FakeKinesisFanOutBehavioursFactory.alternatingSuccessErrorDuringSubscription();
FanOutRecordPublisherConfiguration configuration = createConfiguration();
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
FanOutRecordPublisher recordPublisher = new FanOutRecordPublisher(latest(), "arn", createDummyStreamShardHandle(), kinesis, configuration, backoff);
recordPublisher.run(new TestConsumer());
recordPublisher.run(new TestConsumer());
recordPublisher.run(new TestConsumer());
// Expecting:
// - first attempt to fail, and backoff attempt #1
// - second attempt to succeed, and reset attempt index
// - third attempt to fail, and backoff attempt #1
verify(backoff, times(2)).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), eq(1));
verify(backoff, never()).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), eq(0));
verify(backoff, never()).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), eq(2));
}
use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.
the class StreamConsumerRegistrarTest method testDeregisterStreamConsumerAndWaitForDeletingStatus.
@Test
public void testDeregisterStreamConsumerAndWaitForDeletingStatus() throws Exception {
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
StreamConsumerFakeKinesis kinesis = FakeKinesisFanOutBehavioursFactory.existingActiveConsumer();
StreamConsumerRegistrar registrar = createRegistrar(kinesis, backoff);
registrar.deregisterStreamConsumer(STREAM);
// We will invoke describe stream until the stream consumer is in the DELETING state
assertEquals(2, kinesis.getNumberOfDescribeStreamConsumerInvocations());
for (int i = 1; i < 2; 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 testRegisterStreamConsumerThatAlreadyExistsAndActive.
@Test
public void testRegisterStreamConsumerThatAlreadyExistsAndActive() throws Exception {
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
KinesisProxyV2Interface kinesis = FakeKinesisFanOutBehavioursFactory.existingActiveConsumer();
StreamConsumerRegistrar registrar = createRegistrar(kinesis, backoff);
String result = registrar.registerStreamConsumer(STREAM, "name");
verify(backoff, never()).sleep(anyLong());
assertEquals(STREAM_CONSUMER_ARN_EXISTING, result);
}
Aggregations