-
Notifications
You must be signed in to change notification settings - Fork 15.1k
KAFKA-16908: Refactor QuorumConfig with AbstractConfig #16388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -676,6 +676,8 @@ class KafkaConfig private(doLog: Boolean, val props: util.Map[_, _]) | |
| val quorumLingerMs = getInt(QuorumConfig.QUORUM_LINGER_MS_CONFIG) | ||
| val quorumRequestTimeoutMs = getInt(QuorumConfig.QUORUM_REQUEST_TIMEOUT_MS_CONFIG) | ||
| val quorumRetryBackoffMs = getInt(QuorumConfig.QUORUM_RETRY_BACKOFF_MS_CONFIG) | ||
| private val _quorumConfig = new QuorumConfig(this) | ||
| def quorumConfig = _quorumConfig | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please use this to return quorum-related configs and then remove all related getters from |
||
|
|
||
| /** Internal Configurations **/ | ||
| val unstableApiVersionsEnabled = getBoolean(ServerConfigs.UNSTABLE_API_VERSIONS_ENABLE_CONFIG) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,7 +99,14 @@ public class QuorumConfig { | |
| public static final String QUORUM_RETRY_BACKOFF_MS_DOC = CommonClientConfigs.RETRY_BACKOFF_MS_DOC; | ||
| public static final int DEFAULT_QUORUM_RETRY_BACKOFF_MS = 20; | ||
|
|
||
| public static final ConfigDef CONFIG_DEF = new ConfigDef() | ||
| private final AbstractConfig config; | ||
|
|
||
| public QuorumConfig(AbstractConfig config) { | ||
| this.config = config; | ||
| } | ||
|
|
||
| public static ConfigDef configDef() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why we need this change? |
||
| return new ConfigDef() | ||
| .define(QUORUM_VOTERS_CONFIG, LIST, DEFAULT_QUORUM_VOTERS, new ControllerQuorumVotersValidator(), HIGH, QUORUM_VOTERS_DOC) | ||
| .define(QUORUM_BOOTSTRAP_SERVERS_CONFIG, LIST, DEFAULT_QUORUM_BOOTSTRAP_SERVERS, new ControllerQuorumBootstrapServersValidator(), HIGH, QUORUM_BOOTSTRAP_SERVERS_DOC) | ||
| .define(QUORUM_ELECTION_TIMEOUT_MS_CONFIG, INT, DEFAULT_QUORUM_ELECTION_TIMEOUT_MS, null, HIGH, QUORUM_ELECTION_TIMEOUT_MS_DOC) | ||
|
|
@@ -108,63 +115,30 @@ public class QuorumConfig { | |
| .define(QUORUM_LINGER_MS_CONFIG, INT, DEFAULT_QUORUM_LINGER_MS, null, MEDIUM, QUORUM_LINGER_MS_DOC) | ||
| .define(QUORUM_REQUEST_TIMEOUT_MS_CONFIG, INT, DEFAULT_QUORUM_REQUEST_TIMEOUT_MS, null, MEDIUM, QUORUM_REQUEST_TIMEOUT_MS_DOC) | ||
| .define(QUORUM_RETRY_BACKOFF_MS_CONFIG, INT, DEFAULT_QUORUM_RETRY_BACKOFF_MS, null, LOW, QUORUM_RETRY_BACKOFF_MS_DOC); | ||
|
|
||
| private final int requestTimeoutMs; | ||
| private final int retryBackoffMs; | ||
| private final int electionTimeoutMs; | ||
| private final int electionBackoffMaxMs; | ||
| private final int fetchTimeoutMs; | ||
| private final int appendLingerMs; | ||
|
|
||
| public QuorumConfig(AbstractConfig abstractConfig) { | ||
| this( | ||
| abstractConfig.getInt(QUORUM_REQUEST_TIMEOUT_MS_CONFIG), | ||
| abstractConfig.getInt(QUORUM_RETRY_BACKOFF_MS_CONFIG), | ||
| abstractConfig.getInt(QUORUM_ELECTION_TIMEOUT_MS_CONFIG), | ||
| abstractConfig.getInt(QUORUM_ELECTION_BACKOFF_MAX_MS_CONFIG), | ||
| abstractConfig.getInt(QUORUM_FETCH_TIMEOUT_MS_CONFIG), | ||
| abstractConfig.getInt(QUORUM_LINGER_MS_CONFIG) | ||
| ); | ||
| } | ||
|
|
||
| public QuorumConfig( | ||
| int requestTimeoutMs, | ||
| int retryBackoffMs, | ||
| int electionTimeoutMs, | ||
| int electionBackoffMaxMs, | ||
| int fetchTimeoutMs, | ||
| int appendLingerMs | ||
| ) { | ||
| this.requestTimeoutMs = requestTimeoutMs; | ||
| this.retryBackoffMs = retryBackoffMs; | ||
| this.electionTimeoutMs = electionTimeoutMs; | ||
| this.electionBackoffMaxMs = electionBackoffMaxMs; | ||
| this.fetchTimeoutMs = fetchTimeoutMs; | ||
| this.appendLingerMs = appendLingerMs; | ||
| } | ||
|
|
||
| public int requestTimeoutMs() { | ||
| return requestTimeoutMs; | ||
| return config.getInt(QUORUM_REQUEST_TIMEOUT_MS_CONFIG); | ||
| } | ||
|
|
||
| public int retryBackoffMs() { | ||
| return retryBackoffMs; | ||
| return config.getInt(QUORUM_RETRY_BACKOFF_MS_CONFIG); | ||
| } | ||
|
|
||
| public int electionTimeoutMs() { | ||
| return electionTimeoutMs; | ||
| return config.getInt(QUORUM_ELECTION_TIMEOUT_MS_CONFIG); | ||
| } | ||
|
|
||
| public int electionBackoffMaxMs() { | ||
| return electionBackoffMaxMs; | ||
| return config.getInt(QUORUM_ELECTION_BACKOFF_MAX_MS_CONFIG); | ||
| } | ||
|
|
||
| public int fetchTimeoutMs() { | ||
| return fetchTimeoutMs; | ||
| return config.getInt(QUORUM_FETCH_TIMEOUT_MS_CONFIG); | ||
| } | ||
|
|
||
| public int appendLingerMs() { | ||
| return appendLingerMs; | ||
| return config.getInt(QUORUM_LINGER_MS_CONFIG); | ||
| } | ||
|
|
||
| private static Integer parseVoterId(String idString) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,6 +79,7 @@ | |
| import java.util.Optional; | ||
| import java.util.OptionalInt; | ||
| import java.util.OptionalLong; | ||
| import java.util.Properties; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please remove unnecessary change |
||
| import java.util.Set; | ||
| import java.util.function.Consumer; | ||
| import java.util.function.Function; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,7 @@ | |
| import java.util.OptionalInt; | ||
| import java.util.OptionalLong; | ||
| import java.util.PriorityQueue; | ||
| import java.util.Properties; | ||
| import java.util.Random; | ||
| import java.util.Set; | ||
| import java.util.concurrent.atomic.AtomicInteger; | ||
|
|
@@ -762,14 +763,14 @@ void start(int nodeId) { | |
| .stream() | ||
| .collect(Collectors.toMap(Node::id, Cluster::nodeAddress)); | ||
|
|
||
| QuorumConfig quorumConfig = new QuorumConfig( | ||
| REQUEST_TIMEOUT_MS, | ||
| RETRY_BACKOFF_MS, | ||
| ELECTION_TIMEOUT_MS, | ||
| ELECTION_JITTER_MS, | ||
| FETCH_TIMEOUT_MS, | ||
| LINGER_MS | ||
| ); | ||
| Properties props = new Properties(); | ||
| props.put(QuorumConfig.QUORUM_REQUEST_TIMEOUT_MS_CONFIG, REQUEST_TIMEOUT_MS); | ||
| props.put(QuorumConfig.QUORUM_RETRY_BACKOFF_MS_CONFIG, RETRY_BACKOFF_MS); | ||
| props.put(QuorumConfig.QUORUM_ELECTION_TIMEOUT_MS_CONFIG, ELECTION_TIMEOUT_MS); | ||
| props.put(QuorumConfig.QUORUM_ELECTION_BACKOFF_MAX_MS_CONFIG, ELECTION_JITTER_MS); | ||
| props.put(QuorumConfig.QUORUM_FETCH_TIMEOUT_MS_CONFIG, FETCH_TIMEOUT_MS); | ||
| props.put(QuorumConfig.QUORUM_LINGER_MS_CONFIG, LINGER_MS); | ||
| QuorumConfig quorumConfig = new QuorumConfig(props); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please fix compile error |
||
| Metrics metrics = new Metrics(time); | ||
|
|
||
| persistentState.log.reopen(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please fix the build error