Search in sources :

Example 1 with FlinkKinesisTimeoutException

use of org.apache.flink.streaming.connectors.kinesis.FlinkKinesisException.FlinkKinesisTimeoutException in project flink by apache.

the class StreamConsumerRegistrar method waitForConsumerToDeregister.

private void waitForConsumerToDeregister(@Nullable final DescribeStreamConsumerResponse describeStreamConsumerResponse, final String streamConsumerArn, final int initialAttempt) throws InterruptedException, ExecutionException {
    int attempt = initialAttempt;
    Instant start = Instant.now();
    Duration timeout = configuration.getDeregisterStreamConsumerTimeout();
    Optional<DescribeStreamConsumerResponse> response = Optional.ofNullable(describeStreamConsumerResponse);
    while (response.isPresent() && response.get().consumerDescription().consumerStatus() != DELETING) {
        LOG.debug("Waiting for stream consumer to deregister, attempt {} - {}", attempt, streamConsumerArn);
        deregistrationBackoff(configuration, backoff, attempt++);
        response = describeStreamConsumer(streamConsumerArn);
        if (Duration.between(start, Instant.now()).compareTo(timeout) > 0) {
            throw new FlinkKinesisTimeoutException("Timeout waiting for stream consumer to deregister: " + streamConsumerArn);
        }
    }
}
Also used : DescribeStreamConsumerResponse(software.amazon.awssdk.services.kinesis.model.DescribeStreamConsumerResponse) Instant(java.time.Instant) Duration(java.time.Duration) FlinkKinesisTimeoutException(org.apache.flink.streaming.connectors.kinesis.FlinkKinesisException.FlinkKinesisTimeoutException)

Example 2 with FlinkKinesisTimeoutException

use of org.apache.flink.streaming.connectors.kinesis.FlinkKinesisException.FlinkKinesisTimeoutException in project flink by apache.

the class StreamConsumerRegistrar method waitForConsumerToBecomeActive.

private String waitForConsumerToBecomeActive(@Nullable final DescribeStreamConsumerResponse describeStreamConsumerResponse, final String streamArn, final String streamConsumerName, final int initialAttempt) throws InterruptedException, ExecutionException {
    int attempt = initialAttempt;
    Instant start = Instant.now();
    Duration timeout = configuration.getRegisterStreamConsumerTimeout();
    DescribeStreamConsumerResponse response = describeStreamConsumerResponse;
    while (response == null || response.consumerDescription().consumerStatus() != ACTIVE) {
        LOG.debug("Waiting for stream consumer to become active, attempt {} - {} on {}", attempt, streamConsumerName, streamArn);
        registrationBackoff(configuration, backoff, attempt++);
        response = kinesisProxyV2Interface.describeStreamConsumer(streamArn, streamConsumerName);
        if (Duration.between(start, Instant.now()).compareTo(timeout) > 0) {
            throw new FlinkKinesisTimeoutException("Timeout waiting for stream consumer to become active: " + streamConsumerName + " on " + streamArn);
        }
    }
    return response.consumerDescription().consumerARN();
}
Also used : DescribeStreamConsumerResponse(software.amazon.awssdk.services.kinesis.model.DescribeStreamConsumerResponse) Instant(java.time.Instant) Duration(java.time.Duration) FlinkKinesisTimeoutException(org.apache.flink.streaming.connectors.kinesis.FlinkKinesisException.FlinkKinesisTimeoutException)

Aggregations

Duration (java.time.Duration)2 Instant (java.time.Instant)2 FlinkKinesisTimeoutException (org.apache.flink.streaming.connectors.kinesis.FlinkKinesisException.FlinkKinesisTimeoutException)2 DescribeStreamConsumerResponse (software.amazon.awssdk.services.kinesis.model.DescribeStreamConsumerResponse)2