use of org.apache.kafka.clients.FetchSessionHandler in project kafka by apache.
the class FetchSessionBenchmark method setUp.
@Setup(Level.Trial)
public void setUp() {
fetches = new LinkedHashMap<>();
handler = new FetchSessionHandler(LOG_CONTEXT, 1);
topicIds = new HashMap<>();
FetchSessionHandler.Builder builder = handler.newBuilder();
Uuid id = Uuid.randomUuid();
topicIds.put("foo", id);
LinkedHashMap<TopicIdPartition, FetchResponseData.PartitionData> respMap = new LinkedHashMap<>();
for (int i = 0; i < partitionCount; i++) {
TopicPartition tp = new TopicPartition("foo", i);
FetchRequest.PartitionData partitionData = new FetchRequest.PartitionData(id, 0, 0, 200, Optional.empty());
fetches.put(tp, partitionData);
builder.add(tp, partitionData);
respMap.put(new TopicIdPartition(id, tp), new FetchResponseData.PartitionData().setPartitionIndex(tp.partition()).setLastStableOffset(0).setLogStartOffset(0));
}
builder.build();
// build and handle an initial response so that the next fetch will be incremental
handler.handleResponse(FetchResponse.of(Errors.NONE, 0, 1, respMap), ApiKeys.FETCH.latestVersion());
int counter = 0;
for (TopicPartition topicPartition : new ArrayList<>(fetches.keySet())) {
if (updatedPercentage != 0 && counter % (100 / updatedPercentage) == 0) {
// reorder in fetch session, and update log start offset
fetches.remove(topicPartition);
fetches.put(topicPartition, new FetchRequest.PartitionData(id, 50, 40, 200, Optional.empty()));
}
counter++;
}
}
Aggregations