-
Notifications
You must be signed in to change notification settings - Fork 3.8k
confluent schema registry client to accept config and headers #9096
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
Changes from all commits
9c5900c
5e88ab9
bc86438
badb913
354cb4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,10 @@ | |
| import org.apache.avro.io.DecoderFactory; | ||
| import org.apache.druid.java.util.common.parsers.ParseException; | ||
|
|
||
| import javax.annotation.Nullable; | ||
| import java.nio.ByteBuffer; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
|
|
||
| public class SchemaRegistryBasedAvroBytesDecoder implements AvroBytesDecoder | ||
|
|
@@ -41,11 +44,18 @@ public class SchemaRegistryBasedAvroBytesDecoder implements AvroBytesDecoder | |
| @JsonCreator | ||
| public SchemaRegistryBasedAvroBytesDecoder( | ||
| @JsonProperty("url") String url, | ||
| @JsonProperty("capacity") Integer capacity | ||
| @JsonProperty("capacity") Integer capacity, | ||
| @JsonProperty("urls") @Nullable List<String> urls, | ||
|
Member
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 it would probably make sense to mark the Additionally, would you mind adding a JSON serialization/deserialization unit test for this class to make sure the new properties work as expected? |
||
| @JsonProperty("config") @Nullable Map<String, ?> config, | ||
| @JsonProperty("headers") @Nullable Map<String, String> headers | ||
| ) | ||
| { | ||
| int identityMapCapacity = capacity == null ? Integer.MAX_VALUE : capacity; | ||
| this.registry = new CachedSchemaRegistryClient(url, identityMapCapacity); | ||
| if (!url.isEmpty()) { | ||
| this.registry = new CachedSchemaRegistryClient(url, identityMapCapacity, config, headers); | ||
| } else { | ||
| this.registry = new CachedSchemaRegistryClient(urls, identityMapCapacity, config, headers); | ||
| } | ||
| } | ||
|
|
||
| //For UT only | ||
|
|
@@ -63,7 +73,7 @@ public GenericRecord parse(ByteBuffer bytes) | |
| int id = bytes.getInt(); // extract schema registry id | ||
| int length = bytes.limit() - 1 - 4; | ||
| int offset = bytes.position() + bytes.arrayOffset(); | ||
| Schema schema = registry.getByID(id); | ||
| Schema schema = registry.getById(id); | ||
| DatumReader<GenericRecord> reader = new GenericDatumReader<>(schema); | ||
| return reader.read(null, DecoderFactory.get().binaryDecoder(bytes.array(), offset, length, null)); | ||
| } | ||
|
|
||
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.
This is why CI is failing, could you update the entry for this in licenses.yaml. We use this file to ensure we keep our
LICENSEinformation correct to make doing releases easier.Based on the error message in CI, it looks like maybe the new version pulls in a few additional jars, so you might need to add a few additional entries for
extensions/druid-avro-extensions(or exclude these jars if they aren't actually needed for operation of the extension)