tang7526 commented on a change in pull request #10588:
URL: https://github.com/apache/kafka/pull/10588#discussion_r619798057



##########
File path: build.gradle
##########
@@ -1485,7 +1485,7 @@ project(':tools') {
     testImplementation libs.junitJupiter
     testImplementation project(':clients').sourceSets.test.output
     testImplementation libs.mockitoInline // supports mocking static methods, 
final classes, etc.
-
+    testImplementation libs.easymock

Review comment:
       Thank you for your opinion. I have rewritten it with mockito.

##########
File path: tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java
##########
@@ -190,6 +166,51 @@ public static void main(String[] args) throws Exception {
 
     }
 
+    public KafkaProducer<byte[], byte[]> createKafkaProducer(Properties props) 
{
+        return new KafkaProducer<>(props);
+    }
+    
+    public static Properties readProps(List<String> producerProps, String 
producerConfig, String transactionalId,
+            boolean transactionsEnabled) throws IOException {
+        Properties props = new Properties();
+        if (producerConfig != null) {
+            props.putAll(Utils.loadProps(producerConfig));
+        }
+        if (producerProps != null)
+            for (String prop : producerProps) {
+                String[] pieces = prop.split("=");
+                if (pieces.length != 2)
+                    throw new IllegalArgumentException("Invalid property: " + 
prop);
+                props.put(pieces[0], pieces[1]);
+            }
+
+        props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, 
"org.apache.kafka.common.serialization.ByteArraySerializer");
+        props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, 
"org.apache.kafka.common.serialization.ByteArraySerializer");
+        if (transactionsEnabled)
+            props.put(ProducerConfig.TRANSACTIONAL_ID_CONFIG, transactionalId);
+        return props;
+    }
+
+    public static List<byte[]> readPayloadFile(String payloadFilePath, String 
payloadDelimiter) throws IOException {
+        List<byte[]> payloadByteList = new ArrayList<>();
+        if (payloadFilePath != null) {
+            Path path = Paths.get(payloadFilePath);
+            System.out.println("Reading payloads from: " + 
path.toAbsolutePath());
+            if (Files.notExists(path) || Files.size(path) == 0)  {
+                throw new  IllegalArgumentException("File does not exist or 
empty file provided.");

Review comment:
       Thank you for your opinion. I have removed that space.




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

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


Reply via email to