Search in sources :

Example 1 with RateLimiter

use of org.rnorth.ducttape.ratelimits.RateLimiter in project flink by apache.

the class KinesisDataStreamsTableApiIT method prepareStream.

private void prepareStream(String streamName) throws Exception {
    final RateLimiter rateLimiter = RateLimiterBuilder.newBuilder().withRate(1, SECONDS).withConstantThroughput().build();
    kinesisClient.createStream(CreateStreamRequest.builder().streamName(streamName).shardCount(1).build()).get();
    Deadline deadline = Deadline.fromNow(Duration.ofMinutes(1));
    while (!rateLimiter.getWhenReady(() -> streamExists(streamName))) {
        if (deadline.isOverdue()) {
            throw new RuntimeException("Failed to create stream within time");
        }
    }
}
Also used : Deadline(org.apache.flink.api.common.time.Deadline) RateLimiter(org.rnorth.ducttape.ratelimits.RateLimiter)

Aggregations

Deadline (org.apache.flink.api.common.time.Deadline)1 RateLimiter (org.rnorth.ducttape.ratelimits.RateLimiter)1