mirror of https://github.com/apache/kafka.git
Renamed throttler
This commit is contained in:
parent
9100417ce0
commit
1228eefc4e
|
@ -50,7 +50,7 @@ public class ProducerPerformance {
|
||||||
Stats stats = new Stats(numRecords, 5000);
|
Stats stats = new Stats(numRecords, 5000);
|
||||||
long startMs = System.currentTimeMillis();
|
long startMs = System.currentTimeMillis();
|
||||||
|
|
||||||
MessageThroughputThrottler throttler = new MessageThroughputThrottler(throughput, startMs);
|
ThroughputThrottler throttler = new ThroughputThrottler(throughput, startMs);
|
||||||
for (int i = 0; i < numRecords; i++) {
|
for (int i = 0; i < numRecords; i++) {
|
||||||
long sendStartMs = System.currentTimeMillis();
|
long sendStartMs = System.currentTimeMillis();
|
||||||
Callback cb = stats.nextCompletion(sendStartMs, payload.length, stats);
|
Callback cb = stats.nextCompletion(sendStartMs, payload.length, stats);
|
||||||
|
|
|
@ -33,7 +33,7 @@ package org.apache.kafka.clients.tools;
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public class MessageThroughputThrottler {
|
public class ThroughputThrottler {
|
||||||
|
|
||||||
private static final long NS_PER_MS = 1000000L;
|
private static final long NS_PER_MS = 1000000L;
|
||||||
private static final long NS_PER_SEC = 1000 * NS_PER_MS;
|
private static final long NS_PER_SEC = 1000 * NS_PER_MS;
|
||||||
|
@ -44,7 +44,7 @@ public class MessageThroughputThrottler {
|
||||||
long targetThroughput = -1;
|
long targetThroughput = -1;
|
||||||
long startMs;
|
long startMs;
|
||||||
|
|
||||||
public MessageThroughputThrottler(long targetThroughput, long startMs) {
|
public ThroughputThrottler(long targetThroughput, long startMs) {
|
||||||
this.startMs = startMs;
|
this.startMs = startMs;
|
||||||
this.targetThroughput = targetThroughput;
|
this.targetThroughput = targetThroughput;
|
||||||
this.sleepTimeNs = NS_PER_SEC / targetThroughput;
|
this.sleepTimeNs = NS_PER_SEC / targetThroughput;
|
Loading…
Reference in New Issue