Skip to content

KAFKA-16908: Refactor QuorumConfig with AbstractConfig#16388

Closed
johnnychhsu wants to merge 4 commits intoapache:trunkfrom
johnnychhsu:KAFKA-16908/refactor_QuorumConfig
Closed

KAFKA-16908: Refactor QuorumConfig with AbstractConfig#16388
johnnychhsu wants to merge 4 commits intoapache:trunkfrom
johnnychhsu:KAFKA-16908/refactor_QuorumConfig

Conversation

@johnnychhsu
Copy link
Copy Markdown
Contributor

@johnnychhsu johnnychhsu commented Jun 18, 2024

Test

run ./gradlew clean raft:test --tests RaftEventSimulationTest and passed
run ./gradlew clean build -x test and succeed

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@johnnychhsu johnnychhsu changed the title [WIP]KAFKA-16908: Refactor QuorumConfig with AbstractConfig KAFKA-16908: Refactor QuorumConfig with AbstractConfig Jun 19, 2024
@johnnychhsu johnnychhsu marked this pull request as ready for review June 19, 2024 10:33
Copy link
Copy Markdown
Contributor

@OmniaGM OmniaGM left a comment

Choose a reason for hiding this comment

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

Nice refactor, I just left one suggestion to keep things in line with refactoring KafkaConfig.


public int requestTimeoutMs() {
return requestTimeoutMs;
return getInt(QUORUM_REQUEST_TIMEOUT_MS_CONFIG);
Copy link
Copy Markdown
Contributor

@OmniaGM OmniaGM Jun 19, 2024

Choose a reason for hiding this comment

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

If we are defining these getters here can we add QuorumConfig to KafkaConfig in similar way to _remoteLogManagerConfig and delete the quorum getters from there (and maybe some of the validators as well). As this will help keeping KafkaConfig tidier cc: @chia7712

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm re-thinking the design about inheritance and composition. _remoteLogManagerConfig has a issue that it can't reflect the updated configs (#16394) and I left a comment (#16394 (comment)) about keeping a KafkaConfig reference instead of copying all props of KafkaConfig.

It seems all configs in QuorumConfig can't be updated dynamically, so it is fine for now. However, I'd like to see more consistent design for those individual config class. Hence, maybe we can take a look at #16394 first, and then this PR can follow the same pattern :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks @OmniaGM @chia7712
let me check #16394 first

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

just check #16394 and it looks like currently the approach is instead of inheriting, we composite an AbstractConfig as a property of the actual config.
I am wondering if in the future we can put all config related implementation in a module, instead of scattering around in different modules. In this case, take this QuorumConfig for example, we can have a constructor that accept KafkaConfig to init the QuorumConfig.

Copy link
Copy Markdown
Contributor

@OmniaGM OmniaGM Jun 20, 2024

Choose a reason for hiding this comment

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

I believe this is the discussion @chia7712 and I are having in #16394 specially that we are trying to pull KafkaConfig out of core in other PRs.

@chia7712
Copy link
Copy Markdown
Member

@johnnychhsu Could you please take a look at #16394? It adopts another approach to complete the refactor.

@johnnychhsu johnnychhsu force-pushed the KAFKA-16908/refactor_QuorumConfig branch from dbea46c to cf62fcd Compare June 27, 2024 12:58
Copy link
Copy Markdown
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.

@johnnychhsu thanks for updated PR


val apiVersions = new ApiVersions()
private val raftConfig = new QuorumConfig(config)
private val raftConfig = new QuorumConfig(props)
Copy link
Copy Markdown
Member

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

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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 KafkaConfig? for example: quorumElectionBackoffMs, quorumFetchTimeoutMs, quorumElectionTimeoutMs, quorumLingerMs and quorumRetryBackoffMs can be removed. quorumRequestTimeoutMs can be removed and its' callers should use QuorumConfig#requestTimeoutMs instead

@johnnychhsu johnnychhsu force-pushed the KAFKA-16908/refactor_QuorumConfig branch from cf62fcd to d3c729c Compare July 15, 2024 13:20
Copy link
Copy Markdown
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.

@johnnychhsu thanks for updated patch. It would be nice to check the build :)

this.config = config;
}

public static ConfigDef configDef() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why we need this change?

import java.util.Optional;
import java.util.OptionalInt;
import java.util.OptionalLong;
import java.util.Properties;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please remove unnecessary change

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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please fix compile error

@chia7712
Copy link
Copy Markdown
Member

chia7712 commented Oct 7, 2024

close as this was fixed by #17231

@chia7712 chia7712 closed this Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants