Search in sources :

Example 11 with FullJitterBackoff

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));
}
Also used : LimitExceededException(software.amazon.awssdk.services.kinesis.model.LimitExceededException) SubscriptionErrorKinesisV2(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2) FullJitterBackoff(org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff) TestConsumer(org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer) Test(org.junit.Test)

Example 12 with FullJitterBackoff

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);
}
Also used : LimitExceededException(software.amazon.awssdk.services.kinesis.model.LimitExceededException) SubscriptionErrorKinesisV2(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2) FullJitterBackoff(org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff) TestConsumer(org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer) Test(org.junit.Test)

Example 13 with FullJitterBackoff

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));
}
Also used : SubscriptionErrorKinesisV2(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2) FullJitterBackoff(org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff) TestConsumer(org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer) Test(org.junit.Test)

Example 14 with FullJitterBackoff

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));
    }
}
Also used : StreamConsumerFakeKinesis(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.StreamConsumerFakeKinesis) FullJitterBackoff(org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff) Test(org.junit.Test)

Example 15 with FullJitterBackoff

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);
}
Also used : KinesisProxyV2Interface(org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface) FullJitterBackoff(org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff) Test(org.junit.Test)

Aggregations

FullJitterBackoff (org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff)16 Test (org.junit.Test)14 KinesisProxyV2Interface (org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface)6 SubscriptionErrorKinesisV2 (org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2)5 TestConsumer (org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer)5 StreamConsumerFakeKinesis (org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.StreamConsumerFakeKinesis)4 Properties (java.util.Properties)3 LimitExceededException (software.amazon.awssdk.services.kinesis.model.LimitExceededException)3 ReadTimeoutException (io.netty.handler.timeout.ReadTimeoutException)1 FanOutRecordPublisherConfiguration (org.apache.flink.streaming.connectors.kinesis.internals.publisher.fanout.FanOutRecordPublisherConfiguration)1 StreamConsumerRegistrar (org.apache.flink.streaming.connectors.kinesis.internals.publisher.fanout.StreamConsumerRegistrar)1 FakeKinesisFanOutBehavioursFactory (org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory)1