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


##########
tools/src/main/java/org/apache/kafka/tools/LogCompactionTester.java:
##########
@@ -226,6 +236,7 @@ public static String peekLine(BufferedReader reader) throws 
IOException {
 
     private static final Random RANDOM = new Random();
 
+

Review Comment:
   please remove this change



##########
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:
   Could you please add warning message for the unused level?



##########
tools/src/main/java/org/apache/kafka/tools/LogCompactionTester.java:
##########
@@ -256,7 +270,8 @@ public static void main(String[] args) throws Exception {
         System.out.println("Producing " + messages + " messages..to topics " + 
String.join(",", topics));
         Path producedDataFilePath = produceMessages(
                 brokerUrl, topics, messages,
-                compressionType, dups, percentDeletes);
+                compressionType, compressionLevel,

Review Comment:
   `compressionType` could be changed from `string` to `CompressionType`. That 
also validates the string value



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