[ https://issues.apache.org/jira/browse/KAFKA-18990?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Chia-Ping Tsai resolved KAFKA-18990. ------------------------------------ Fix Version/s: 4.1.0 Resolution: Fixed > Optimize BaseQuotaTest#produceUntilThrottled to avoid redundant MetricName > creation > ----------------------------------------------------------------------------------- > > Key: KAFKA-18990 > URL: https://issues.apache.org/jira/browse/KAFKA-18990 > Project: Kafka > Issue Type: Improvement > Reporter: Chia-Ping Tsai > Assignee: Ming-Yen Chung > Priority: Major > Fix For: 4.1.0 > > > reference: > https://github.com/apache/kafka/blob/trunk/core/src/test/scala/integration/kafka/api/BaseQuotaTest.scala#L229 > {code:java} > def produceUntilThrottled(maxRecords: Int, waitForRequestCompletion: > Boolean = true): Int = { > var numProduced = 0 > var throttled = false > do { > val payload = numProduced.toString.getBytes > val future = producer.send(new ProducerRecord[Array[Byte], > Array[Byte]](topic, null, null, payload), > new ErrorLoggingCallback(topic, null, null, true)) > numProduced += 1 > do { > // move this out of loop > val metric = throttleMetric(QuotaType.PRODUCE, producerClientId) > throttled = metric != null && metricValue(metric) > 0 > } while (!future.isDone && (!throttled || waitForRequestCompletion)) > } while (numProduced < maxRecords && !throttled) > numProduced > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)