public class KafkaSchemaRegistry extends Object implements SchemaRegistry, LeaderAwareSchemaRegistry, SslFactory.SslFactoryCreated
| Modifier and Type | Class and Description |
|---|---|
static class |
KafkaSchemaRegistry.SchemeAndPort |
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_VERSION |
static int |
MIN_VERSION
Schema versions under a particular subject are indexed from MIN_VERSION.
|
DEFAULT_TENANT| Constructor and Description |
|---|
KafkaSchemaRegistry(SchemaRegistryConfig config,
Serializer<SchemaRegistryKey,SchemaRegistryValue> serializer) |
| Modifier and Type | Method and Description |
|---|---|
void |
addCustomHandler(org.eclipse.jetty.server.handler.HandlerWrapper handler) |
void |
addLeaderChangeListener(Consumer<Boolean> listener)
Add a leader change listener.
|
void |
addUpdateRequestHandler(UpdateRequestHandler updateRequestHandler) |
Iterator<ExtendedSchema> |
allVersionsIncludingAliasesWithSubjectPrefix(String prefix,
LookupFilter filter,
boolean returnLatestOnly,
Predicate<Schema> postFilter) |
void |
checkIfSchemaWithIdExist(int id,
Schema schema) |
void |
clearNewSchemaCache() |
void |
clearOldSchemaCache() |
void |
close() |
SchemaRegistryConfig |
config() |
void |
deleteConfigOrForward(String subject,
Map<String,String> headerProperties) |
void |
deleteSchemaVersion(String subject,
Schema schema,
boolean permanentDelete) |
void |
deleteSchemaVersionOrForward(Map<String,String> headerProperties,
String subject,
Schema schema,
boolean permanentDelete) |
List<Integer> |
deleteSubject(String subject,
boolean permanentDelete) |
void |
deleteSubjectConfig(String subject) |
void |
deleteSubjectMode(String subject) |
void |
deleteSubjectMode(String subject,
boolean recursive) |
void |
deleteSubjectModeOrForward(String subject,
boolean recursive,
Map<String,String> headerProperties) |
List<Integer> |
deleteSubjectOrForward(Map<String,String> requestProperties,
String subject,
boolean permanentDelete) |
void |
extractSchemaTags(Schema schema,
List<String> tags) |
Schema |
forwardModifySchemaTagsRequestToLeader(String subject,
Schema schema,
TagSchemaRequest request,
Map<String,String> headerProperties) |
SchemaString |
get(int id,
String subject) |
SchemaString |
get(int id,
String subject,
String format,
boolean fetchMaxId) |
Schema |
get(String subject,
int version,
boolean returnDeletedSchema) |
Iterator<SchemaKey> |
getAllVersions(String subject,
LookupFilter filter) |
UpdateRequestHandler |
getCompositeUpdateRequestHandler() |
Config |
getConfig(String subject) |
Config |
getConfigInScope(String subject) |
protected String |
getContextPrefixForDeleteMode(String context)
Returns the context prefix to use for listing subjects under a given context.
|
List<org.eclipse.jetty.server.handler.HandlerWrapper> |
getCustomHandler() |
String |
getGroupId() |
HostnameVerifier |
getHostnameVerifier() |
IdGenerator |
getIdentityGenerator() |
static io.confluent.rest.NamedURI |
getInterInstanceListener(List<io.confluent.rest.NamedURI> listeners,
String interInstanceListenerName,
String requestedScheme)
This method returns a listener to be used for inter-instance communication.
|
String |
getKafkaClusterId() |
Schema |
getLatestVersion(String subject) |
Schema |
getLatestWithMetadata(String subject,
Map<String,String> metadata,
boolean lookupDeletedSchema) |
LookupCache<SchemaRegistryKey,SchemaRegistryValue> |
getLookupCache() |
MetadataEncoderService |
getMetadataEncoder() |
MetricsContainer |
getMetricsContainer() |
Mode |
getMode(String subject) |
Mode |
getModeInScope(String subject) |
List<Integer> |
getReferencedBy(String subject,
VersionId versionId) |
List<SchemaRegistryResourceExtension> |
getResourceExtensions() |
RuleSetHandler |
getRuleSetHandler() |
protected SchemaUpdateHandler |
getSchemaUpdateHandler(SchemaRegistryConfig config) |
protected SchemaValue |
getSchemaValue(SchemaKey key) |
Serializer<SchemaRegistryKey,SchemaRegistryValue> |
getSerializer() |
SslFactory |
getSslFactory() |
Schema |
getUsingContexts(String subject,
int version,
boolean returnDeletedSchema) |
Iterator<ExtendedSchema> |
getVersionsWithSubjectPrefix(String prefix,
boolean includeAliases,
LookupFilter filter,
boolean returnLatestOnly,
Predicate<Schema> postFilter) |
boolean |
hasSubjects(String subject,
boolean lookupDeletedSubjects) |
boolean |
healthy() |
protected IdGenerator |
identityGenerator(SchemaRegistryConfig config) |
void |
init() |
boolean |
initialized() |
void |
invalidateFromNewSchemaCache(Schema schemaKey)
Invalidate the cached parsed schema for a new schema.
|
void |
invalidateFromOldSchemaCache(Schema schemaKey)
Invalidate the cached parsed schema for an old schema.
|
List<String> |
isCompatible(String subject,
Schema newSchema,
List<SchemaKey> previousSchemas,
boolean normalize) |
boolean |
isLeader() |
protected KafkaStore<SchemaRegistryKey,SchemaRegistryValue> |
kafkaStore(SchemaRegistryConfig config) |
SchemaRegistryIdentity |
leaderIdentity()
Return the identity of the SchemaRegistry that this instance thinks is current leader.
|
RestService |
leaderRestService() |
List<String> |
listContexts() |
Set<String> |
listSubjects(LookupFilter filter) |
Set<String> |
listSubjectsForId(int id,
String subject) |
Set<String> |
listSubjectsForId(int id,
String subject,
boolean returnDeleted) |
Set<String> |
listSubjectsWithPrefix(String prefix,
LookupFilter filter) |
List<SubjectVersion> |
listVersionsForId(int id,
String subject) |
List<SubjectVersion> |
listVersionsForId(int id,
String subject,
boolean lookupDeleted) |
protected LookupCache<SchemaRegistryKey,SchemaRegistryValue> |
lookupCache() |
Schema |
lookUpSchemaUnderSubject(String subject,
Schema schema,
boolean normalize,
boolean lookupDeletedSchema)
Checks if given schema was ever registered under a subject.
|
Schema |
lookUpSchemaUnderSubjectUsingContexts(String subject,
Schema schema,
boolean normalize,
boolean lookupDeletedSchema) |
Schema |
modifySchemaTags(String subject,
Schema schema,
TagSchemaRequest request) |
Schema |
modifySchemaTagsOrForward(String subject,
Schema schema,
TagSchemaRequest request,
Map<String,String> headerProperties) |
SchemaRegistryIdentity |
myIdentity()
Return json data encoding basic information about this SchemaRegistry instance, such as
host, port, etc.
|
int |
normalizeContextLimit(int suppliedLimit) |
int |
normalizeLimit(int suppliedLimit,
int defaultLimit,
int maxLimit) |
int |
normalizeSchemaLimit(int suppliedLimit) |
int |
normalizeSubjectLimit(int suppliedLimit) |
int |
normalizeSubjectVersionLimit(int suppliedLimit) |
void |
onKeystoreCreated(KeyStore keystore) |
void |
onTruststoreCreated(KeyStore truststore) |
ParsedSchema |
parseSchema(Schema schema) |
ParsedSchema |
parseSchema(Schema schema,
boolean isNew,
boolean normalize) |
void |
postInit() |
Map<String,Object> |
properties() |
Schema |
register(String subject,
RegisterSchemaRequest request,
boolean normalize) |
Schema |
register(String subject,
Schema schema,
boolean normalize,
boolean propagateSchemaTags)
Register the given schema under the given subject.
|
Schema |
registerOrForward(String subject,
RegisterSchemaRequest request,
boolean normalize,
Map<String,String> headerProperties) |
void |
removeCustomHandler(org.eclipse.jetty.server.handler.HandlerWrapper handler) |
SchemaProvider |
schemaProvider(String schemaType) |
Set<String> |
schemaTypes() |
boolean |
schemaVersionExists(String subject,
VersionId versionId,
boolean returnDeletedSchema) |
void |
setLeader(SchemaRegistryIdentity newLeader)
'Inform' this SchemaRegistry instance which SchemaRegistry is the current leader.
|
void |
setMode(String subject,
ModeUpdateRequest mode) |
void |
setMode(String subject,
ModeUpdateRequest request,
boolean force) |
void |
setModeOrForward(String subject,
ModeUpdateRequest mode,
boolean force,
Map<String,String> headerProperties) |
void |
setRuleSetHandler(RuleSetHandler ruleSetHandler) |
Set<String> |
subjects(String subject,
boolean lookupDeletedSubjects) |
Schema |
toSchemaEntity(SchemaValue schemaValue) |
Config |
updateConfig(String subject,
ConfigUpdateRequest config) |
Config |
updateConfigOrForward(String subject,
ConfigUpdateRequest newConfig,
Map<String,String> headerProperties) |
void |
waitForInit() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetByVersion, listSubjects, lookUpSchemaUnderSubject, register, register, setTenant, tenantpublic static final int MIN_VERSION
public static final int MAX_VERSION
public KafkaSchemaRegistry(SchemaRegistryConfig config, Serializer<SchemaRegistryKey,SchemaRegistryValue> serializer) throws SchemaRegistryException
SchemaRegistryExceptionprotected KafkaStore<SchemaRegistryKey,SchemaRegistryValue> kafkaStore(SchemaRegistryConfig config) throws SchemaRegistryException
SchemaRegistryExceptionprotected SchemaUpdateHandler getSchemaUpdateHandler(SchemaRegistryConfig config)
public List<SchemaRegistryResourceExtension> getResourceExtensions()
protected LookupCache<SchemaRegistryKey,SchemaRegistryValue> lookupCache()
public LookupCache<SchemaRegistryKey,SchemaRegistryValue> getLookupCache()
public Serializer<SchemaRegistryKey,SchemaRegistryValue> getSerializer()
public MetadataEncoderService getMetadataEncoder()
public RuleSetHandler getRuleSetHandler()
public void setRuleSetHandler(RuleSetHandler ruleSetHandler)
public UpdateRequestHandler getCompositeUpdateRequestHandler()
public void addUpdateRequestHandler(UpdateRequestHandler updateRequestHandler)
protected IdGenerator identityGenerator(SchemaRegistryConfig config)
public IdGenerator getIdentityGenerator()
public MetricsContainer getMetricsContainer()
public static io.confluent.rest.NamedURI getInterInstanceListener(List<io.confluent.rest.NamedURI> listeners, String interInstanceListenerName, String requestedScheme) throws SchemaRegistryException
This method returns a listener to be used for inter-instance communication. It iterates through the list of listeners until it finds one whose name matches the inter.instance.listener.name config. If no such listener is found, it returns the last listener matching the requested scheme.
When there is no matching named listener, in theory, any port from any listener would be sufficient. Choosing the last, instead of say the first, is arbitrary. The port used by this listener also forms the identity of the schema registry instance along with the host name.
SchemaRegistryExceptionpublic void init()
throws SchemaRegistryException
init in interface SchemaRegistrySchemaRegistryExceptionpublic void postInit()
throws SchemaRegistryException
SchemaRegistryExceptionpublic void waitForInit()
throws InterruptedException
InterruptedExceptionpublic boolean initialized()
public boolean healthy()
public SslFactory getSslFactory()
public void addLeaderChangeListener(Consumer<Boolean> listener)
listener - a function that takes whether this node is a leaderpublic boolean isLeader()
public void setLeader(@Nullable
SchemaRegistryIdentity newLeader)
throws SchemaRegistryTimeoutException,
SchemaRegistryStoreException,
IdGenerationException
setLeader in interface LeaderAwareSchemaRegistrynewLeader - Identity of the current leader. null means no leader is alive.SchemaRegistryTimeoutExceptionSchemaRegistryStoreExceptionIdGenerationExceptionpublic SchemaRegistryIdentity myIdentity()
public SchemaRegistryIdentity leaderIdentity()
public RestService leaderRestService()
public Set<String> schemaTypes()
schemaTypes in interface SchemaRegistrypublic SchemaProvider schemaProvider(String schemaType)
public int normalizeLimit(int suppliedLimit,
int defaultLimit,
int maxLimit)
public int normalizeSchemaLimit(int suppliedLimit)
public int normalizeSubjectLimit(int suppliedLimit)
public int normalizeContextLimit(int suppliedLimit)
public int normalizeSubjectVersionLimit(int suppliedLimit)
public Schema register(String subject, RegisterSchemaRequest request, boolean normalize) throws SchemaRegistryException
SchemaRegistryExceptionpublic Schema register(String subject, Schema schema, boolean normalize, boolean propagateSchemaTags) throws SchemaRegistryException
If the schema already exists, it is returned. During registration, the metadata and ruleSet may be populated by the config that is in scope.
register in interface SchemaRegistrysubject - The subjectschema - The schemanormalize - Whether to normalize the schema before registrationSchemaRegistryExceptionpublic Schema registerOrForward(String subject, RegisterSchemaRequest request, boolean normalize, Map<String,String> headerProperties) throws SchemaRegistryException
SchemaRegistryExceptionpublic void extractSchemaTags(Schema schema, List<String> tags) throws SchemaRegistryException
SchemaRegistryExceptionpublic Schema modifySchemaTags(String subject, Schema schema, TagSchemaRequest request) throws SchemaRegistryException
SchemaRegistryExceptionpublic Schema modifySchemaTagsOrForward(String subject, Schema schema, TagSchemaRequest request, Map<String,String> headerProperties) throws SchemaRegistryException
SchemaRegistryExceptionpublic void deleteSchemaVersion(String subject, Schema schema, boolean permanentDelete) throws SchemaRegistryException
deleteSchemaVersion in interface SchemaRegistrySchemaRegistryExceptionpublic void deleteSchemaVersionOrForward(Map<String,String> headerProperties, String subject, Schema schema, boolean permanentDelete) throws SchemaRegistryException
SchemaRegistryExceptionpublic List<Integer> deleteSubject(String subject, boolean permanentDelete) throws SchemaRegistryException
deleteSubject in interface SchemaRegistrySchemaRegistryExceptionpublic List<Integer> deleteSubjectOrForward(Map<String,String> requestProperties, String subject, boolean permanentDelete) throws SchemaRegistryException
SchemaRegistryExceptionpublic Schema lookUpSchemaUnderSubjectUsingContexts(String subject, Schema schema, boolean normalize, boolean lookupDeletedSchema) throws SchemaRegistryException
SchemaRegistryExceptionpublic Schema lookUpSchemaUnderSubject(String subject, Schema schema, boolean normalize, boolean lookupDeletedSchema) throws SchemaRegistryException
lookUpSchemaUnderSubject in interface SchemaRegistrySchemaRegistryExceptionpublic Schema getLatestWithMetadata(String subject, Map<String,String> metadata, boolean lookupDeletedSchema) throws SchemaRegistryException
getLatestWithMetadata in interface SchemaRegistrySchemaRegistryExceptionpublic void checkIfSchemaWithIdExist(int id,
Schema schema)
throws SchemaRegistryException,
StoreException
public Schema forwardModifySchemaTagsRequestToLeader(String subject, Schema schema, TagSchemaRequest request, Map<String,String> headerProperties) throws SchemaRegistryRequestForwardingException
public ParsedSchema parseSchema(Schema schema) throws InvalidSchemaException
InvalidSchemaExceptionpublic ParsedSchema parseSchema(Schema schema, boolean isNew, boolean normalize) throws InvalidSchemaException
InvalidSchemaExceptionpublic Schema getUsingContexts(String subject, int version, boolean returnDeletedSchema) throws SchemaRegistryException
SchemaRegistryExceptionpublic boolean schemaVersionExists(String subject, VersionId versionId, boolean returnDeletedSchema) throws SchemaRegistryException
SchemaRegistryExceptionpublic Schema get(String subject, int version, boolean returnDeletedSchema) throws SchemaRegistryException
get in interface SchemaRegistrySchemaRegistryExceptionpublic SchemaString get(int id, String subject) throws SchemaRegistryException
get in interface SchemaRegistrySchemaRegistryExceptionpublic SchemaString get(int id, String subject, String format, boolean fetchMaxId) throws SchemaRegistryException
SchemaRegistryExceptionpublic Schema toSchemaEntity(SchemaValue schemaValue) throws SchemaRegistryStoreException
SchemaRegistryStoreExceptionprotected SchemaValue getSchemaValue(SchemaKey key) throws SchemaRegistryException
SchemaRegistryExceptionpublic List<Integer> getReferencedBy(String subject, VersionId versionId) throws SchemaRegistryException
SchemaRegistryExceptionpublic List<String> listContexts() throws SchemaRegistryException
SchemaRegistryExceptionpublic Set<String> listSubjects(LookupFilter filter) throws SchemaRegistryException
listSubjects in interface SchemaRegistrySchemaRegistryExceptionpublic Set<String> listSubjectsWithPrefix(String prefix, LookupFilter filter) throws SchemaRegistryException
SchemaRegistryExceptionpublic Set<String> listSubjectsForId(int id, String subject) throws SchemaRegistryException
SchemaRegistryExceptionpublic Set<String> listSubjectsForId(int id, String subject, boolean returnDeleted) throws SchemaRegistryException
listSubjectsForId in interface SchemaRegistrySchemaRegistryExceptionpublic List<SubjectVersion> listVersionsForId(int id, String subject) throws SchemaRegistryException
SchemaRegistryExceptionpublic List<SubjectVersion> listVersionsForId(int id, String subject, boolean lookupDeleted) throws SchemaRegistryException
SchemaRegistryExceptionpublic Set<String> subjects(String subject, boolean lookupDeletedSubjects) throws SchemaRegistryStoreException
SchemaRegistryStoreExceptionpublic boolean hasSubjects(String subject, boolean lookupDeletedSubjects) throws SchemaRegistryStoreException
SchemaRegistryStoreExceptionpublic Iterator<SchemaKey> getAllVersions(String subject, LookupFilter filter) throws SchemaRegistryException
getAllVersions in interface SchemaRegistrySchemaRegistryExceptionpublic Iterator<ExtendedSchema> getVersionsWithSubjectPrefix(String prefix, boolean includeAliases, LookupFilter filter, boolean returnLatestOnly, Predicate<Schema> postFilter) throws SchemaRegistryException
getVersionsWithSubjectPrefix in interface SchemaRegistrySchemaRegistryExceptionpublic Iterator<ExtendedSchema> allVersionsIncludingAliasesWithSubjectPrefix(String prefix, LookupFilter filter, boolean returnLatestOnly, Predicate<Schema> postFilter) throws SchemaRegistryException
SchemaRegistryExceptionpublic Schema getLatestVersion(String subject) throws SchemaRegistryException
getLatestVersion in interface SchemaRegistrySchemaRegistryExceptionpublic void invalidateFromNewSchemaCache(Schema schemaKey)
schemaKey - a schema key obtained by Schema.toHashKey()public void invalidateFromOldSchemaCache(Schema schemaKey)
schemaKey - a schema key obtained by Schema.toHashKey()public void clearNewSchemaCache()
public void clearOldSchemaCache()
public void close()
throws IOException
close in interface SchemaRegistryIOExceptionpublic Config updateConfig(String subject, ConfigUpdateRequest config) throws SchemaRegistryStoreException, OperationNotPermittedException, UnknownLeaderException
public Config updateConfigOrForward(String subject, ConfigUpdateRequest newConfig, Map<String,String> headerProperties) throws SchemaRegistryStoreException, SchemaRegistryRequestForwardingException, UnknownLeaderException, OperationNotPermittedException
public void deleteSubjectConfig(String subject) throws SchemaRegistryStoreException, OperationNotPermittedException
public void deleteConfigOrForward(String subject, Map<String,String> headerProperties) throws SchemaRegistryStoreException, SchemaRegistryRequestForwardingException, OperationNotPermittedException, UnknownLeaderException
public String getKafkaClusterId()
public String getGroupId()
public Config getConfig(String subject) throws SchemaRegistryStoreException
SchemaRegistryStoreExceptionpublic Config getConfigInScope(String subject) throws SchemaRegistryStoreException
SchemaRegistryStoreExceptionpublic List<String> isCompatible(String subject, Schema newSchema, List<SchemaKey> previousSchemas, boolean normalize) throws SchemaRegistryException
isCompatible in interface SchemaRegistrypreviousSchemas - Full schema history in chronological orderSchemaRegistryExceptionpublic Mode getMode(String subject) throws SchemaRegistryStoreException
SchemaRegistryStoreExceptionpublic Mode getModeInScope(String subject) throws SchemaRegistryStoreException
SchemaRegistryStoreExceptionpublic void setMode(String subject, ModeUpdateRequest mode) throws SchemaRegistryException
SchemaRegistryExceptionpublic void setMode(String subject, ModeUpdateRequest request, boolean force) throws SchemaRegistryException
SchemaRegistryExceptionpublic void setModeOrForward(String subject, ModeUpdateRequest mode, boolean force, Map<String,String> headerProperties) throws SchemaRegistryException
SchemaRegistryExceptionpublic void deleteSubjectMode(String subject) throws SchemaRegistryStoreException, OperationNotPermittedException
public void deleteSubjectMode(String subject, boolean recursive) throws SchemaRegistryStoreException, OperationNotPermittedException
public void deleteSubjectModeOrForward(String subject, boolean recursive, Map<String,String> headerProperties) throws SchemaRegistryStoreException, SchemaRegistryRequestForwardingException, OperationNotPermittedException, UnknownLeaderException
protected String getContextPrefixForDeleteMode(String context)
context - The normalized context string, or null for default contextpublic SchemaRegistryConfig config()
config in interface SchemaRegistrypublic Map<String,Object> properties()
properties in interface SchemaRegistrypublic HostnameVerifier getHostnameVerifier() throws SchemaRegistryStoreException
SchemaRegistryStoreExceptionpublic void onKeystoreCreated(KeyStore keystore)
onKeystoreCreated in interface SslFactory.SslFactoryCreatedpublic void onTruststoreCreated(KeyStore truststore)
onTruststoreCreated in interface SslFactory.SslFactoryCreatedpublic List<org.eclipse.jetty.server.handler.HandlerWrapper> getCustomHandler()
public void addCustomHandler(org.eclipse.jetty.server.handler.HandlerWrapper handler)
public void removeCustomHandler(org.eclipse.jetty.server.handler.HandlerWrapper handler)
Copyright © 2026 Confluent, Inc.. All rights reserved.