Search in sources :

Example 6 with FullJitterBackoff

use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.

the class StreamConsumerRegistrarTest method testRegistrationBackoffForLazy.

@Test
public void testRegistrationBackoffForLazy() throws Exception {
    FullJitterBackoff backoff = mock(FullJitterBackoff.class);
    KinesisProxyV2Interface kinesis = FakeKinesisFanOutBehavioursFactory.existingActiveConsumer();
    Properties efoProperties = createEfoProperties();
    efoProperties.setProperty(EFO_REGISTRATION_TYPE, LAZY.name());
    FanOutRecordPublisherConfiguration configuration = new FanOutRecordPublisherConfiguration(efoProperties, emptyList());
    StreamConsumerRegistrar registrar = new StreamConsumerRegistrar(kinesis, configuration, backoff);
    String result = registrar.registerStreamConsumer(STREAM, "name");
    verify(backoff).sleep(anyLong());
    assertEquals(STREAM_CONSUMER_ARN_EXISTING, result);
}
Also used : KinesisProxyV2Interface(org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface) Properties(java.util.Properties) FullJitterBackoff(org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff) Test(org.junit.Test)

Example 7 with FullJitterBackoff

use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.

the class StreamConsumerRegistrarTest method testDeregisterStreamConsumerNotFound.

@Test
public void testDeregisterStreamConsumerNotFound() throws Exception {
    FullJitterBackoff backoff = mock(FullJitterBackoff.class);
    StreamConsumerFakeKinesis kinesis = FakeKinesisFanOutBehavioursFactory.streamConsumerNotFound();
    StreamConsumerRegistrar registrar = createRegistrar(kinesis, backoff);
    registrar.deregisterStreamConsumer(STREAM);
    assertEquals(1, kinesis.getNumberOfDescribeStreamConsumerInvocations());
}
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 8 with FullJitterBackoff

use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.

the class StreamConsumerRegistrarTest method testDeregistrationBackoff.

@Test
public void testDeregistrationBackoff() 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.deregistrationBackoff(configuration, backoff, 11);
    verify(backoff).sleep(5);
    verify(backoff).calculateFullJitterBackoff(EXPECTED_DEREGISTRATION_BASE, EXPECTED_DEREGISTRATION_MAX, EXPECTED_DEREGISTRATION_POW, 11);
}
Also used : KinesisProxyV2Interface(org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface) FullJitterBackoff(org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff) Test(org.junit.Test)

Example 9 with FullJitterBackoff

use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.

the class StreamConsumerRegistrarTest method backoffFor.

private FullJitterBackoff backoffFor(final long millisToBackoffFor) {
    FullJitterBackoff backoff = spy(new FullJitterBackoff());
    when(backoff.calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), anyInt())).thenReturn(millisToBackoffFor);
    return backoff;
}
Also used : FullJitterBackoff(org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff)

Example 10 with FullJitterBackoff

use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.

the class FanOutRecordPublisherTest method testSubscribeToShardFailsWhenMaxRetriesExceeded.

@Test
public void testSubscribeToShardFailsWhenMaxRetriesExceeded() throws Exception {
    thrown.expect(RuntimeException.class);
    thrown.expectMessage("Maximum retries exceeded for SubscribeToShard. Failed 3 times.");
    Properties efoProperties = createEfoProperties();
    efoProperties.setProperty(SUBSCRIBE_TO_SHARD_RETRIES, String.valueOf(EXPECTED_SUBSCRIBE_TO_SHARD_RETRIES));
    FanOutRecordPublisherConfiguration configuration = new FanOutRecordPublisherConfiguration(efoProperties, emptyList());
    LimitExceededException retryableError = LimitExceededException.builder().build();
    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()) == INCOMPLETE) {
        if (++count > EXPECTED_SUBSCRIBE_TO_SHARD_RETRIES) {
            break;
        }
    }
}
Also used : LimitExceededException(software.amazon.awssdk.services.kinesis.model.LimitExceededException) Properties(java.util.Properties) 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)

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