yunchipang commented on code in PR #20396:
URL: https://github.com/apache/kafka/pull/20396#discussion_r2302396180


##########
tools/src/main/java/org/apache/kafka/tools/LogCompactionTester.java:
##########
@@ -395,12 +410,28 @@ private static void require(boolean requirement, String 
message) {
     }
 
     private static Path produceMessages(String brokerUrl, Set<String> topics, 
long messages,
-                                        String compressionType, int dups, int 
percentDeletes) throws IOException {
-        Map<String, Object> producerProps = Map.of(
-                ProducerConfig.MAX_BLOCK_MS_CONFIG, 
String.valueOf(Long.MAX_VALUE),
-                ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerUrl,
-                ProducerConfig.COMPRESSION_TYPE_CONFIG, compressionType
-        );
+                                        String compressionType, Integer 
compressionLevel,
+                                        int dups, int percentDeletes) throws 
IOException {
+        Map<String, Object> producerProps = new HashMap<>();
+        producerProps.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, 
String.valueOf(Long.MAX_VALUE));
+        producerProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerUrl);
+        producerProps.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, 
compressionType);
+        
+        if (compressionLevel != null) {
+            switch (compressionType.toLowerCase(Locale.ROOT)) {
+                case "gzip":
+                    
producerProps.put(ProducerConfig.COMPRESSION_GZIP_LEVEL_CONFIG, 
compressionLevel);
+                    break;
+                case "lz4":
+                    
producerProps.put(ProducerConfig.COMPRESSION_LZ4_LEVEL_CONFIG, 
compressionLevel);
+                    break;
+                case "zstd":
+                    
producerProps.put(ProducerConfig.COMPRESSION_ZSTD_LEVEL_CONFIG, 
compressionLevel);
+                    break;
+                default:
+                    break;

Review Comment:
   added. thanks!



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to