chia7712 commented on code in PR #22899:
URL: https://github.com/apache/kafka/pull/22899#discussion_r3628744669
##########
tools/src/test/java/org/apache/kafka/tools/other/ReplicationQuotasTestRig.java:
##########
@@ -398,24 +403,20 @@ String json(String... topic) {
}
KafkaProducer<byte[], byte[]> createProducer() {
- return TestUtils.createProducer(
- cluster.bootstrapServers(),
- 1,
- 60 * 1000L,
- 1024L * 1024L,
- Integer.MAX_VALUE,
- 30 * 1000,
- 0,
- 16384,
- "none",
- 20 * 1000,
- SecurityProtocol.PLAINTEXT,
- Option.empty(),
- Option.empty(),
- new ByteArraySerializer(),
- new ByteArraySerializer(),
- false
- );
+ Properties producerProps = new Properties();
+ producerProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,
cluster.bootstrapServers());
+ producerProps.put(ProducerConfig.ACKS_CONFIG, "1");
+ producerProps.put(ProducerConfig.MAX_BLOCK_MS_CONFIG,
Long.toString(60 * 1000L));
+ producerProps.put(ProducerConfig.BUFFER_MEMORY_CONFIG,
Long.toString(1024L * 1024L));
+ producerProps.put(ProducerConfig.RETRIES_CONFIG,
Integer.toString(Integer.MAX_VALUE));
+ producerProps.put(ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG,
Integer.toString(30 * 1000));
+ producerProps.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG,
Integer.toString(20 * 1000));
+ producerProps.put(ProducerConfig.LINGER_MS_CONFIG, "0");
+ producerProps.put(ProducerConfig.BATCH_SIZE_CONFIG, "16384");
+ producerProps.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, "none");
+ producerProps.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG,
"false");
+ producerProps.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG,
SecurityProtocol.PLAINTEXT.name());
Review Comment:
`SECURITY_PROTOCOL_CONFIG` and `COMPRESSION_TYPE_CONFIG` already have
default values, so we don't need to set them explicitly
##########
tools/src/test/java/org/apache/kafka/tools/other/ReplicationQuotasTestRig.java:
##########
@@ -398,24 +403,20 @@ String json(String... topic) {
}
KafkaProducer<byte[], byte[]> createProducer() {
- return TestUtils.createProducer(
- cluster.bootstrapServers(),
- 1,
- 60 * 1000L,
- 1024L * 1024L,
- Integer.MAX_VALUE,
- 30 * 1000,
- 0,
- 16384,
- "none",
- 20 * 1000,
- SecurityProtocol.PLAINTEXT,
- Option.empty(),
- Option.empty(),
- new ByteArraySerializer(),
- new ByteArraySerializer(),
- false
- );
+ Properties producerProps = new Properties();
+ producerProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,
cluster.bootstrapServers());
+ producerProps.put(ProducerConfig.ACKS_CONFIG, "1");
+ producerProps.put(ProducerConfig.MAX_BLOCK_MS_CONFIG,
Long.toString(60 * 1000L));
+ producerProps.put(ProducerConfig.BUFFER_MEMORY_CONFIG,
Long.toString(1024L * 1024L));
+ producerProps.put(ProducerConfig.RETRIES_CONFIG,
Integer.toString(Integer.MAX_VALUE));
+ producerProps.put(ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG,
Integer.toString(30 * 1000));
+ producerProps.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG,
Integer.toString(20 * 1000));
+ producerProps.put(ProducerConfig.LINGER_MS_CONFIG, "0");
+ producerProps.put(ProducerConfig.BATCH_SIZE_CONFIG, "16384");
+ producerProps.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, "none");
+ producerProps.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG,
"false");
+ producerProps.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG,
SecurityProtocol.PLAINTEXT.name());
+ return new KafkaProducer<>(producerProps, new
ByteArraySerializer(), new ByteArraySerializer());
Review Comment:
```java
KafkaProducer<byte[], byte[]> createProducer() {
return new KafkaProducer<>(
Map.of(
ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,
cluster.bootstrapServers(),
ProducerConfig.ACKS_CONFIG, "1",
ProducerConfig.MAX_BLOCK_MS_CONFIG, 60 * 1000L,
ProducerConfig.BUFFER_MEMORY_CONFIG, 1024L * 1024L,
ProducerConfig.RETRIES_CONFIG, Integer.MAX_VALUE,
ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG, 30 * 1000,
ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, 20 * 1000,
ProducerConfig.LINGER_MS_CONFIG, 0,
ProducerConfig.BATCH_SIZE_CONFIG, 16384,
ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, false
),
new ByteArraySerializer(),
new ByteArraySerializer()
);
}
```
--
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]