KAFKA-18514: Refactor share module code to server and server-common (#18524)

As per the discussion with @ijuma and @mumrah, the `share` module seems not required and it's advised to user `server` and `server-common` instead. The PR moves the classes from `share` module to respective server related modules.

Following has been refactored in the PR:

- Moved Share Fetch, Acknowledge, Session, Context and Cache related classes to `server` module as the classes are used by `core` and `tools` modules.
- Moved `Persister` releated classes from `share` to `server-common` as the Persister classes though currently just being used by `core` module but in [near future](https://github.com/apache/kafka/pull/17775) will also be used by `group-coordinator`. Hence the Persister classes shouldn't go in `server`. The debate is mostly between `coordinator-common` vs `server-common`. We have kept the Persister in `server-common` for now, the classes are more related to the server than the coordinator. Persister is basically an abstraction in the server to let you choose how you want to persist the share group progress.
- Updated build.gradle to remove `share` module.
- Removed `import-control-share.xml`

Reviewers: Ismael Juma <ismael@juma.me.uk>
This commit is contained in:
Apoorv Mittal 2025-01-16 08:14:25 +00:00 committed by GitHub
parent 14daa23b59
commit a1f7457389
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
58 changed files with 9 additions and 94 deletions

View File

@ -1027,34 +1027,6 @@ project(':server') {
}
}
project(':share') {
base {
archivesName = "kafka-share"
}
dependencies {
implementation project(':server-common')
implementation libs.slf4jApi
testImplementation project(':clients').sourceSets.test.output
testImplementation project(':server-common').sourceSets.test.output
testImplementation libs.junitJupiter
testImplementation libs.mockitoCore
testImplementation testLog4j2Libs
testRuntimeOnly runtimeTestLibs
}
checkstyle {
configProperties = checkstyleConfigProperties("import-control-share.xml")
}
javadoc {
enabled = false
}
}
project(':core') {
apply plugin: 'scala'
@ -1106,7 +1078,6 @@ project(':core') {
implementation project(':storage')
implementation project(':server')
implementation project(':coordinator-common')
implementation project(':share')
implementation project(':share-coordinator')
implementation libs.argparse4j
@ -1131,7 +1102,6 @@ project(':core') {
testImplementation project(':server-common').sourceSets.test.output
testImplementation project(':storage:storage-api').sourceSets.test.output
testImplementation project(':server').sourceSets.test.output
testImplementation project(':share').sourceSets.test.output
testImplementation project(':test-common')
testImplementation project(':test-common:test-common-api')
testImplementation libs.bcpkix
@ -1769,7 +1739,6 @@ project(':share-coordinator') {
implementation project(':coordinator-common')
implementation project(':metadata')
implementation project(':server-common')
implementation project(':share')
implementation libs.metrics
implementation libs.slf4jApi
@ -2467,7 +2436,6 @@ project(':tools') {
implementation project(':group-coordinator')
implementation project(':coordinator-common')
implementation project(':share-coordinator')
implementation project(':share')
implementation libs.argparse4j
implementation libs.jacksonDatabind
implementation libs.jacksonDataformatCsv

View File

@ -98,6 +98,15 @@
<allow pkg="org.apache.kafka.server.util" />
</subpackage>
<subpackage name="share">
<allow pkg="org.apache.kafka.server.share" />
<subpackage name="persister">
<allow pkg="org.apache.kafka.clients" />
<allow pkg="org.apache.kafka.server.util" />
<allow pkg="org.apache.kafka.test" />
</subpackage>
</subpackage>
<subpackage name="util">
<!-- InterBrokerSendThread uses some clients classes that are not part of the public -->
<!-- API but are still relatively common -->

View File

@ -1,62 +0,0 @@
<!DOCTYPE import-control PUBLIC
"-//Puppy Crawl//DTD Import Control 1.1//EN"
"http://www.puppycrawl.com/dtds/import_control_1_1.dtd">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<import-control pkg="org.apache.kafka">
<!-- THINK HARD ABOUT THE LAYERING OF THE PROJECT BEFORE CHANGING THIS FILE -->
<!-- common library dependencies -->
<allow pkg="java" />
<allow pkg="org.slf4j" />
<allow pkg="org.junit" />
<allow pkg="org.mockito" />
<!-- no one depends on the server -->
<disallow pkg="kafka" />
<!-- anyone can use public classes -->
<allow pkg="org.apache.kafka.common" exact-match="true" />
<allow pkg="org.apache.kafka.common.utils" />
<allow pkg="org.apache.kafka.common.annotation" />
<!-- protocol, records and request/response utilities -->
<allow pkg="org.apache.kafka.common.message" />
<allow pkg="org.apache.kafka.common.protocol" />
<allow pkg="org.apache.kafka.common.requests" />
<subpackage name="server">
<subpackage name="share">
<allow pkg="org.apache.kafka.server.share" />
<subpackage name="fetch">
<allow pkg="org.apache.kafka.server.purgatory" />
<allow class="org.apache.kafka.server.storage.log.FetchParams"/>
</subpackage>
<subpackage name="persister">
<allow pkg="org.apache.kafka.clients" />
<allow pkg="org.apache.kafka.common.internals" />
<allow pkg="org.apache.kafka.server.util" />
<allow pkg="org.apache.kafka.test" />
</subpackage>
</subpackage>
</subpackage>
</import-control>