Class LruSchemaRegistryClient
java.lang.Object
io.confluent.kafka.schemaregistry.validator.AbstractSchemaRegistryClient
io.confluent.kafka.schemaregistry.validator.LruSchemaRegistryClient
- All Implemented Interfaces:
io.confluent.kafka.schemaregistry.client.SchemaRegistryClient,io.confluent.kafka.schemaregistry.client.SchemaVersionFetcher,Closeable,AutoCloseable
An implementation of
SchemaRegistryClient that
only supports SchemaRegistryClient.getSchemaBySubjectAndId(String, int) and
SchemaRegistryClient.getId(String, ParsedSchema).
It uses LRU caches to hold the results of these two methods.
This class is thread-safe as the underlying caches are also thread-safe.
This class can still be used with
as
long as auto-registration of schemas is disabled.invalid reference
io.confluent.kafka.serializers.KafkaAvroSerializer
-
Constructor Summary
ConstructorsConstructorDescriptionLruSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.rest.RestService restService, int maxCacheSize, int maxRetries, int retriesWaitMs, Map<String, ?> configs, Map<String, String> httpHeaders, com.google.common.base.Ticker ticker, int missingIdQueryRange, long missingIdCacheTtl, long missingSchemaCacheTtl) LruSchemaRegistryClient(List<String> baseUrls, int maxCacheSize, int maxRetries, int retriesWaitMs, Map<String, ?> configs, Map<String, String> httpHeaders, int missingIdQueryRange, long missingIdCacheTtl, long missingSchemaCacheTtl) LruSchemaRegistryClient(List<String> baseUrls, int maxCacheSize, int maxRetries, int retriesWaitMs, Map<String, ?> configs, Map<String, String> httpHeaders, com.google.common.base.Ticker ticker, int missingIdQueryRange, long missingIdCacheTtl, long missingSchemaCacheTtl) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()io.confluent.kafka.schemaregistry.client.rest.entities.SchemagetByVersion(String subject, int version, boolean lookupDeletedSchema) intio.confluent.kafka.schemaregistry.client.rest.entities.requests.RegisterSchemaResponsegetIdWithResponse(String subject, io.confluent.kafka.schemaregistry.ParsedSchema schema, boolean normalize) io.confluent.kafka.schemaregistry.ParsedSchemagetSchemaByGuid(String guid, String format) io.confluent.kafka.schemaregistry.ParsedSchemagetSchemaBySubjectAndId(String subject, int id) Optional<io.confluent.kafka.schemaregistry.ParsedSchema> parseSchema(io.confluent.kafka.schemaregistry.client.rest.entities.Schema schema) Optional<io.confluent.kafka.schemaregistry.ParsedSchema> parseSchema(String schemaType, String schemaString, List<io.confluent.kafka.schemaregistry.client.rest.entities.SchemaReference> references) voidreset()Methods inherited from class io.confluent.kafka.schemaregistry.validator.AbstractSchemaRegistryClient
deleteSchemaVersion, deleteSchemaVersion, deleteSubject, deleteSubject, getAllSubjects, getAllSubjectsById, getAllVersions, getById, getByID, getBySubjectAndId, getBySubjectAndID, getCompatibility, getGuid, getId, getId, getLatestSchemaMetadata, getMode, getMode, getSchemaById, getSchemaMetadata, getVersion, getVersion, register, register, register, register, setMode, setMode, testCompatibility, testCompatibility, updateCompatibilityMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.confluent.kafka.schemaregistry.client.SchemaRegistryClient
batchGetAssociations, createAssociation, createOrUpdateAssociation, deleteAssociations, deleteCompatibility, deleteConfig, deleteMode, deleteSchemaVersion, deleteSchemaVersion, deleteSubject, deleteSubject, getAllContexts, getAllSubjects, getAllSubjectsByPrefix, getAllVersions, getAllVersionsById, getAssociationsByResourceId, getAssociationsByResourceName, getAssociationsBySubject, getCompatibility, getConfig, getConfig, getLatestWithMetadata, getSchemaEntityBySubjectAndId, getSchemaMetadata, getSchemaRegistryDeployment, getSchemaRegistryServerVersion, getSchemas, getVersion, mutateAssociations, parseSchema, parseSchemaOrElseThrow, register, registerWithResponse, registerWithResponse, setMode, tenant, testCompatibilityVerbose, testCompatibilityVerbose, ticker, updateConfig
-
Constructor Details
-
LruSchemaRegistryClient
-
LruSchemaRegistryClient
-
LruSchemaRegistryClient
public LruSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.rest.RestService restService, int maxCacheSize, int maxRetries, int retriesWaitMs, Map<String, ?> configs, Map<String, String> httpHeaders, com.google.common.base.Ticker ticker, int missingIdQueryRange, long missingIdCacheTtl, long missingSchemaCacheTtl)
-
-
Method Details
-
parseSchema
-
parseSchema
public Optional<io.confluent.kafka.schemaregistry.ParsedSchema> parseSchema(io.confluent.kafka.schemaregistry.client.rest.entities.Schema schema) -
getSchemaBySubjectAndId
public io.confluent.kafka.schemaregistry.ParsedSchema getSchemaBySubjectAndId(String subject, int id) throws IOException, io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException - Specified by:
getSchemaBySubjectAndIdin interfaceio.confluent.kafka.schemaregistry.client.SchemaRegistryClient- Specified by:
getSchemaBySubjectAndIdin classAbstractSchemaRegistryClient- Throws:
IOExceptionio.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException
-
getSchemaByGuid
public io.confluent.kafka.schemaregistry.ParsedSchema getSchemaByGuid(String guid, String format) throws IOException, io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException - Throws:
IOExceptionio.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException
-
getByVersion
public io.confluent.kafka.schemaregistry.client.rest.entities.Schema getByVersion(String subject, int version, boolean lookupDeletedSchema) -
getId
public int getId(String subject, io.confluent.kafka.schemaregistry.ParsedSchema schema, boolean normalize) throws IOException, io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException - Specified by:
getIdin interfaceio.confluent.kafka.schemaregistry.client.SchemaRegistryClient- Specified by:
getIdin classAbstractSchemaRegistryClient- Throws:
IOExceptionio.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException
-
getGuid
public String getGuid(String subject, io.confluent.kafka.schemaregistry.ParsedSchema schema, boolean normalize) throws IOException, io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException - Specified by:
getGuidin interfaceio.confluent.kafka.schemaregistry.client.SchemaRegistryClient- Specified by:
getGuidin classAbstractSchemaRegistryClient- Throws:
IOExceptionio.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException
-
getIdWithResponse
public io.confluent.kafka.schemaregistry.client.rest.entities.requests.RegisterSchemaResponse getIdWithResponse(String subject, io.confluent.kafka.schemaregistry.ParsedSchema schema, boolean normalize) throws IOException, io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException - Throws:
IOExceptionio.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException
-
reset
public void reset()- Specified by:
resetin interfaceio.confluent.kafka.schemaregistry.client.SchemaRegistryClient- Overrides:
resetin classAbstractSchemaRegistryClient
-
close
- Throws:
IOException
-