KAFKA-20337: Make all GroupConfig fields Optional and clean up validation#22003
Conversation
|
@squah-confluent I have been playing with those dynamic configs and I came up with this patch. Please take a look. |
squah-confluent
left a comment
There was a problem hiding this comment.
Thanks for the refactor, looks good!
The approach to validate() where we only pass in the present parsed values is nice.
96c26ce to
1e55293
Compare
| @@ -2828,7 +2828,8 @@ class KafkaApis(val requestChannel: RequestChannel, | |||
| } else { | |||
| // Compute group-specific timeout for caching errors (2 * heartbeat interval) | |||
| val heartbeatIntervalMs = Option(groupConfigManager.groupConfig(streamsGroupHeartbeatRequest.data.groupId).orElse(null)) | |||
There was a problem hiding this comment.
val heartbeatIntervalMs = groupConfigManager.groupConfig(streamsGroupHeartbeatRequest.data.groupId)
.flatMap[java.lang.Integer](gc => gc.streamsHeartbeatIntervalMs())
.orElseGet(() => config.groupCoordinatorConfig.streamsGroupHeartbeatIntervalMs())
.toLong| @@ -324,48 +314,41 @@ public static Optional<String> brokerSynonym(String groupConfigName) { | |||
|
|
|||
| public GroupConfig(Map<?, ?> props) { | |||
| super(CONFIG_DEF, props, false); | |||
There was a problem hiding this comment.
Have you considered dropping the AbstractConfig inheritance entirely? Since we now expect callers to strictly use the new Optional getter methods, extending AbstractConfig unnecessarily exposes a wider, unsafe API surface.
There was a problem hiding this comment.
Yes, I have. At the moment, AbstractConfig's methods are used by ConfigHelper so I stopped here in this PR. I will investigate this further as follow-ups.
…tion All GroupConfig fields are now Optional<T>, storing only explicitly provided values. Broker-level defaults are resolved at access time via flatMap().orElse(brokerDefault), eliminating stale-capture issues when broker configs change dynamically. Key changes: - All 21 GroupConfig fields are private Optional, using optionalInt/Boolean/String helpers based on originals(). - GroupConfigManager no longer needs a defaultConfig; constructor simplified. - GroupCoordinatorConfig.extractGroupConfigMap(ShareGroupConfig) removed. - All consumers (GroupMetadataManager, ShareGroupConfigProvider, KafkaApis) use flatMap. - validate() uses CONFIG_DEF.parse() directly instead of constructing a GroupConfig, keeping validation independent from GroupConfig construction. - validateValues refactored with validateIntRange/Max/Min helpers operating on a single filtered parsed map. - Cross-field checks use broker defaults for missing values. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1e55293 to
5f29cef
Compare
…ion (apache#22003) All GroupConfig fields are now Optional<T>, storing only explicitly provided values. Broker-level defaults are resolved at access time via flatMap().orElse(brokerDefault), eliminating stale-capture issues when broker configs change dynamically. Key changes: - All 21 GroupConfig fields are private Optional, using optionalInt/Boolean/String helpers based on originals(). - GroupConfigManager no longer needs a defaultConfig; constructor simplified. - GroupCoordinatorConfig.extractGroupConfigMap(ShareGroupConfig) removed. - All consumers (GroupMetadataManager, ShareGroupConfigProvider, KafkaApis) use flatMap. - validateValues refactored with validateIntRange/Max/Min helpers operating on a single filtered parsed map. - Cross-field checks use broker defaults for missing values. Reviewers: Sean Quah <squah@confluent.io>, Chia-Ping Tsai <chia7712@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All GroupConfig fields are now Optional, storing only explicitly
provided values. Broker-level defaults are resolved at access time via
flatMap().orElse(brokerDefault), eliminating stale-capture issues when
broker configs change dynamically.
Key changes:
optionalInt/Boolean/String helpers based on originals().
simplified.
removed.
KafkaApis) use flatMap.
operating on a single filtered parsed map.
Reviewers: Sean Quah squah@confluent.io, Chia-Ping Tsai
chia7712@gmail.com