-
Notifications
You must be signed in to change notification settings - Fork 3.3k
feat(readOnly): support read only datahub deployments #15301
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
RyanHolstien
merged 8 commits into
datahub-project:master
from
RyanHolstien:feat/supportReadReplica
Nov 20, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cc31d1a
feat(readOnly): support read only datahub deployments
RyanHolstien 3c6d539
spotless
RyanHolstien 2690f14
Merge branch 'master' into feat/supportReadReplica
RyanHolstien 6f6e95c
review comments
RyanHolstien b832d2c
Merge branch 'master' into feat/supportReadReplica
RyanHolstien c90b143
fix dep cycle
RyanHolstien 9766b96
fix test
RyanHolstien e10e901
Merge branch 'master' into feat/supportReadReplica
RyanHolstien 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
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
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
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
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
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
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
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
61 changes: 61 additions & 0 deletions
61
.../kafka-producer/src/main/java/com/linkedin/metadata/dao/producer/GenericProducerImpl.java
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,61 @@ | ||
| package com.linkedin.metadata.dao.producer; | ||
|
|
||
| import static com.linkedin.metadata.Constants.READ_ONLY_LOG; | ||
|
|
||
| import com.linkedin.metadata.event.GenericProducer; | ||
| import com.linkedin.metadata.utils.metrics.MetricUtils; | ||
| import java.util.Optional; | ||
| import java.util.concurrent.CompletableFuture; | ||
| import java.util.concurrent.Future; | ||
| import javax.annotation.Nullable; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.apache.kafka.clients.producer.Callback; | ||
| import org.apache.kafka.clients.producer.Producer; | ||
| import org.apache.kafka.clients.producer.ProducerRecord; | ||
|
|
||
| @Slf4j | ||
| public class GenericProducerImpl<T> implements GenericProducer<T> { | ||
| private final Producer<String, T> producer; | ||
| private final KafkaHealthChecker kafkaHealthChecker; | ||
| private final MetricUtils metricUtils; | ||
| private boolean canWrite = true; | ||
|
|
||
| public GenericProducerImpl( | ||
| Producer<String, T> producer, | ||
| KafkaHealthChecker kafkaHealthChecker, | ||
| MetricUtils metricUtils) { | ||
| this.producer = producer; | ||
| this.kafkaHealthChecker = kafkaHealthChecker; | ||
| this.metricUtils = metricUtils; | ||
| } | ||
|
|
||
| @Override | ||
| public void setWritable(boolean writable) { | ||
| canWrite = writable; | ||
| } | ||
|
|
||
| @Override | ||
| public Future<?> send(ProducerRecord<String, T> producerRecord, @Nullable Callback callback) { | ||
| if (!canWrite) { | ||
| log.warn(READ_ONLY_LOG); | ||
| return CompletableFuture.completedFuture(Optional.empty()); | ||
| } | ||
| Callback finalCallback; | ||
| if (callback == null) { | ||
| finalCallback = | ||
| kafkaHealthChecker.getKafkaCallBack( | ||
| metricUtils, | ||
| "GENERIC", | ||
| producerRecord.key() != null ? producerRecord.key() : StringUtils.EMPTY); | ||
| } else { | ||
| finalCallback = callback; | ||
| } | ||
| return producer.send(producerRecord, finalCallback); | ||
| } | ||
|
|
||
| @Override | ||
| public void flush() { | ||
| producer.flush(); | ||
| } | ||
| } |
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
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.
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.
I thought there was another producer besides this one?
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.
There's the one for usage and platform events which should still be relevant even in read mode to capture when someone is making read calls. Unless we think read-only should not produce any analytics about its usage.