Search in sources :

Example 1 with SubscriptionErrorKinesisV2

use of org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2 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 SubscriptionErrorKinesisV2

use of org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2 in project flink by apache.

the class FanOutShardSubscriberTest method testRetryableErrorThrownToConsumer.

@Test
public void testRetryableErrorThrownToConsumer() throws Exception {
    thrown.expect(FanOutShardSubscriber.RetryableFanOutSubscriberException.class);
    thrown.expectMessage("Error!");
    RuntimeException error = new RuntimeException("Error!");
    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 : StartingPosition(software.amazon.awssdk.services.kinesis.model.StartingPosition) SubscriptionErrorKinesisV2(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2) Test(org.junit.Test)

Example 3 with SubscriptionErrorKinesisV2

use of org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2 in project flink by apache.

the class FanOutShardSubscriberTest method testRecoverableErrorThrownToConsumer.

@Test
public void testRecoverableErrorThrownToConsumer() throws Exception {
    thrown.expect(FanOutShardSubscriber.RecoverableFanOutSubscriberException.class);
    thrown.expectMessage("io.netty.handler.timeout.ReadTimeoutException");
    SubscriptionErrorKinesisV2 errorKinesisV2 = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(ReadTimeoutException.INSTANCE);
    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 : StartingPosition(software.amazon.awssdk.services.kinesis.model.StartingPosition) SubscriptionErrorKinesisV2(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2) Test(org.junit.Test)

Example 4 with SubscriptionErrorKinesisV2

use of org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2 in project flink by apache.

the class FanOutRecordPublisherTest method testShardConsumerCompletesIfResourceNotFoundExceptionThrownFromSubscription.

@Test
public void testShardConsumerCompletesIfResourceNotFoundExceptionThrownFromSubscription() throws Exception {
    ResourceNotFoundException exception = ResourceNotFoundException.builder().build();
    SubscriptionErrorKinesisV2 kinesis = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(exception);
    RecordPublisher recordPublisher = createRecordPublisher(kinesis);
    TestConsumer consumer = new TestConsumer();
    assertEquals(COMPLETE, recordPublisher.run(consumer));
    // Will exit on the first subscription
    assertEquals(1, kinesis.getNumberOfSubscribeToShardInvocations());
}
Also used : RecordPublisher(org.apache.flink.streaming.connectors.kinesis.internals.publisher.RecordPublisher) ResourceNotFoundException(software.amazon.awssdk.services.kinesis.model.ResourceNotFoundException) SubscriptionErrorKinesisV2(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2) TestConsumer(org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer) Test(org.junit.Test)

Example 5 with SubscriptionErrorKinesisV2

use of org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2 in project flink by apache.

the class FanOutShardSubscriberTest method testMultipleErrorsThrownPassesFirstErrorToConsumer.

@Test
public void testMultipleErrorsThrownPassesFirstErrorToConsumer() throws Exception {
    thrown.expect(FanOutShardSubscriber.FanOutSubscriberException.class);
    thrown.expectMessage("Error 1!");
    RuntimeException error1 = new RuntimeException("Error 1!");
    RuntimeException error2 = new RuntimeException("Error 2!");
    SubscriptionErrorKinesisV2 errorKinesisV2 = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(error1, error2);
    FanOutShardSubscriber subscriber = new FanOutShardSubscriber("consumerArn", "shardId", errorKinesisV2, DEFAULT_SUBSCRIBE_TO_SHARD_TIMEOUT);
    StartingPosition startingPosition = StartingPosition.builder().build();
    subscriber.subscribeToShardAndConsumeRecords(startingPosition, event -> {
    });
}
Also used : StartingPosition(software.amazon.awssdk.services.kinesis.model.StartingPosition) SubscriptionErrorKinesisV2(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2) Test(org.junit.Test)

Aggregations

SubscriptionErrorKinesisV2 (org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2)10 Test (org.junit.Test)10 TestConsumer (org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer)6 FullJitterBackoff (org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff)4 LimitExceededException (software.amazon.awssdk.services.kinesis.model.LimitExceededException)4 StartingPosition (software.amazon.awssdk.services.kinesis.model.StartingPosition)4 RecordPublisher (org.apache.flink.streaming.connectors.kinesis.internals.publisher.RecordPublisher)2 SdkInterruptedException (com.amazonaws.http.timers.client.SdkInterruptedException)1 Properties (java.util.Properties)1 RecordPublisherRunResult (org.apache.flink.streaming.connectors.kinesis.internals.publisher.RecordPublisher.RecordPublisherRunResult)1 ResourceNotFoundException (software.amazon.awssdk.services.kinesis.model.ResourceNotFoundException)1