Search in sources :

Example 1 with SdkInterruptedException

use of com.amazonaws.http.timers.client.SdkInterruptedException in project flink by apache.

the class FanOutShardSubscriberTest method testInterruptedErrorThrownToConsumer.

@Test
public void testInterruptedErrorThrownToConsumer() throws Exception {
    thrown.expect(FanOutShardSubscriber.FanOutSubscriberInterruptedException.class);
    SdkInterruptedException error = new SdkInterruptedException(null);
    SubscriptionErrorKinesisV2 errorKinesisV2 = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(error);
    FanOutShardSubscriber subscriber = new FanOutShardSubscriber("consumerArn", "shardId", errorKinesisV2, DEFAULT_SUBSCRIBE_TO_SHARD_TIMEOUT);
    software.amazon.awssdk.services.kinesis.model.StartingPosition startingPosition = software.amazon.awssdk.services.kinesis.model.StartingPosition.builder().build();
    subscriber.subscribeToShardAndConsumeRecords(startingPosition, event -> {
    });
}
Also used : SdkInterruptedException(com.amazonaws.http.timers.client.SdkInterruptedException) StartingPosition(software.amazon.awssdk.services.kinesis.model.StartingPosition) SubscriptionErrorKinesisV2(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2) Test(org.junit.Test)

Example 2 with SdkInterruptedException

use of com.amazonaws.http.timers.client.SdkInterruptedException in project flink by apache.

the class FanOutRecordPublisherTest method testInterruptedPublisherReturnsCancelled.

@Test
public void testInterruptedPublisherReturnsCancelled() throws Exception {
    KinesisProxyV2Interface kinesis = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(new SdkInterruptedException(null));
    RecordPublisher publisher = createRecordPublisher(kinesis, StartingPosition.continueFromSequenceNumber(SEQUENCE_NUMBER));
    RecordPublisherRunResult actual = publisher.run(new TestConsumer());
    assertEquals(CANCELLED, actual);
}
Also used : RecordPublisher(org.apache.flink.streaming.connectors.kinesis.internals.publisher.RecordPublisher) RecordPublisherRunResult(org.apache.flink.streaming.connectors.kinesis.internals.publisher.RecordPublisher.RecordPublisherRunResult) SdkInterruptedException(com.amazonaws.http.timers.client.SdkInterruptedException) KinesisProxyV2Interface(org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface) TestConsumer(org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer) Test(org.junit.Test)

Example 3 with SdkInterruptedException

use of com.amazonaws.http.timers.client.SdkInterruptedException 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)

Aggregations

SdkInterruptedException (com.amazonaws.http.timers.client.SdkInterruptedException)3 Test (org.junit.Test)3 KinesisProxyV2Interface (org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface)2 ShardConsumerTestUtils.fakeSequenceNumber (org.apache.flink.streaming.connectors.kinesis.internals.ShardConsumerTestUtils.fakeSequenceNumber)1 RecordPublisher (org.apache.flink.streaming.connectors.kinesis.internals.publisher.RecordPublisher)1 RecordPublisherRunResult (org.apache.flink.streaming.connectors.kinesis.internals.publisher.RecordPublisher.RecordPublisherRunResult)1 FanOutRecordPublisherFactory (org.apache.flink.streaming.connectors.kinesis.internals.publisher.fanout.FanOutRecordPublisherFactory)1 SequenceNumber (org.apache.flink.streaming.connectors.kinesis.model.SequenceNumber)1 SubscriptionErrorKinesisV2 (org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2)1 TestConsumer (org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer)1 StartingPosition (software.amazon.awssdk.services.kinesis.model.StartingPosition)1