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


##########
tools/src/main/java/org/apache/kafka/tools/LogCompactionTester.java:
##########
@@ -395,12 +407,29 @@ 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
-        );
+                                        CompressionType 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.name);
+        
+        if (compressionLevel != null) {
+            switch (compressionType.name.toLowerCase(Locale.ROOT)) {

Review Comment:
   ```java
           if (compressionLevel != null) {
               switch (compressionType) {
                   case GZIP -> 
producerProps.put(ProducerConfig.COMPRESSION_GZIP_LEVEL_CONFIG, 
compressionLevel);
                   case LZ4 -> 
producerProps.put(ProducerConfig.COMPRESSION_LZ4_LEVEL_CONFIG, 
compressionLevel);
                   case ZSTD -> 
producerProps.put(ProducerConfig.COMPRESSION_ZSTD_LEVEL_CONFIG, 
compressionLevel);
                   default -> System.out.println("Warning: Compression level " 
+ compressionLevel + " is ignored for compression type "
                           + compressionType.name + ". Only gzip, lz4, and zstd 
support compression levels.");
               }
           }
   ```



-- 
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]

Reply via email to