hachikuji commented on a change in pull request #10289: URL: https://github.com/apache/kafka/pull/10289#discussion_r597274570
########## File path: checkstyle/suppressions.xml ########## @@ -68,7 +68,7 @@ files="(Utils|Topic|KafkaLZ4BlockOutputStream|AclData|JoinGroupRequest).java"/> <suppress checks="CyclomaticComplexity" - files="(ConsumerCoordinator|Fetcher|Sender|KafkaProducer|BufferPool|ConfigDef|RecordAccumulator|KerberosLogin|AbstractRequest|AbstractResponse|Selector|SslFactory|SslTransportLayer|SaslClientAuthenticator|SaslClientCallbackHandler|SaslServerAuthenticator|AbstractCoordinator|TransactionManager|AbstractStickyAssignor|DefaultSslEngineFactory|Authorizer).java"/> + files="(ConsumerCoordinator|Fetcher|Sender|KafkaProducer|BufferPool|ConfigDef|RecordAccumulator|KerberosLogin|AbstractRequest|AbstractResponse|Selector|SslFactory|SslTransportLayer|SaslClientAuthenticator|SaslClientCallbackHandler|SaslServerAuthenticator|AbstractCoordinator|TransactionManager|AbstractStickyAssignor|DefaultSslEngineFactory|Authorizer|KafkaRaftClient).java"/> Review comment: I agree it is unfortunate. There are probably ways we can improve this. For example, this logic smells a little bit: ```java if (quorum.isLeader()) { logger.debug("Rejecting vote request {} with epoch {} since we are already leader on that epoch", request, candidateEpoch); voteGranted = false; } else if (quorum.isCandidate()) { logger.debug("Rejecting vote request {} with epoch {} since we are already candidate on that epoch", request, candidateEpoch); voteGranted = false; } else if (quorum.isResigned()) { logger.debug("Rejecting vote request {} with epoch {} since we have resigned as candidate/leader in this epoch", request, candidateEpoch); voteGranted = false; } else if (quorum.isFollower()) { FollowerState state = quorum.followerStateOrThrow(); logger.debug("Rejecting vote request {} with epoch {} since we already have a leader {} on that epoch", request, candidateEpoch, state.leaderId()); voteGranted = false; ``` It might be possible to push this logic into `EpochState` or at least to use make use of the `name()` method in the logging. @dengziming would you be interested in following up on this separately? -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org