multiSub("warmup", "warmup", 0, numWarmup, numWarmup * numPartitions);
}
public Void call() throws Exception {
final ThroughputAggregator agg = new ThroughputAggregator("recvs", numMessages);
agg.startProgress();
final Map<String, Long> lastSeqIdSeenMap = new HashMap<String, Long>();
for (int i = startTopicLabel; i < startTopicLabel + numTopics; i++) {
if (!HedwigBenchmark.amIResponsibleForTopic(i, partitionIndex, numPartitions)) {
continue;
}
final String topic = HedwigBenchmark.TOPIC_PREFIX + i;
subscriber.subscribe(ByteString.copyFromUtf8(topic), subId, CreateOrAttach.CREATE_OR_ATTACH);
subscriber.startDelivery(ByteString.copyFromUtf8(topic), subId, new MessageHandler() {
@Override
public void deliver(ByteString thisTopic, ByteString subscriberId, Message msg,
Callback<Void> callback, Object context) {
logger.debug("Got message from src-region: {} with seq-id: {}",
msg.getSrcRegion(), msg.getMsgId());
String mapKey = topic + msg.getSrcRegion().toStringUtf8();
Long lastSeqIdSeen = lastSeqIdSeenMap.get(mapKey);
if (lastSeqIdSeen == null) {
lastSeqIdSeen = (long) 0;
}
if (getSrcSeqId(msg) <= lastSeqIdSeen) {
logger.info("Redelivery of message, src-region: " + msg.getSrcRegion() + "seq-id: "
+ msg.getMsgId());
} else {
agg.ding(false);
}
callback.operationFinished(context, null);
}
});
}
System.out.println("Finished subscribing to topics and now waiting for messages to come in...");
// Wait till the benchmark test has completed
agg.queue.take();
System.out.println(agg.summarize(agg.earliest.get()));
return null;
}