Package io.confluent.kafka.serializers
Class AbstractKafkaSchemaSerDe
java.lang.Object
io.confluent.kafka.serializers.AbstractKafkaSchemaSerDe
- All Implemented Interfaces:
Closeable,AutoCloseable
Common fields and helper methods for both the serializer and the deserializer.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AbstractKafkaSchemaSerDeConfigprotected ContextNameStrategyprotected static final intprotected booleanprotected booleanprotected SchemaIdDeserializerprotected SchemaIdSerializerprotected SubjectNameStrategyprotected com.google.common.cache.Cache<AbstractKafkaSchemaSerDe.SubjectSchema,AbstractKafkaSchemaSerDe.ExtendedSchema> protected com.google.common.cache.Cache<String,AbstractKafkaSchemaSerDe.ExtendedSchema> protected SchemaRegistryClientprotected com.google.common.base.Tickerprotected booleanprotected booleanprotected SchemaIdDeserializerprotected SchemaIdSerializerprotected SubjectNameStrategy -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclearKey()voidclose()protected voidconfigureClientProperties(AbstractKafkaSchemaSerDeConfig config, SchemaProvider provider) protected ObjectexecuteMigrations(List<AbstractKafkaSchemaSerDe.Migration> migrations, String subject, String topic, org.apache.kafka.common.header.Headers headers, Object message) protected ObjectexecuteRules(String subject, String topic, org.apache.kafka.common.header.Headers headers, RuleMode ruleMode, ParsedSchema source, ParsedSchema target, Object message) protected ObjectexecuteRules(String subject, String topic, org.apache.kafka.common.header.Headers headers, Object original, RuleMode ruleMode, ParsedSchema source, ParsedSchema target, Object message) protected ObjectexecuteRules(String subject, String topic, org.apache.kafka.common.header.Headers headers, Object original, RulePhase rulePhase, RuleMode ruleMode, ParsedSchema source, ParsedSchema target, Object message) org.apache.avro.SchemagetById(int id) Deprecated.org.apache.avro.SchemagetBySubjectAndId(String subject, int id) Deprecated.protected StringgetContextName(String topic) protected StringgetContextName(String topic, String subject) protected AbstractKafkaSchemaSerDe.ExtendedSchemagetLatestWithMetadata(String subject) protected List<AbstractKafkaSchemaSerDe.Migration>getMigrations(String subject, ParsedSchema writerSchema, ParsedSchema readerSchema) protected StringgetOldSubjectName(Object value) Get the subject name used by the old Encoder interface, which relies only on the value type rather than the topic.getSchemaById(int id) protected ParsedSchemagetSchemaBySchemaId(String subject, SchemaId schemaId) getSchemaBySubjectAndId(String subject, int id) protected StringgetSubjectName(String topic, boolean isKey, Object value, ParsedSchema schema) Get the subject name for the given topic and value type.booleanisKey()static Objectkey()protected Map<String,AbstractKafkaSchemaSerDe.ExtendedSchema> protected static AbstractKafkaSchemaSerDe.ExtendedSchemalookupLatestVersion(SchemaRegistryClient schemaRegistry, String subject, ParsedSchema schema, Map<AbstractKafkaSchemaSerDe.SubjectSchema, AbstractKafkaSchemaSerDe.ExtendedSchema> cache, boolean latestCompatStrict) protected AbstractKafkaSchemaSerDe.ExtendedSchemalookupLatestVersion(String subject, ParsedSchema schema, boolean latestCompatStrict) protected ParsedSchemalookupSchemaBySubjectAndId(String subject, int id, ParsedSchema schema, boolean idCompatStrict) protected voidintregister(String subject, ParsedSchema schema) intregister(String subject, ParsedSchema schema, boolean normalize) intDeprecated.protected SchemaregisterWithResponse(String subject, ParsedSchema schema, boolean normalize, boolean propagateSchemaTags) protected SchemaIdDeserializerschemaIdDeserializer(boolean isKey) protected SchemaIdSerializerschemaIdSerializer(boolean isKey) static voidprotected booleanstrategyUsesSchema(boolean isKey) protected com.google.common.base.Tickerticker(SchemaRegistryClient client) protected static org.apache.kafka.common.KafkaExceptiontoKafkaException(RestClientException e, String errorMessage)
-
Field Details
-
DEFAULT_CACHE_CAPACITY
protected static final int DEFAULT_CACHE_CAPACITY- See Also:
-
config
-
configOriginals
-
schemaRegistry
-
ticker
protected com.google.common.base.Ticker ticker -
contextNameStrategy
-
keySubjectNameStrategy
-
keySchemaIdSerializer
-
keySchemaIdDeserializer
-
valueSubjectNameStrategy
-
valueSchemaIdSerializer
-
valueSchemaIdDeserializer
-
latestVersions
protected com.google.common.cache.Cache<AbstractKafkaSchemaSerDe.SubjectSchema,AbstractKafkaSchemaSerDe.ExtendedSchema> latestVersions -
latestWithMetadata
protected com.google.common.cache.Cache<String,AbstractKafkaSchemaSerDe.ExtendedSchema> latestWithMetadata -
useSchemaReflection
protected boolean useSchemaReflection -
useLatestVersion
protected boolean useLatestVersion -
metadata
-
enableRuleServiceLoader
protected boolean enableRuleServiceLoader -
ruleExecutors
-
ruleActions
-
isKey
protected boolean isKey
-
-
Constructor Details
-
AbstractKafkaSchemaSerDe
public AbstractKafkaSchemaSerDe()
-
-
Method Details
-
key
-
setKey
-
clearKey
public static void clearKey() -
ticker
-
configureClientProperties
protected void configureClientProperties(AbstractKafkaSchemaSerDeConfig config, SchemaProvider provider) -
postOp
-
getSchemaRegistryClient
-
getRuleExecutors
-
getRuleActions
-
isKey
public boolean isKey() -
latestVersionsCache
protected Map<AbstractKafkaSchemaSerDe.SubjectSchema,AbstractKafkaSchemaSerDe.ExtendedSchema> latestVersionsCache() -
latestWithMetadataCache
-
getLatestWithMetadata
protected AbstractKafkaSchemaSerDe.ExtendedSchema getLatestWithMetadata(String subject) throws IOException, RestClientException - Throws:
IOExceptionRestClientException
-
getMigrations
protected List<AbstractKafkaSchemaSerDe.Migration> getMigrations(String subject, ParsedSchema writerSchema, ParsedSchema readerSchema) throws IOException, RestClientException - Throws:
IOExceptionRestClientException
-
getSubjectName
Get the subject name for the given topic and value type. -
getContextName
-
getContextName
-
strategyUsesSchema
protected boolean strategyUsesSchema(boolean isKey) -
schemaIdSerializer
-
schemaIdDeserializer
-
getOldSubjectName
Get the subject name used by the old Encoder interface, which relies only on the value type rather than the topic. -
register
@Deprecated public int register(String subject, org.apache.avro.Schema schema) throws IOException, RestClientException Deprecated.- Throws:
IOExceptionRestClientException
-
register
- Throws:
IOExceptionRestClientException
-
register
public int register(String subject, ParsedSchema schema, boolean normalize) throws IOException, RestClientException - Throws:
IOExceptionRestClientException
-
registerWithResponse
protected Schema registerWithResponse(String subject, ParsedSchema schema, boolean normalize, boolean propagateSchemaTags) throws IOException, RestClientException - Throws:
IOExceptionRestClientException
-
getById
Deprecated.- Throws:
IOExceptionRestClientException
-
getSchemaById
- Throws:
IOExceptionRestClientException
-
getBySubjectAndId
@Deprecated public org.apache.avro.Schema getBySubjectAndId(String subject, int id) throws IOException, RestClientException Deprecated.- Throws:
IOExceptionRestClientException
-
getSchemaBySubjectAndId
public ParsedSchema getSchemaBySubjectAndId(String subject, int id) throws IOException, RestClientException - Throws:
IOExceptionRestClientException
-
getSchemaBySchemaId
protected ParsedSchema getSchemaBySchemaId(String subject, SchemaId schemaId) throws IOException, RestClientException - Throws:
IOExceptionRestClientException
-
lookupSchemaBySubjectAndId
protected ParsedSchema lookupSchemaBySubjectAndId(String subject, int id, ParsedSchema schema, boolean idCompatStrict) throws IOException, RestClientException - Throws:
IOExceptionRestClientException
-
lookupLatestVersion
protected AbstractKafkaSchemaSerDe.ExtendedSchema lookupLatestVersion(String subject, ParsedSchema schema, boolean latestCompatStrict) throws IOException, RestClientException - Throws:
IOExceptionRestClientException
-
lookupLatestVersion
protected static AbstractKafkaSchemaSerDe.ExtendedSchema lookupLatestVersion(SchemaRegistryClient schemaRegistry, String subject, ParsedSchema schema, Map<AbstractKafkaSchemaSerDe.SubjectSchema, AbstractKafkaSchemaSerDe.ExtendedSchema> cache, boolean latestCompatStrict) throws IOException, RestClientException- Throws:
IOExceptionRestClientException
-
executeMigrations
protected Object executeMigrations(List<AbstractKafkaSchemaSerDe.Migration> migrations, String subject, String topic, org.apache.kafka.common.header.Headers headers, Object message) throws IOException - Throws:
IOException
-
executeRules
protected Object executeRules(String subject, String topic, org.apache.kafka.common.header.Headers headers, RuleMode ruleMode, ParsedSchema source, ParsedSchema target, Object message) -
executeRules
protected Object executeRules(String subject, String topic, org.apache.kafka.common.header.Headers headers, Object original, RuleMode ruleMode, ParsedSchema source, ParsedSchema target, Object message) -
executeRules
protected Object executeRules(String subject, String topic, org.apache.kafka.common.header.Headers headers, Object original, RulePhase rulePhase, RuleMode ruleMode, ParsedSchema source, ParsedSchema target, Object message) -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
toKafkaException
protected static org.apache.kafka.common.KafkaException toKafkaException(RestClientException e, String errorMessage)
-