Skip to content

Conversation

m1a2st
Copy link
Collaborator

@m1a2st m1a2st commented Oct 4, 2025

We can rewrite this class from scala to java and move to server-common
module. To maintain backward compatibility, we should keep the logger
name state.change.logger.

Reviewers: Chia-Ping Tsai [email protected]

@github-actions github-actions bot added triage PRs from the community core Kafka Broker labels Oct 4, 2025
import org.slf4j.LoggerFactory;

public class StateChangeLogger {
private static final Logger log = LoggerFactory.getLogger("state.change.logger");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOGGER

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class StateChangeLogger {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add comments explaining the purpose of this class?

Copy link
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, test this patch locally, and it works well

astraea@4d06546d9896:/opt/kafka$ cat logs/state-change.log 
[2025-10-06 14:49:48,720] INFO [Broker id=10686] Transitioning 1 partition(s) to local leaders. (state.change.logger)
[2025-10-06 14:49:48,722] INFO [Broker id=10686] Creating new partition chia-0 with topic id SSROqblKQnylcx-1TgPrPA. (state.change.logger)
[2025-10-06 14:49:48,735] INFO [Broker id=10686] Leader chia-0 with topic id Some(SSROqblKQnylcx-1TgPrPA) starts at leader epoch 0 from offset 0 with partition epoch 0, high watermark 0, ISR [10686], adding replicas [] and removing replicas [] . Previous leader None and previous leader epoch was -1. (state.change.logger)
[2025-10-06 14:49:48,891] INFO [Broker id=10686] Transitioning 1 partition(s) to local leaders. (state.change.logger)
[2025-10-06 14:49:48,900] INFO [Broker id=10686] Skipped the become-leader state change for chia-0 with topic id Some(SSROqblKQnylcx-1TgPrPA), partition registration PartitionRegistration(replicas=[10686], directories=[_Q5ubnelBuH_WhzwMDjmjA], isr=[10686], removingReplicas=[], addingReplicas=[], elr=[], lastKnownElr=[], leader=10686, leaderRecoveryState=RECOVERED, leaderEpoch=0, partitionEpoch=1) and isNew=false since it is already the leader with leader epoch 0. Current high watermark 0, ISR [10686], adding replicas [] and removing replicas []. (state.change.logger)

@chia7712
Copy link
Member

chia7712 commented Oct 6, 2025

the failed test is handled by #20620

@chia7712 chia7712 merged commit f68a149 into apache:trunk Oct 6, 2025
21 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Kafka Broker triage PRs from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants