kevin-wu24 commented on code in PR #22669: URL: https://github.com/apache/kafka/pull/22669#discussion_r3482670547
########## 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: > But this will force the benchmark writer to include resetCounters() after every setup In my opinion this is a good thing for future readers of the code. You know when you leave whatever "setup" method all the counters are zeroed. The clearing is explicit rather than implicit. One way to think about it is that the construction of the `RaftClientBenchmarkContext` is a function that is responsible for one thing, "building your benchmark context" object. The facts that `resetCounters()` may or may not be called afterwards or may or may not be necessary in that construction are arguments for not putting that method invocation in the constructor. -- 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]
