hlteoh37 commented on code in PR #20245: URL: https://github.com/apache/flink/pull/20245#discussion_r940415649
########## flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/sink/writer/config/BasicAsyncSinkWriterConfiguration.java: ########## @@ -0,0 +1,162 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.connector.base.sink.writer.config; + +import org.apache.flink.connector.base.sink.writer.strategy.AIMDScalingStrategy; +import org.apache.flink.connector.base.sink.writer.strategy.CongestionControlRateLimitingStrategy; +import org.apache.flink.connector.base.sink.writer.strategy.RateLimitingStrategy; + +/** + * BasicAsyncSinkWriterConfiguration with defaults that work well for streaming sources/sinks like + * Kinesis Data Streams and Kinesis Firehose. + */ +public class BasicAsyncSinkWriterConfiguration implements AsyncSinkWriterConfiguration { + private final int maxBatchSize; + private final int maxInFlightRequests; + private final int maxBufferedRequests; + private final long maxBatchSizeInBytes; + private final long maxTimeInBufferMS; + private final long maxRecordSizeInBytes; + private final RateLimitingStrategy rateLimitingStrategy; + + private BasicAsyncSinkWriterConfiguration( + int maxBatchSize, + int maxInFlightRequests, + int maxBufferedRequests, + long maxBatchSizeInBytes, + long maxTimeInBufferMS, + long maxRecordSizeInBytes, + RateLimitingStrategy rateLimitingStrategy) { + this.maxBatchSize = maxBatchSize; + this.maxInFlightRequests = maxInFlightRequests; + this.maxBufferedRequests = maxBufferedRequests; + this.maxBatchSizeInBytes = maxBatchSizeInBytes; + this.maxTimeInBufferMS = maxTimeInBufferMS; + this.maxRecordSizeInBytes = maxRecordSizeInBytes; + this.rateLimitingStrategy = rateLimitingStrategy; + } + + public int getMaxBatchSize() { + return maxBatchSize; + } + + public int getMaxInFlightRequests() { + return maxInFlightRequests; + } + + public int getMaxBufferedRequests() { + return maxBufferedRequests; + } + + public long getMaxBatchSizeInBytes() { + return maxBatchSizeInBytes; + } + + public long getMaxTimeInBufferMS() { + return maxTimeInBufferMS; + } + + public long getMaxRecordSizeInBytes() { + return maxRecordSizeInBytes; + } + + public RateLimitingStrategy getRateLimitingStrategy() { + return rateLimitingStrategy; + } + + public static BasicAsyncSinkWriterConfigurationBuilder builder() { + return new BasicAsyncSinkWriterConfigurationBuilder(); + } + + /** Builder for {@link BasicAsyncSinkWriterConfiguration}. */ + public static class BasicAsyncSinkWriterConfigurationBuilder { + + private int maxBatchSize = 500; + private int maxInFlightRequests = 50; + private int maxBufferedRequests = 10_000; + private long maxBatchSizeInBytes = 5 * 1024 * 1024; + private long maxTimeInBufferMS = 5_000; + private long maxRecordSizeInBytes = 1024 * 1024; Review Comment: Removed defaults, and made it mandatory in builder by implementing interface -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
