Class CachingSchemaStore
- java.lang.Object
-
- org.apache.cassandra.cdc.schemastore.CachingSchemaStore
-
- All Implemented Interfaces:
SchemaStore
public class CachingSchemaStore extends java.lang.Object implements SchemaStore
Recommended implementation of SchemaStore that detects schema changes and regenerates Avro schema. Pass in a `SchemaStorePublisherFactory` to publish the schema downstream.
-
-
Constructor Summary
Constructors Constructor Description CachingSchemaStore(SchemaStoreStats schemaStoreStats, java.util.function.Supplier<org.apache.cassandra.bridge.CassandraVersion> cassandraVersionSupplier, org.apache.cassandra.cdc.api.SchemaSupplier schemaSupplier, SchemaStorePublisherFactory schemaStorePublisherFactory, KafkaOptions kafkaOptions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.avro.generic.GenericDatumReader<org.apache.avro.generic.GenericRecord>getReader(java.lang.String namespace, java.lang.String name)Get the datum readerorg.apache.avro.SchemagetSchema(java.lang.String namespace, java.lang.String name)Get the avro corresponding to the namespace and the name of the schemajava.util.Map<java.lang.String,org.apache.avro.Schema>getSchemas()java.lang.StringgetVersion(java.lang.String namespace, java.lang.String name)Get the schema version corresponding to the namespace and the name of the schemaorg.apache.avro.generic.GenericDatumWriter<org.apache.avro.generic.GenericRecord>getWriter(java.lang.String namespace, java.lang.String name)Get the datum writervoidinitialize()`initialize()` must be called on server start-up once all other dependencies are initialized, e.g.voidonConfigChange()`onConfigChange()` should be called whenever the Kafka config is changed and the publisher needs to be rebuilt.voidonSchemaChange()`onSchemaChanged()` should be called whenever a Cassandra CQL schema change is detected.protected org.apache.cassandra.cdc.avro.CqlToAvroSchemaConverterschemaConverter()
-
-
-
Constructor Detail
-
CachingSchemaStore
public CachingSchemaStore(SchemaStoreStats schemaStoreStats, java.util.function.Supplier<org.apache.cassandra.bridge.CassandraVersion> cassandraVersionSupplier, org.apache.cassandra.cdc.api.SchemaSupplier schemaSupplier, SchemaStorePublisherFactory schemaStorePublisherFactory, KafkaOptions kafkaOptions)
-
-
Method Detail
-
initialize
public void initialize()
`initialize()` must be called on server start-up once all other dependencies are initialized, e.g. when Sidecar has fully initialized connections to Cassandra.
-
onConfigChange
public void onConfigChange()
`onConfigChange()` should be called whenever the Kafka config is changed and the publisher needs to be rebuilt.
-
onSchemaChange
public void onSchemaChange()
`onSchemaChanged()` should be called whenever a Cassandra CQL schema change is detected.
-
schemaConverter
@NotNull protected org.apache.cassandra.cdc.avro.CqlToAvroSchemaConverter schemaConverter()
-
getSchema
public org.apache.avro.Schema getSchema(java.lang.String namespace, java.lang.String name)Description copied from interface:SchemaStoreGet the avro corresponding to the namespace and the name of the schema- Specified by:
getSchemain interfaceSchemaStore- Returns:
- avro schema, or return null if nothing can be found
-
getWriter
public org.apache.avro.generic.GenericDatumWriter<org.apache.avro.generic.GenericRecord> getWriter(java.lang.String namespace, java.lang.String name)Description copied from interface:SchemaStoreGet the datum writer- Specified by:
getWriterin interfaceSchemaStore- Returns:
- datum writer or null if schema is not found
-
getReader
public org.apache.avro.generic.GenericDatumReader<org.apache.avro.generic.GenericRecord> getReader(java.lang.String namespace, java.lang.String name)Description copied from interface:SchemaStoreGet the datum reader- Specified by:
getReaderin interfaceSchemaStore- Returns:
- datum reader or null if schema is not found
-
getVersion
public java.lang.String getVersion(java.lang.String namespace, java.lang.String name)Description copied from interface:SchemaStoreGet the schema version corresponding to the namespace and the name of the schema- Specified by:
getVersionin interfaceSchemaStore- Returns:
- a type 3 (name based) UUID generated based on the MD5 of the CQL schema, or return null if nothing can be found
-
getSchemas
public java.util.Map<java.lang.String,org.apache.avro.Schema> getSchemas()
-
-