sijie closed pull request #2244: Fix batching time in perf producer to allow to
disable batching
URL: https://github.com/apache/incubator-pulsar/pull/2244
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java
b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java
index 3a27799dac..0643fe754b 100644
---
a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java
+++
b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java
@@ -130,7 +130,7 @@
public String payloadFilename = null;
@Parameter(names = { "-b",
"--batch-time-window" }, description = "Batch messages in 'x'
ms window (Default: 1ms)")
- public long batchTime = 1;
+ public double batchTimeMillis = 1.0;
@Parameter(names = { "-time",
"--test-duration" }, description = "Test duration in secs. If
0, it will keep publishing")
@@ -272,8 +272,12 @@ public EncryptionKeyInfo getPrivateKey(String keyName,
Map<String, String> keyMe
// enable round robin message routing if it is a partitioned
topic
.messageRoutingMode(MessageRoutingMode.RoundRobinPartition);
- if (arguments.batchTime > 0) {
- producerBuilder.batchingMaxPublishDelay(arguments.batchTime,
TimeUnit.MILLISECONDS).enableBatching(true);
+ if (arguments.batchTimeMillis == 0.0) {
+ producerBuilder.enableBatching(false);
+ } else {
+ long batchTimeUsec = (long) (arguments.batchTimeMillis * 1000);
+ producerBuilder.batchingMaxPublishDelay(batchTimeUsec,
TimeUnit.MICROSECONDS)
+ .enableBatching(true);
}
// Block if queue is full else we will start seeing errors in sendAsync
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services