Class KafkaSchemaHistory
java.lang.Object
io.debezium.relational.history.AbstractSchemaHistory
io.debezium.storage.kafka.history.KafkaSchemaHistory
- All Implemented Interfaces:
SchemaHistory
A
SchemaHistory implementation that records schema changes as normal SourceRecords on the specified topic,
and that recovers the history by establishing a Kafka Consumer re-processing all messages on that topic.- Author:
- Randall Hauch
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Field.Setstatic final Fieldprivate ExecutorServiceprivate static final Stringprivate static final Stringprivate static final Stringprivate Configurationprivate static final shortThe default replication factor for the history topic which is used in case the value couldn't be retrieved from the broker.private static final StringThe name of broker property defining default replication factor for topics without the explicit setting.static final Fieldstatic final Fieldprivate Durationprivate Durationprivate static final org.slf4j.Loggerprivate intprivate static final IntegerThe one and only partition of the history topic.private static final intprivate Durationprivate static final Stringprivate Configurationprivate final DocumentReaderstatic final Fieldstatic final Fieldprivate static final Stringprivate static final longprivate static final longprivate static final Stringstatic final Fieldprivate Stringprivate static final intprivate static final booleanFields inherited from class io.debezium.relational.history.AbstractSchemaHistory
config, loggerFields inherited from interface io.debezium.relational.history.SchemaHistory
CONFIGURATION_FIELD_PREFIX_STRING, DDL_FILTER, INTERNAL_CONNECTOR_CLASS, INTERNAL_CONNECTOR_ID, INTERNAL_PREFER_DDL, NAME, SKIP_UNPARSEABLE_DDL_STATEMENTS, STORE_ONLY_CAPTURED_DATABASES_DDL, STORE_ONLY_CAPTURED_TABLES_DDL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckTopicSettings(String topicName) voidconfigure(Configuration config, HistoryRecordComparator comparator, SchemaHistoryListener listener, boolean useCatalogBeforeSchema) static StringconsumerConfigPropertyName(String kafkaConsumerPropertyName) booleanexists()private static Field.ValidatorforKafka(Field.Validator validator) private shortgetDefaultTopicReplicationFactor(org.apache.kafka.clients.admin.AdminClient admin) private LonggetEndOffsetOfDbHistoryTopic(Long previousEndOffset, org.apache.kafka.clients.consumer.KafkaConsumer<String, String> historyConsumer) private org.apache.kafka.clients.admin.ConfiggetKafkaBrokerConfig(org.apache.kafka.clients.admin.AdminClient admin) private static booleanvoidprotected voidrecoverRecords(Consumer<HistoryRecord> records) voidstart()voidstop()private voidbooleanprotected voidstoreRecord(HistoryRecord record) toString()Methods inherited from class io.debezium.relational.history.AbstractSchemaHistory
record, record, recoverMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.debezium.relational.history.SchemaHistory
recover, recover
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
CLEANUP_POLICY_NAME
- See Also:
-
CLEANUP_POLICY_VALUE
- See Also:
-
RETENTION_MS_NAME
- See Also:
-
RETENTION_MS_MAX
private static final long RETENTION_MS_MAX- See Also:
-
RETENTION_MS_MIN
private static final long RETENTION_MS_MIN -
RETENTION_BYTES_NAME
- See Also:
-
UNLIMITED_VALUE
private static final int UNLIMITED_VALUE- See Also:
-
PARTITION_COUNT
private static final int PARTITION_COUNT- See Also:
-
DEFAULT_TOPIC_REPLICATION_FACTOR_PROP_NAME
The name of broker property defining default replication factor for topics without the explicit setting.- See Also:
-
kafka.server.KafkaConfig.DefaultReplicationFactorProp- Constant Field Values
-
DEFAULT_TOPIC_REPLICATION_FACTOR
private static final short DEFAULT_TOPIC_REPLICATION_FACTORThe default replication factor for the history topic which is used in case the value couldn't be retrieved from the broker.- See Also:
-
TOPIC
-
BOOTSTRAP_SERVERS
-
RECOVERY_POLL_INTERVAL_MS
-
RECOVERY_POLL_ATTEMPTS
-
KAFKA_QUERY_TIMEOUT_MS
-
KAFKA_CREATE_TIMEOUT_MS
-
ALL_FIELDS
-
CONSUMER_PREFIX
- See Also:
-
PRODUCER_PREFIX
- See Also:
-
PARTITION
The one and only partition of the history topic. -
reader
-
topicName
-
consumerConfig
-
producerConfig
-
producer
-
maxRecoveryAttempts
private int maxRecoveryAttempts -
pollInterval
-
checkTopicSettingsExecutor
-
kafkaQueryTimeout
-
kafkaCreateTimeout
-
USE_KAFKA_24_NEW_TOPIC_CONSTRUCTOR
private static final boolean USE_KAFKA_24_NEW_TOPIC_CONSTRUCTOR
-
-
Constructor Details
-
KafkaSchemaHistory
public KafkaSchemaHistory()
-
-
Method Details
-
hasNewTopicConstructorWithOptionals
private static boolean hasNewTopicConstructorWithOptionals() -
configure
public void configure(Configuration config, HistoryRecordComparator comparator, SchemaHistoryListener listener, boolean useCatalogBeforeSchema) - Specified by:
configurein interfaceSchemaHistory- Overrides:
configurein classAbstractSchemaHistory
-
start
public void start()- Specified by:
startin interfaceSchemaHistory- Overrides:
startin classAbstractSchemaHistory
-
storeRecord
- Specified by:
storeRecordin classAbstractSchemaHistory- Throws:
SchemaHistoryException
-
recoverRecords
- Specified by:
recoverRecordsin classAbstractSchemaHistory
-
getEndOffsetOfDbHistoryTopic
-
storageExists
public boolean storageExists() -
exists
public boolean exists() -
checkTopicSettings
-
stop
public void stop()- Specified by:
stopin interfaceSchemaHistory- Overrides:
stopin classAbstractSchemaHistory
-
stopCheckTopicSettingsExecutor
private void stopCheckTopicSettingsExecutor() -
toString
-
consumerConfigPropertyName
-
initializeStorage
public void initializeStorage()- Specified by:
initializeStoragein interfaceSchemaHistory- Overrides:
initializeStoragein classAbstractSchemaHistory
-
getDefaultTopicReplicationFactor
private short getDefaultTopicReplicationFactor(org.apache.kafka.clients.admin.AdminClient admin) throws Exception - Throws:
Exception
-
getKafkaBrokerConfig
private org.apache.kafka.clients.admin.Config getKafkaBrokerConfig(org.apache.kafka.clients.admin.AdminClient admin) throws Exception - Throws:
Exception
-
forKafka
-