You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by gw...@apache.org on 2016/08/26 02:19:55 UTC
kafka git commit: KAFKA-4052: Allow passing properties file to
ProducerPerformance
Repository: kafka
Updated Branches:
refs/heads/trunk dddb79f31 -> bf3dbcba4
KAFKA-4052: Allow passing properties file to ProducerPerformance
Tested by running on a kerberos enabled Kafka cluster.
Author: Ashish Singh <as...@cloudera.com>
Reviewers: Gwen Shapira, Sriharsha Chintalapani
Closes #1749 from SinghAsDev/KAFKA-4052
Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/bf3dbcba
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/bf3dbcba
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/bf3dbcba
Branch: refs/heads/trunk
Commit: bf3dbcba4fe5fd8185a529ba216acf20f7e2d02d
Parents: dddb79f
Author: Ashish Singh <as...@cloudera.com>
Authored: Thu Aug 25 19:19:50 2016 -0700
Committer: Gwen Shapira <cs...@gmail.com>
Committed: Thu Aug 25 19:19:50 2016 -0700
----------------------------------------------------------------------
.../apache/kafka/tools/ProducerPerformance.java | 22 ++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kafka/blob/bf3dbcba/tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java b/tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java
index b83227f..a13d3ec 100644
--- a/tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java
+++ b/tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java
@@ -29,6 +29,7 @@ import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;
+import org.apache.kafka.common.utils.Utils;
public class ProducerPerformance {
@@ -44,8 +45,16 @@ public class ProducerPerformance {
int recordSize = res.getInt("recordSize");
int throughput = res.getInt("throughput");
List<String> producerProps = res.getList("producerConfig");
+ String producerConfig = res.getString("producerConfigFile");
+
+ if (producerProps == null && producerConfig == null) {
+ throw new ArgumentParserException("Either --producer-props or --producer.config must be specified.", parser);
+ }
Properties props = new Properties();
+ if (producerConfig != null) {
+ props.putAll(Utils.loadProps(producerConfig));
+ }
if (producerProps != null)
for (String prop : producerProps) {
String[] pieces = prop.split("=");
@@ -132,11 +141,20 @@ public class ProducerPerformance {
parser.addArgument("--producer-props")
.nargs("+")
- .required(true)
+ .required(false)
.metavar("PROP-NAME=PROP-VALUE")
.type(String.class)
.dest("producerConfig")
- .help("kafka producer related configuaration properties like bootstrap.servers,client.id etc..");
+ .help("kafka producer related configuration properties like bootstrap.servers,client.id etc. " +
+ "These configs take precedence over those passed via --producer.config.");
+
+ parser.addArgument("--producer.config")
+ .action(store())
+ .required(false)
+ .type(String.class)
+ .metavar("CONFIG-FILE")
+ .dest("producerConfigFile")
+ .help("producer config properties file.");
return parser;
}