-
Notifications
You must be signed in to change notification settings - Fork 11
feat(inkless): POD-2392 Implement consolidating partition tracking #567
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d257e1c
feat(inkless): POD-2392 Implement consolidating partition tracking
viktorsomogyi 6772b84
Address copilot review comments
viktorsomogyi 5ce20de
Use full leader set to remove from fetchers
viktorsomogyi c684ee9
Update core/src/main/scala/kafka/server/ReplicaManager.scala
viktorsomogyi 3fa8e4a
Address copilot review comments
viktorsomogyi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
core/src/main/scala/io/aiven/inkless/consolidation/ConsolidationFetcherManager.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * Inkless | ||
| * Copyright (C) 2024 - 2026 Aiven OY | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package io.aiven.inkless.consolidation | ||
|
|
||
| import kafka.server.{AbstractFetcherManager, KafkaConfig, ReplicaManager, ReplicationQuotaManager} | ||
| import org.apache.kafka.common.utils.LogContext | ||
| import org.apache.kafka.server.network.BrokerEndPoint | ||
|
|
||
| class ConsolidationFetcherManager(brokerConfig: KafkaConfig, | ||
| replicaManager: ReplicaManager, | ||
| quotaManager: ReplicationQuotaManager) | ||
| extends AbstractFetcherManager[ConsolidationFetcherThread](name = "ConsolidationFetcherManager on broker " + brokerConfig.brokerId, | ||
| clientId = "Consolidation", | ||
| numFetchers = brokerConfig.numReplicaFetchers) { | ||
|
|
||
| override def createFetcherThread(fetcherId: Int, sourceBroker: BrokerEndPoint): ConsolidationFetcherThread = { | ||
| val threadName = s"ConsolidationFetcherThread-$fetcherId-${sourceBroker.id}" | ||
| val logContext = new LogContext(s"[ConsolidationFetcher replicaId=${brokerConfig.brokerId}, leaderId=${sourceBroker.id}, " + | ||
| s"fetcherId=$fetcherId] ") | ||
| val disklessLeaderEndPoint = new DisklessLeaderEndPoint(sourceBroker) | ||
| new ConsolidationFetcherThread(threadName, disklessLeaderEndPoint, brokerConfig, failedPartitions, replicaManager, | ||
| quotaManager, logContext.logPrefix) | ||
| } | ||
|
|
||
| def shutdown(): Unit = { | ||
| info("shutting down") | ||
| closeAllFetchers() | ||
| info("shutdown completed") | ||
| } | ||
| } |
40 changes: 40 additions & 0 deletions
40
core/src/main/scala/io/aiven/inkless/consolidation/ConsolidationFetcherThread.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * Inkless | ||
| * Copyright (C) 2024 - 2026 Aiven OY | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package io.aiven.inkless.consolidation | ||
|
|
||
| import io.aiven.inkless.consume.ConcatenatedRecords | ||
| import kafka.server.{FailedPartitions, KafkaConfig, ReplicaFetcherThread, ReplicaManager, ReplicaQuota} | ||
| import org.apache.kafka.common.record.{MemoryRecords, Records} | ||
| import org.apache.kafka.server.LeaderEndPoint | ||
|
|
||
| class ConsolidationFetcherThread(name: String, | ||
| leader: LeaderEndPoint, | ||
| brokerConfig: KafkaConfig, | ||
| failedPartitions: FailedPartitions, | ||
| replicaMgr: ReplicaManager, | ||
| quota: ReplicaQuota, | ||
| logPrefix: String) extends ReplicaFetcherThread(name, leader, brokerConfig, failedPartitions, replicaMgr, quota, logPrefix) { | ||
|
|
||
| override def toMemoryRecords(records: Records): MemoryRecords = { | ||
| (records: @unchecked) match { | ||
| case r: ConcatenatedRecords => r.toMemoryRecords | ||
| case _ => super.toMemoryRecords(records) | ||
| } | ||
| } | ||
| } |
120 changes: 120 additions & 0 deletions
120
core/src/main/scala/io/aiven/inkless/consolidation/DisklessLeaderEndPoint.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| /* | ||
| * Inkless | ||
| * Copyright (C) 2024 - 2026 Aiven OY | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package io.aiven.inkless.consolidation | ||
|
|
||
| import org.apache.kafka.common.TopicPartition | ||
| import org.apache.kafka.common.message.{FetchResponseData, OffsetForLeaderEpochRequestData, OffsetForLeaderEpochResponseData} | ||
| import org.apache.kafka.common.requests.FetchRequest | ||
| import org.apache.kafka.server.common.OffsetAndEpoch | ||
| import org.apache.kafka.server.network.BrokerEndPoint | ||
| import org.apache.kafka.server.{LeaderEndPoint, PartitionFetchState, ReplicaFetch, ResultWithPartitions} | ||
|
|
||
| import java.util | ||
| import java.util.Optional | ||
|
|
||
| class DisklessLeaderEndPoint(brokerEndPoint: BrokerEndPoint) extends LeaderEndPoint { | ||
|
|
||
| /** | ||
| * A boolean specifying if truncation when fetching from the leader is supported | ||
| */ | ||
| override def isTruncationOnFetchSupported: Boolean = false | ||
|
|
||
| /** | ||
| * Initiate closing access to fetches from leader. | ||
| */ | ||
| override def initiateClose(): Unit = { | ||
| } | ||
|
|
||
| /** | ||
| * Closes access to fetches from leader. | ||
| * `initiateClose` must be called prior to invoking `close`. | ||
| */ | ||
| override def close(): Unit = { | ||
| } | ||
|
|
||
| /** | ||
| * The specific broker (host:port) we want to connect to. | ||
| */ | ||
| override def brokerEndPoint(): BrokerEndPoint = { | ||
| brokerEndPoint | ||
| } | ||
|
|
||
| /** | ||
| * Given a fetchRequest, carries out the expected request and returns | ||
| * the results from fetching from the leader. | ||
| * | ||
| * @param fetchRequest The fetch request we want to carry out | ||
| * @return A map of topic partition -> fetch data | ||
| */ | ||
| override def fetch(fetchRequest: FetchRequest.Builder): util.Map[TopicPartition, FetchResponseData.PartitionData] = | ||
| util.Map.of[TopicPartition, FetchResponseData.PartitionData] | ||
|
viktorsomogyi marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Fetches the epoch and log start offset of the given topic partition from the leader. | ||
| * | ||
| * @param topicPartition The topic partition that we want to fetch from | ||
| * @param currentLeaderEpoch An int representing the current leader epoch of the requester | ||
| * @return An OffsetAndEpoch object representing the earliest offset and epoch in the leader's topic partition. | ||
| */ | ||
| override def fetchEarliestOffset(topicPartition: TopicPartition, currentLeaderEpoch: Int): OffsetAndEpoch = { | ||
| return new OffsetAndEpoch(0, 0) | ||
| } | ||
|
viktorsomogyi marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Fetches the epoch and log end offset of the given topic partition from the leader. | ||
| * | ||
| * @param topicPartition The topic partition that we want to fetch from | ||
| * @param currentLeaderEpoch An int representing the current leader epoch of the requester | ||
| * @return An OffsetAndEpoch object representing the latest offset and epoch in the leader's topic partition. | ||
| */ | ||
| override def fetchLatestOffset(topicPartition: TopicPartition, currentLeaderEpoch: Int): OffsetAndEpoch = { | ||
| return new OffsetAndEpoch(0, 0) | ||
| } | ||
|
|
||
| /** | ||
| * Fetches offset for leader epoch from the leader for each given topic partition | ||
| * | ||
| * @param partitions A map of topic partition -> leader epoch of the replica | ||
| * @return A map of topic partition -> end offset for a requested leader epoch | ||
| */ | ||
| override def fetchEpochEndOffsets(partitions: util.Map[TopicPartition, OffsetForLeaderEpochRequestData.OffsetForLeaderPartition]): util.Map[TopicPartition, OffsetForLeaderEpochResponseData.EpochEndOffset] = { | ||
| util.Map.of[TopicPartition, OffsetForLeaderEpochResponseData.EpochEndOffset]() | ||
| } | ||
|
|
||
| /** | ||
| * Fetches the epoch and local log start offset from the leader for the given partition and the current leader-epoch | ||
| * | ||
| * @param topicPartition The topic partition that we want to fetch from | ||
| * @param currentLeaderEpoch An int representing the current leader epoch of the requester | ||
| * @return An OffsetAndEpoch object representing the earliest local offset and epoch in the leader's topic partition. | ||
| */ | ||
| override def fetchEarliestLocalOffset(topicPartition: TopicPartition, currentLeaderEpoch: Int): OffsetAndEpoch = { | ||
| new OffsetAndEpoch(0, 0) | ||
| } | ||
|
|
||
| /** | ||
| * Builds a fetch request, given a partition map. | ||
| * | ||
| * @param partitions A map of topic partitions to their respective partition fetch state | ||
| * @return A ResultWithPartitions, used to create the fetchRequest for fetch. | ||
| */ | ||
| override def buildFetch(partitions: util.Map[TopicPartition, PartitionFetchState]): ResultWithPartitions[Optional[ReplicaFetch]] = { | ||
| new ResultWithPartitions[Optional[ReplicaFetch]](Optional.empty(), util.Set.of()) | ||
|
viktorsomogyi marked this conversation as resolved.
|
||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.