Search in sources :

Example 16 with KinesisAsyncClient

use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project flink by apache.

the class KinesisProxyV2Test method testRegisterStreamConsumerBackoffJitter.

@Test
public void testRegisterStreamConsumerBackoffJitter() throws Exception {
    FullJitterBackoff backoff = mock(FullJitterBackoff.class);
    KinesisAsyncClient client = mock(KinesisAsyncClient.class);
    KinesisProxyV2 proxy = new KinesisProxyV2(client, mock(SdkAsyncHttpClient.class), createConfiguration(), backoff);
    when(client.registerStreamConsumer(any(RegisterStreamConsumerRequest.class))).thenThrow(new RuntimeException(LimitExceededException.builder().build())).thenReturn(CompletableFuture.completedFuture(RegisterStreamConsumerResponse.builder().build()));
    proxy.registerStreamConsumer("arn", "name");
    verify(backoff).sleep(anyLong());
    verify(backoff).calculateFullJitterBackoff(EXPECTED_REGISTRATION_BASE, EXPECTED_REGISTRATION_MAX, EXPECTED_REGISTRATION_POW, 1);
}
Also used : KinesisAsyncClient(software.amazon.awssdk.services.kinesis.KinesisAsyncClient) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) Test(org.junit.Test)

Example 17 with KinesisAsyncClient

use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project flink by apache.

the class KinesisProxyV2Test method testDeregisterStreamConsumer.

@Test
public void testDeregisterStreamConsumer() throws Exception {
    KinesisAsyncClient client = mock(KinesisAsyncClient.class);
    KinesisProxyV2 proxy = new KinesisProxyV2(client, mock(SdkAsyncHttpClient.class), createConfiguration(), mock(FullJitterBackoff.class));
    DeregisterStreamConsumerResponse expected = DeregisterStreamConsumerResponse.builder().build();
    ArgumentCaptor<DeregisterStreamConsumerRequest> requestCaptor = ArgumentCaptor.forClass(DeregisterStreamConsumerRequest.class);
    when(client.deregisterStreamConsumer(requestCaptor.capture())).thenReturn(CompletableFuture.completedFuture(expected));
    DeregisterStreamConsumerResponse actual = proxy.deregisterStreamConsumer("arn");
    assertEquals(expected, actual);
    DeregisterStreamConsumerRequest request = requestCaptor.getValue();
    assertEquals("arn", request.consumerARN());
}
Also used : KinesisAsyncClient(software.amazon.awssdk.services.kinesis.KinesisAsyncClient) DeregisterStreamConsumerResponse(software.amazon.awssdk.services.kinesis.model.DeregisterStreamConsumerResponse) DeregisterStreamConsumerRequest(software.amazon.awssdk.services.kinesis.model.DeregisterStreamConsumerRequest) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) Test(org.junit.Test)

Example 18 with KinesisAsyncClient

use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project flink by apache.

the class KinesisProxyV2Test method testDescribeStreamConsumerWithStreamArnAndConsumerName.

@Test
public void testDescribeStreamConsumerWithStreamArnAndConsumerName() throws Exception {
    KinesisAsyncClient client = mock(KinesisAsyncClient.class);
    KinesisProxyV2 proxy = new KinesisProxyV2(client, mock(SdkAsyncHttpClient.class), createConfiguration(), mock(FullJitterBackoff.class));
    DescribeStreamConsumerResponse expected = DescribeStreamConsumerResponse.builder().build();
    ArgumentCaptor<DescribeStreamConsumerRequest> requestCaptor = ArgumentCaptor.forClass(DescribeStreamConsumerRequest.class);
    when(client.describeStreamConsumer(requestCaptor.capture())).thenReturn(CompletableFuture.completedFuture(expected));
    DescribeStreamConsumerResponse actual = proxy.describeStreamConsumer("arn", "name");
    assertEquals(expected, actual);
    DescribeStreamConsumerRequest request = requestCaptor.getValue();
    assertEquals("arn", request.streamARN());
    assertEquals("name", request.consumerName());
}
Also used : KinesisAsyncClient(software.amazon.awssdk.services.kinesis.KinesisAsyncClient) DescribeStreamConsumerResponse(software.amazon.awssdk.services.kinesis.model.DescribeStreamConsumerResponse) DescribeStreamConsumerRequest(software.amazon.awssdk.services.kinesis.model.DescribeStreamConsumerRequest) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) Test(org.junit.Test)

Aggregations

KinesisAsyncClient (software.amazon.awssdk.services.kinesis.KinesisAsyncClient)18 SdkAsyncHttpClient (software.amazon.awssdk.http.async.SdkAsyncHttpClient)14 Test (org.junit.Test)12 SubscribeToShardRequest (software.amazon.awssdk.services.kinesis.model.SubscribeToShardRequest)4 CompletableFuture (java.util.concurrent.CompletableFuture)3 DescribeStreamConsumerRequest (software.amazon.awssdk.services.kinesis.model.DescribeStreamConsumerRequest)3 DescribeStreamConsumerResponse (software.amazon.awssdk.services.kinesis.model.DescribeStreamConsumerResponse)3 DescribeStreamSummaryRequest (software.amazon.awssdk.services.kinesis.model.DescribeStreamSummaryRequest)3 Properties (java.util.Properties)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 FanOutRecordPublisherConfiguration (org.apache.flink.streaming.connectors.kinesis.internals.publisher.fanout.FanOutRecordPublisherConfiguration)2 Subscriber (org.reactivestreams.Subscriber)2 Subscription (org.reactivestreams.Subscription)2 SdkPublisher (software.amazon.awssdk.core.async.SdkPublisher)2 Region (software.amazon.awssdk.regions.Region)2 DescribeStreamSummaryResponse (software.amazon.awssdk.services.kinesis.model.DescribeStreamSummaryResponse)2 ShardIteratorType (software.amazon.awssdk.services.kinesis.model.ShardIteratorType)2 SubscribeToShardEvent (software.amazon.awssdk.services.kinesis.model.SubscribeToShardEvent)2 SubscribeToShardEventStream (software.amazon.awssdk.services.kinesis.model.SubscribeToShardEventStream)2 SubscribeToShardResponse (software.amazon.awssdk.services.kinesis.model.SubscribeToShardResponse)2