-
Notifications
You must be signed in to change notification settings - Fork 14k
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
KAFKA-12342; Merge RaftClient and MetaLogManager interfaces and remove shim #10497
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bf5ed4b
KAFKA-12342; Merge RaftClient and MetaLogManager interfaces and remov…
49934ef
Merge remote-tracking branch 'upstream/trunk' into KAFKA-12342
2340d7f
Move reader iteration to event handler
ac1bb30
Merge remote-tracking branch 'upstream/trunk' into KAFKA-12342
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 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -37,7 +37,7 @@ import org.apache.kafka.common.security.JaasContext | |
import org.apache.kafka.common.security.auth.SecurityProtocol | ||
import org.apache.kafka.common.utils.{LogContext, Time} | ||
import org.apache.kafka.raft.RaftConfig.{AddressSpec, InetAddressSpec, NON_ROUTABLE_ADDRESS, UnknownAddressSpec} | ||
import org.apache.kafka.raft.{FileBasedStateStore, KafkaRaftClient, RaftClient, RaftConfig, RaftRequest, RecordSerde} | ||
import org.apache.kafka.raft.{FileBasedStateStore, KafkaRaftClient, LeaderAndEpoch, RaftClient, RaftConfig, RaftRequest, RecordSerde} | ||
|
||
import scala.jdk.CollectionConverters._ | ||
|
||
|
@@ -101,6 +101,10 @@ trait RaftManager[T] { | |
epoch: Int, | ||
records: Seq[T] | ||
): Option[Long] | ||
|
||
def leaderAndEpoch: LeaderAndEpoch | ||
|
||
def client: RaftClient[T] | ||
} | ||
|
||
class KafkaRaftManager[T]( | ||
|
@@ -126,10 +130,10 @@ class KafkaRaftManager[T]( | |
private val dataDir = createDataDir() | ||
private val metadataLog = buildMetadataLog() | ||
private val netChannel = buildNetworkChannel() | ||
private val raftClient = buildRaftClient() | ||
private val raftIoThread = new RaftIoThread(raftClient, threadNamePrefix) | ||
val client: KafkaRaftClient[T] = buildRaftClient() | ||
private val raftIoThread = new RaftIoThread(client, threadNamePrefix) | ||
|
||
def kafkaRaftClient: KafkaRaftClient[T] = raftClient | ||
def kafkaRaftClient: KafkaRaftClient[T] = client | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that since you added a new method |
||
|
||
def startup(): Unit = { | ||
// Update the voter endpoints (if valid) with what's in RaftConfig | ||
|
@@ -152,7 +156,7 @@ class KafkaRaftManager[T]( | |
|
||
def shutdown(): Unit = { | ||
raftIoThread.shutdown() | ||
raftClient.close() | ||
client.close() | ||
scheduler.shutdown() | ||
netChannel.close() | ||
metadataLog.close() | ||
|
@@ -161,7 +165,7 @@ class KafkaRaftManager[T]( | |
override def register( | ||
listener: RaftClient.Listener[T] | ||
): Unit = { | ||
raftClient.register(listener) | ||
client.register(listener) | ||
} | ||
|
||
override def scheduleAtomicAppend( | ||
|
@@ -184,9 +188,9 @@ class KafkaRaftManager[T]( | |
isAtomic: Boolean | ||
): Option[Long] = { | ||
val offset = if (isAtomic) { | ||
raftClient.scheduleAtomicAppend(epoch, records.asJava) | ||
client.scheduleAtomicAppend(epoch, records.asJava) | ||
} else { | ||
raftClient.scheduleAppend(epoch, records.asJava) | ||
client.scheduleAppend(epoch, records.asJava) | ||
} | ||
|
||
Option(offset).map(Long.unbox) | ||
|
@@ -203,7 +207,7 @@ class KafkaRaftManager[T]( | |
createdTimeMs | ||
) | ||
|
||
raftClient.handle(inboundRequest) | ||
client.handle(inboundRequest) | ||
|
||
inboundRequest.completion.thenApply { response => | ||
response.data | ||
|
@@ -308,4 +312,7 @@ class KafkaRaftManager[T]( | |
) | ||
} | ||
|
||
override def leaderAndEpoch: LeaderAndEpoch = { | ||
client.leaderAndEpoch | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to override the return type from
RaftClient[T]
toKafkaRaftClient[T]
?