}
long startTime = System.currentTimeMillis();
int myPublishLimit = numMessages / numRegions / numPartitions - myPublishCount;
myPublishCount = 0;
ThroughputLatencyAggregator agg = new ThroughputLatencyAggregator("acked pubs", myPublishLimit, nParallel);
int topicLabel = 0;
while (myPublishCount < myPublishLimit) {
int topicNum = startTopicLabel + topicLabel;
topicLabel = (topicLabel + 1) % numTopics;
if (!HedwigBenchmark.amIResponsibleForTopic(topicNum, partitionIndex, numPartitions)) {
continue;
}
ByteString topic = ByteString.copyFromUtf8(HedwigBenchmark.TOPIC_PREFIX + topicNum);
if (rate > 0) {
long delay = startTime + (long) (1000 * myPublishCount / rate) - System.currentTimeMillis();
if (delay > 0)
Thread.sleep(delay);
}
publisher.asyncPublish(topic, msg, new BenchmarkCallback(agg), null);
myPublishCount++;
}
System.out.println("Finished unacked pubs: tput = " + BenchmarkUtils.calcTp(myPublishLimit, startTime)
+ " ops/s");
// Wait till the benchmark test has completed
agg.tpAgg.queue.take();
System.out.println(agg.summarize(startTime));
return null;
}