Package io.debezium.relational.history
Class AbstractDatabaseHistory
- java.lang.Object
-
- io.debezium.relational.history.AbstractDatabaseHistory
-
- All Implemented Interfaces:
DatabaseHistory
- Direct Known Subclasses:
FileDatabaseHistory,KafkaDatabaseHistory,MemoryDatabaseHistory
public abstract class AbstractDatabaseHistory extends Object implements DatabaseHistory
- Author:
- Randall Hauch
-
-
Field Summary
Fields Modifier and Type Field Description private HistoryRecordComparatorcomparatorprotected Configurationconfigprivate Function<String,Optional<Pattern>>ddlFilterstatic FieldINTERNAL_PREFER_DDLprivate DatabaseHistoryListenerlistenerprotected org.slf4j.Loggerloggerprivate booleanpreferDdlprivate booleanskipUnparseableDDLprivate booleanstoreOnlyCapturedTablesDdlprivate TableChanges.TableChangesSerializer<Array>tableChangesSerializerprivate booleanuseCatalogBeforeSchema-
Fields inherited from interface io.debezium.relational.history.DatabaseHistory
CONFIGURATION_FIELD_PREFIX_STRING, DDL_FILTER, NAME, SKIP_UNPARSEABLE_DDL_STATEMENTS, STORE_ONLY_CAPTURED_TABLES_DDL, STORE_ONLY_MONITORED_TABLES_DDL
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractDatabaseHistory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidconfigure(Configuration config, HistoryRecordComparator comparator, DatabaseHistoryListener listener, boolean useCatalogBeforeSchema)Configure this instance.voidinitializeStorage()Called to initialize permanent storage of the history.voidrecord(Map<String,?> source, Map<String,?> position, String databaseName, String ddl)Record a change to the schema of the named database, and store it in the schema storage.voidrecord(Map<String,?> source, Map<String,?> position, String databaseName, String schemaName, String ddl, TableChanges changes)voidrecover(Map<Map<String,?>,Map<String,?>> offsets, Tables schema, DdlParser ddlParser)protected abstract voidrecoverRecords(Consumer<HistoryRecord> records)booleanskipUnparseableDdlStatements()voidstart()Start the history.voidstop()Stop recording history and release any resources acquired since#configure(Configuration, HistoryRecordComparator, DatabaseHistoryListener).booleanstoreOnlyCapturedTables()protected abstract voidstoreRecord(HistoryRecord record)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.debezium.relational.history.DatabaseHistory
exists, recover, recover, storageExists
-
-
-
-
Field Detail
-
logger
protected final org.slf4j.Logger logger
-
INTERNAL_PREFER_DDL
public static final Field INTERNAL_PREFER_DDL
-
config
protected Configuration config
-
comparator
private HistoryRecordComparator comparator
-
skipUnparseableDDL
private boolean skipUnparseableDDL
-
storeOnlyCapturedTablesDdl
private boolean storeOnlyCapturedTablesDdl
-
listener
private DatabaseHistoryListener listener
-
useCatalogBeforeSchema
private boolean useCatalogBeforeSchema
-
preferDdl
private boolean preferDdl
-
tableChangesSerializer
private TableChanges.TableChangesSerializer<Array> tableChangesSerializer
-
-
Method Detail
-
configure
public void configure(Configuration config, HistoryRecordComparator comparator, DatabaseHistoryListener listener, boolean useCatalogBeforeSchema)
Description copied from interface:DatabaseHistoryConfigure this instance.- Specified by:
configurein interfaceDatabaseHistory- Parameters:
config- the configuration for this history storecomparator- the function that should be used to compare history records duringrecovery; may be null if thedefault comparatoris to be usedlistener- TODOuseCatalogBeforeSchema- true if the parsed string for a table contains only 2 items and the first should be used as the catalog and the second as the table name, or false if the first should be used as the schema and the second as the table name
-
start
public void start()
Description copied from interface:DatabaseHistoryStart the history.- Specified by:
startin interfaceDatabaseHistory
-
record
public final void record(Map<String,?> source, Map<String,?> position, String databaseName, String ddl) throws DatabaseHistoryException
Description copied from interface:DatabaseHistoryRecord a change to the schema of the named database, and store it in the schema storage.- Specified by:
recordin interfaceDatabaseHistory- Parameters:
source- the information about the source database; may not be nullposition- the point in history where these DDL changes were made, which may be used whenrecoveringthe schema to some point in history; may not be nulldatabaseName- the name of the database whose schema is being changed; may be nullddl- the DDL statements that describe the changes to the database schema; may not be null- Throws:
DatabaseHistoryException- if the record could not be written
-
record
public final void record(Map<String,?> source, Map<String,?> position, String databaseName, String schemaName, String ddl, TableChanges changes) throws DatabaseHistoryException
- Specified by:
recordin interfaceDatabaseHistory- Throws:
DatabaseHistoryException
-
recover
public void recover(Map<Map<String,?>,Map<String,?>> offsets, Tables schema, DdlParser ddlParser)
- Specified by:
recoverin interfaceDatabaseHistory
-
storeRecord
protected abstract void storeRecord(HistoryRecord record) throws DatabaseHistoryException
- Throws:
DatabaseHistoryException
-
recoverRecords
protected abstract void recoverRecords(Consumer<HistoryRecord> records)
-
stop
public void stop()
Description copied from interface:DatabaseHistoryStop recording history and release any resources acquired since#configure(Configuration, HistoryRecordComparator, DatabaseHistoryListener).- Specified by:
stopin interfaceDatabaseHistory
-
initializeStorage
public void initializeStorage()
Description copied from interface:DatabaseHistoryCalled to initialize permanent storage of the history.- Specified by:
initializeStoragein interfaceDatabaseHistory
-
storeOnlyCapturedTables
public boolean storeOnlyCapturedTables()
- Specified by:
storeOnlyCapturedTablesin interfaceDatabaseHistory
-
skipUnparseableDdlStatements
public boolean skipUnparseableDdlStatements()
- Specified by:
skipUnparseableDdlStatementsin interfaceDatabaseHistory
-
-