anjy7 commented on code in PR #22669: URL: https://github.com/apache/kafka/pull/22669#discussion_r3479173370
########## raft/src/testFixtures/java/org/apache/kafka/raft/RaftClientBenchmarkContext.java: ########## @@ -0,0 +1,182 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.kafka.raft; + +import org.apache.kafka.common.Uuid; +import org.apache.kafka.common.message.FetchRequestData; +import org.apache.kafka.common.protocol.ApiMessage; +import org.apache.kafka.server.common.KRaftVersion; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public final class RaftClientBenchmarkContext { + private final RaftClientTestContext context; + private final MockLog log; + private final MockNetworkChannel channel; + private final ReplicaKey otherVoter; + + private int lastFlushCount; + private int lastReadCount; + private int lastTruncationCount; + private int lastRequestsSent; + private int lastQuorumWrites; + + private RaftClientBenchmarkContext(RaftClientTestContext context, ReplicaKey otherVoter) { + this.context = context; + this.log = context.log; + this.channel = context.channel; + this.otherVoter = otherVoter; + resetCounters(); Review Comment: This isn't true here. The mock counters are cumulative and aren't zeroed by wrapping them in a fresh context. Constructing the client already does counted work during init and leader() drives a full election on the context before the RaftClientBenchmarkContext constructor runs. So the counters are non-zero at that point. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
