Search in sources :

Example 1 with DescribeStreamSummaryResponse

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

the class KinesisProxyV2Test method testDescribeStreamSummary.

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

Example 2 with DescribeStreamSummaryResponse

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

the class StreamConsumerRegistrar method registerStreamConsumer.

/**
 * Register a stream consumer with the given name against the given stream. Blocks until the
 * consumer becomes active. If the stream consumer already exists, the ARN is returned.
 *
 * @param stream the stream to register the stream consumer against
 * @param streamConsumerName the name of the new stream consumer
 * @return the stream consumer ARN
 * @throws ExecutionException
 * @throws InterruptedException
 */
public String registerStreamConsumer(final String stream, final String streamConsumerName) throws ExecutionException, InterruptedException {
    LOG.debug("Registering stream consumer - {}::{}", stream, streamConsumerName);
    int attempt = 1;
    if (configuration.getEfoRegistrationType() == LAZY) {
        registrationBackoff(configuration, backoff, attempt++);
    }
    DescribeStreamSummaryResponse describeStreamSummaryResponse = kinesisProxyV2Interface.describeStreamSummary(stream);
    String streamArn = describeStreamSummaryResponse.streamDescriptionSummary().streamARN();
    LOG.debug("Found stream ARN - {}", streamArn);
    Optional<DescribeStreamConsumerResponse> describeStreamConsumerResponse = describeStreamConsumer(streamArn, streamConsumerName);
    if (!describeStreamConsumerResponse.isPresent()) {
        invokeIgnoringResourceInUse(() -> kinesisProxyV2Interface.registerStreamConsumer(streamArn, streamConsumerName));
    }
    String streamConsumerArn = waitForConsumerToBecomeActive(describeStreamConsumerResponse.orElse(null), streamArn, streamConsumerName, attempt);
    LOG.debug("Using stream consumer - {}", streamConsumerArn);
    return streamConsumerArn;
}
Also used : DescribeStreamConsumerResponse(software.amazon.awssdk.services.kinesis.model.DescribeStreamConsumerResponse) DescribeStreamSummaryResponse(software.amazon.awssdk.services.kinesis.model.DescribeStreamSummaryResponse)

Aggregations

DescribeStreamSummaryResponse (software.amazon.awssdk.services.kinesis.model.DescribeStreamSummaryResponse)2 Test (org.junit.Test)1 SdkAsyncHttpClient (software.amazon.awssdk.http.async.SdkAsyncHttpClient)1 KinesisAsyncClient (software.amazon.awssdk.services.kinesis.KinesisAsyncClient)1 DescribeStreamConsumerResponse (software.amazon.awssdk.services.kinesis.model.DescribeStreamConsumerResponse)1 DescribeStreamSummaryRequest (software.amazon.awssdk.services.kinesis.model.DescribeStreamSummaryRequest)1