wenbingshen commented on a change in pull request #10588:
URL: https://github.com/apache/kafka/pull/10588#discussion_r618900520
##########
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:
A simple format point, can you delete the extra spaces which before
IllegalArgumentException. :)
--
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:
[email protected]