MINOR: ProducerPerformance should work with older client jars

Author: Jun Rao <junrao@gmail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #2896 from junrao/minor
This commit is contained in:
Jun Rao 2017-04-23 16:28:05 +01:00 committed by Ismael Juma
parent 1fbb8cfafa
commit b154221774
1 changed files with 14 additions and 7 deletions

View File

@ -129,17 +129,24 @@ public class ProducerPerformance {
}
}
// Make sure all messages are sent before printing out the stats and the metrics
producer.flush();
if (!shouldPrintMetrics) {
producer.close();
/* print final results */
stats.printTotal();
/* print final results */
stats.printTotal();
} else {
// Make sure all messages are sent before printing out the stats and the metrics
// We need to do this in a different branch for now since tests/kafkatest/sanity_checks/test_performance_services.py
// expects this class to work with older versions of the client jar that don't support flush().
producer.flush();
/* print out metrics */
if (shouldPrintMetrics) {
/* print final results */
stats.printTotal();
/* print out metrics */
ToolsUtils.printMetrics(producer.metrics());
producer.close();
}
producer.close();
} catch (ArgumentParserException e) {
if (args.length == 0) {
parser.printHelp();