You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "jlprat (via GitHub)" <gi...@apache.org> on 2024/01/26 16:24:00 UTC
[PR] MINOR: Clean up core server classes [kafka]
jlprat opened a new pull request, #15272:
URL: https://github.com/apache/kafka/pull/15272
Follow up from https://github.com/apache/kafka/pull/15252
Mark methods and fields private where possible:
- Annotate public methods and fields
- Remove unused classes and methods
- Make sure Arrays are not printed with .toString
- Optimize minor warnings
### Committer Checklist (excluded from commit message)
- [ ] Verify design and implementation
- [ ] Verify test coverage and CI build status
- [ ] Verify documentation (including upgrade notes)
--
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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Clean up core server classes [kafka]
Posted by "jlprat (via GitHub)" <gi...@apache.org>.
jlprat commented on PR #15272:
URL: https://github.com/apache/kafka/pull/15272#issuecomment-1912344480
@showuon if you have some time, this is a follow up of the one you reviewed already.
--
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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Clean up core server classes [kafka]
Posted by "jlprat (via GitHub)" <gi...@apache.org>.
jlprat commented on code in PR #15272:
URL: https://github.com/apache/kafka/pull/15272#discussion_r1467861593
##########
core/src/main/scala/kafka/server/metadata/BrokerMetadataPublisher.scala:
##########
@@ -80,7 +80,7 @@ object BrokerMetadataPublisher extends Logging {
Option(newTopicsImage.getPartition(topicId, partitionId)) match {
case Some(partition) =>
if (!partition.replicas.contains(brokerId)) {
- info(s"Found stray log dir $log: the current replica assignment ${partition.replicas} " +
+ info(s"Found stray log dir $log: the current replica assignment ${partition.replicas.mkString("Array(", ", ", ")")} " +
Review Comment:
This actually should have printed the memory reference and not the contents. With the current version, it prints the contents.
##########
core/src/main/scala/kafka/server/ConfigAdminManager.scala:
##########
@@ -154,26 +154,25 @@ class ConfigAdminManager(nodeId: Int,
throw new InvalidRequestException(s"Unknown resource type ${resource.resourceType().toInt}")
}
} catch {
- case t: Throwable => {
+ case t: Throwable =>
val err = ApiError.fromThrowable(t)
- info(s"Error preprocessing incrementalAlterConfigs request on ${configResource}", t)
+ info(s"Error preprocessing incrementalAlterConfigs request on $configResource", t)
results.put(resource, err)
- }
}
}
})
results
}
- def validateBrokerConfigChange(
+ private def validateBrokerConfigChange(
resource: IAlterConfigsResource,
configResource: ConfigResource
): Unit = {
val perBrokerConfig = !configResource.name().isEmpty
val persistentProps = configRepository.config(configResource)
val configProps = conf.dynamicConfig.fromPersistentProps(persistentProps, perBrokerConfig)
val alterConfigOps = resource.configs().asScala.map {
- case config =>
+ config =>
Review Comment:
Previous code was the standard in really old version of Scala, since then anonymous function style is preferred.
##########
core/src/main/scala/kafka/server/ConfigHelper.scala:
##########
@@ -80,7 +80,7 @@ class ConfigHelper(metadataCache: MetadataCache, config: KafkaConfig, configRepo
def describeConfigs(resourceToConfigNames: List[DescribeConfigsResource],
includeSynonyms: Boolean,
includeDocumentation: Boolean): List[DescribeConfigsResponseData.DescribeConfigsResult] = {
- resourceToConfigNames.map { case resource =>
Review Comment:
Previous code was the standard in really old version of Scala, since then anonymous function style is preferred.
##########
core/src/main/scala/kafka/server/metadata/ClientQuotaMetadataManager.scala:
##########
@@ -98,14 +98,14 @@ class ClientQuotaMetadataManager(private[metadata] val quotaManagers: QuotaManag
}
}
quotaDelta.changes().entrySet().forEach { e =>
- handleUserClientQuotaChange(userClientEntity, e.getKey, e.getValue.asScala.map(_.toDouble))
+ handleUserClientQuotaChange(userClientEntity, e.getKey, e.getValue.asScala)
Review Comment:
The map to Double wasn't needed as it was already a double
##########
core/src/main/scala/kafka/server/ConfigAdminManager.scala:
##########
@@ -369,15 +365,13 @@ object ConfigAdminManager {
persistentResponses: AlterConfigsResponseData
): AlterConfigsResponseData = {
val response = new AlterConfigsResponseData()
- val responsesByResource = persistentResponses.responses().iterator().asScala.map {
- case r => (r.resourceName(), r.resourceType()) -> new ApiError(r.errorCode(), r.errorMessage())
Review Comment:
Previous code was the standard in really old version of Scala, since then anonymous function style is preferred.
##########
core/src/main/scala/kafka/server/AutoTopicCreationManager.scala:
##########
@@ -50,6 +50,10 @@ trait AutoTopicCreationManager {
object AutoTopicCreationManager {
+ /**
+ * @deprecated use [[apply(kafka.server.KafkaConfig, kafka.server.MetadataCache, scala.Option, scala.Option, scala.Option, scala.Option, org.apache.kafka.coordinator.group.GroupCoordinator, kafka.coordinator.transaction.TransactionCoordinator)]]
+ */
+ @deprecated("Use the alternative apply method", "3.8.0")
Review Comment:
I could alternatively delete this method altogether.
--
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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Clean up core server classes [kafka]
Posted by "jlprat (via GitHub)" <gi...@apache.org>.
jlprat merged PR #15272:
URL: https://github.com/apache/kafka/pull/15272
--
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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Clean up core server classes [kafka]
Posted by "jlprat (via GitHub)" <gi...@apache.org>.
jlprat commented on PR #15272:
URL: https://github.com/apache/kafka/pull/15272#issuecomment-1916746800
Rebased again to contain https://github.com/apache/kafka/pull/15290
--
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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Clean up core server classes [kafka]
Posted by "jlprat (via GitHub)" <gi...@apache.org>.
jlprat commented on PR #15272:
URL: https://github.com/apache/kafka/pull/15272#issuecomment-1919044644
I checked that all tests pass locally, and the failures in CI seem all unrelated to the changes.
--
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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Clean up core server classes [kafka]
Posted by "mimaison (via GitHub)" <gi...@apache.org>.
mimaison commented on code in PR #15272:
URL: https://github.com/apache/kafka/pull/15272#discussion_r1469799402
##########
core/src/main/scala/kafka/server/AutoTopicCreationManager.scala:
##########
@@ -50,6 +50,10 @@ trait AutoTopicCreationManager {
object AutoTopicCreationManager {
+ /**
+ * @deprecated use [[apply(kafka.server.KafkaConfig, kafka.server.MetadataCache, scala.Option, scala.Option, scala.Option, scala.Option, org.apache.kafka.coordinator.group.GroupCoordinator, kafka.coordinator.transaction.TransactionCoordinator)]]
+ */
+ @deprecated("Use the alternative apply method", "3.8.0")
Review Comment:
If it's not used anymore or if it's easy to update the remaining callers, let's delete this method
--
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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Clean up core server classes [kafka]
Posted by "jlprat (via GitHub)" <gi...@apache.org>.
jlprat commented on code in PR #15272:
URL: https://github.com/apache/kafka/pull/15272#discussion_r1469806761
##########
core/src/main/scala/kafka/server/AutoTopicCreationManager.scala:
##########
@@ -50,6 +50,10 @@ trait AutoTopicCreationManager {
object AutoTopicCreationManager {
+ /**
+ * @deprecated use [[apply(kafka.server.KafkaConfig, kafka.server.MetadataCache, scala.Option, scala.Option, scala.Option, scala.Option, org.apache.kafka.coordinator.group.GroupCoordinator, kafka.coordinator.transaction.TransactionCoordinator)]]
+ */
+ @deprecated("Use the alternative apply method", "3.8.0")
Review Comment:
Deleted the method :)
--
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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Clean up core server classes [kafka]
Posted by "jlprat (via GitHub)" <gi...@apache.org>.
jlprat commented on PR #15272:
URL: https://github.com/apache/kafka/pull/15272#issuecomment-1916544246
Needed to rebase because of merge conflicts
--
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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org