hlteoh37 commented on code in PR #20245:
URL: https://github.com/apache/flink/pull/20245#discussion_r918857597
##########
flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/sink/writer/AsyncSinkWriter.java:
##########
@@ -344,44 +342,45 @@ public void write(InputT element, Context context) throws
IOException, Interrupt
* </ul>
*/
private void nonBlockingFlush() throws InterruptedException {
- while (!isInFlightRequestOrMessageLimitExceeded()
+ while (!rateLimitingStrategy.shouldBlock(createRequestInfo())
&& (bufferedRequestEntries.size() >= getNextBatchSizeLimit()
|| bufferedRequestEntriesTotalSizeInBytes >=
maxBatchSizeInBytes)) {
flush();
}
}
- /**
- * Determines if the sink should block and complete existing in flight
requests before it may
- * prudently create any new ones. This is exactly determined by if the
number of requests
- * currently in flight exceeds the maximum supported by the sink OR if the
number of in flight
- * messages exceeds the maximum determined to be appropriate by the rate
limiting strategy.
- */
- private boolean isInFlightRequestOrMessageLimitExceeded() {
- return inFlightRequestsCount >= maxInFlightRequests
- || inFlightMessages >= rateLimitingStrategy.getRateLimit();
+ private RequestInfo createRequestInfo() {
+ int batchSize = getNextBatchSize();
+ long requestStartTime = System.currentTimeMillis();
Review Comment:
Good point. Will change it.
--
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]