Search in sources :

Example 6 with KinesisProxyV2Interface

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

the class StreamConsumerRegistrarTest method testStreamNotFoundWhenRegisteringThrowsException.

@Test
public void testStreamNotFoundWhenRegisteringThrowsException() throws Exception {
    thrown.expect(ResourceNotFoundException.class);
    KinesisProxyV2Interface kinesis = FakeKinesisFanOutBehavioursFactory.streamNotFound();
    StreamConsumerRegistrar registrar = createRegistrar(kinesis, mock(FullJitterBackoff.class));
    registrar.registerStreamConsumer(STREAM, "name");
}
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 7 with KinesisProxyV2Interface

use of org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface 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 8 with KinesisProxyV2Interface

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

the class ShardConsumerFanOutTest method testShardConsumerRetriesGenericSdkError.

@Test
public void testShardConsumerRetriesGenericSdkError() throws Exception {
    // Throws error after 5 records and there are 25 records available in the shard
    KinesisProxyV2Interface kinesis = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(new SdkClientException(""));
    int expectedNumberOfRecordsReadFromKinesisBeforeError = 25;
    SequenceNumber startingSequenceNumber = new SequenceNumber("0");
    Properties properties = efoProperties();
    // Speed up test by reducing backoff time
    properties.setProperty(SUBSCRIBE_TO_SHARD_BACKOFF_MAX, "1");
    // SdkClientException will cause a retry, each retry will result in 5 more records being
    // consumed
    // The shard will consume all 25 records
    assertNumberOfMessagesReceivedFromKinesis(expectedNumberOfRecordsReadFromKinesisBeforeError, kinesis, startingSequenceNumber, properties);
}
Also used : SdkClientException(com.amazonaws.SdkClientException) ShardConsumerTestUtils.fakeSequenceNumber(org.apache.flink.streaming.connectors.kinesis.internals.ShardConsumerTestUtils.fakeSequenceNumber) SequenceNumber(org.apache.flink.streaming.connectors.kinesis.model.SequenceNumber) KinesisProxyV2Interface(org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface) TestUtils.efoProperties(org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.efoProperties) Properties(java.util.Properties) Test(org.junit.Test)

Example 9 with KinesisProxyV2Interface

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

the class ShardConsumerFanOutTest method testShardConsumerExitsWhenRecordPublisherIsInterrupted.

@Test
public void testShardConsumerExitsWhenRecordPublisherIsInterrupted() throws Exception {
    // Throws error after 5 records
    KinesisProxyV2Interface kinesis = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(new SdkInterruptedException(null));
    int expectedNumberOfRecordsReadFromKinesisBeforeError = 5;
    SequenceNumber startingSequenceNumber = new SequenceNumber("0");
    SequenceNumber expectedLastProcessSequenceNumber = new SequenceNumber("5");
    // SdkInterruptedException will terminate the consumer, it will not retry and read only the
    // first 5 records
    ShardConsumerTestUtils.assertNumberOfMessagesReceivedFromKinesis(expectedNumberOfRecordsReadFromKinesisBeforeError, new FanOutRecordPublisherFactory(kinesis), startingSequenceNumber, efoProperties(), expectedLastProcessSequenceNumber);
}
Also used : SdkInterruptedException(com.amazonaws.http.timers.client.SdkInterruptedException) ShardConsumerTestUtils.fakeSequenceNumber(org.apache.flink.streaming.connectors.kinesis.internals.ShardConsumerTestUtils.fakeSequenceNumber) SequenceNumber(org.apache.flink.streaming.connectors.kinesis.model.SequenceNumber) FanOutRecordPublisherFactory(org.apache.flink.streaming.connectors.kinesis.internals.publisher.fanout.FanOutRecordPublisherFactory) KinesisProxyV2Interface(org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface) Test(org.junit.Test)

Example 10 with KinesisProxyV2Interface

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

the class FanOutShardSubscriberTest method testTimeoutSubscribingToShard.

@Test
public void testTimeoutSubscribingToShard() throws Exception {
    thrown.expect(FanOutShardSubscriber.RecoverableFanOutSubscriberException.class);
    thrown.expectMessage("Timed out acquiring subscription");
    KinesisProxyV2Interface kinesis = FakeKinesisFanOutBehavioursFactory.failsToAcquireSubscription();
    FanOutShardSubscriber subscriber = new FanOutShardSubscriber("consumerArn", "shardId", kinesis, Duration.ofMillis(1));
    StartingPosition startingPosition = StartingPosition.builder().build();
    subscriber.subscribeToShardAndConsumeRecords(startingPosition, event -> {
    });
}
Also used : StartingPosition(software.amazon.awssdk.services.kinesis.model.StartingPosition) KinesisProxyV2Interface(org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface) Test(org.junit.Test)

Aggregations

KinesisProxyV2Interface (org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface)15 Test (org.junit.Test)14 FullJitterBackoff (org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff)6 SdkInterruptedException (com.amazonaws.http.timers.client.SdkInterruptedException)3 RecordPublisher (org.apache.flink.streaming.connectors.kinesis.internals.publisher.RecordPublisher)3 TestConsumer (org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer)3 Properties (java.util.Properties)2 SimpleStringSchema (org.apache.flink.api.common.serialization.SimpleStringSchema)2 ShardConsumerTestUtils.fakeSequenceNumber (org.apache.flink.streaming.connectors.kinesis.internals.ShardConsumerTestUtils.fakeSequenceNumber)2 SequenceNumber (org.apache.flink.streaming.connectors.kinesis.model.SequenceNumber)2 KinesisProxyInterface (org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyInterface)2 TestableKinesisDataFetcher (org.apache.flink.streaming.connectors.kinesis.testutils.TestableKinesisDataFetcher)2 StartingPosition (software.amazon.awssdk.services.kinesis.model.StartingPosition)2 SdkClientException (com.amazonaws.SdkClientException)1 UserRecord (com.amazonaws.services.kinesis.clientlibrary.types.UserRecord)1 Date (java.util.Date)1 RecordPublisherRunResult (org.apache.flink.streaming.connectors.kinesis.internals.publisher.RecordPublisher.RecordPublisherRunResult)1 FanOutRecordPublisherConfiguration (org.apache.flink.streaming.connectors.kinesis.internals.publisher.fanout.FanOutRecordPublisherConfiguration)1 FanOutRecordPublisherFactory (org.apache.flink.streaming.connectors.kinesis.internals.publisher.fanout.FanOutRecordPublisherFactory)1 StreamConsumerRegistrar (org.apache.flink.streaming.connectors.kinesis.internals.publisher.fanout.StreamConsumerRegistrar)1