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 HistoryRecordComparator
comparator
protected Configuration
config
private Function<String,Optional<Pattern>>
ddlFilter
static Field
INTERNAL_PREFER_DDL
private DatabaseHistoryListener
listener
protected org.slf4j.Logger
logger
private boolean
preferDdl
private boolean
skipUnparseableDDL
private boolean
storeOnlyCapturedTablesDdl
private TableChanges.TableChangesSerializer<Array>
tableChangesSerializer
private boolean
useCatalogBeforeSchema
-
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 protected
AbstractDatabaseHistory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
configure(Configuration config, HistoryRecordComparator comparator, DatabaseHistoryListener listener, boolean useCatalogBeforeSchema)
Configure this instance.void
initializeStorage()
Called to initialize permanent storage of the history.void
record(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.void
record(Map<String,?> source, Map<String,?> position, String databaseName, String schemaName, String ddl, TableChanges changes)
void
recover(Map<Map<String,?>,Map<String,?>> offsets, Tables schema, DdlParser ddlParser)
protected abstract void
recoverRecords(Consumer<HistoryRecord> records)
boolean
skipUnparseableDdlStatements()
void
start()
Start the history.void
stop()
Stop recording history and release any resources acquired since#configure(Configuration, HistoryRecordComparator, DatabaseHistoryListener)
.boolean
storeOnlyCapturedTables()
protected abstract void
storeRecord(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:DatabaseHistory
Configure this instance.- Specified by:
configure
in 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 comparator
is 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:DatabaseHistory
Start the history.- Specified by:
start
in interfaceDatabaseHistory
-
record
public final void record(Map<String,?> source, Map<String,?> position, String databaseName, String ddl) throws DatabaseHistoryException
Description copied from interface:DatabaseHistory
Record a change to the schema of the named database, and store it in the schema storage.- Specified by:
record
in 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 whenrecovering
the 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:
record
in interfaceDatabaseHistory
- Throws:
DatabaseHistoryException
-
recover
public void recover(Map<Map<String,?>,Map<String,?>> offsets, Tables schema, DdlParser ddlParser)
- Specified by:
recover
in 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:DatabaseHistory
Stop recording history and release any resources acquired since#configure(Configuration, HistoryRecordComparator, DatabaseHistoryListener)
.- Specified by:
stop
in interfaceDatabaseHistory
-
initializeStorage
public void initializeStorage()
Description copied from interface:DatabaseHistory
Called to initialize permanent storage of the history.- Specified by:
initializeStorage
in interfaceDatabaseHistory
-
storeOnlyCapturedTables
public boolean storeOnlyCapturedTables()
- Specified by:
storeOnlyCapturedTables
in interfaceDatabaseHistory
-
skipUnparseableDdlStatements
public boolean skipUnparseableDdlStatements()
- Specified by:
skipUnparseableDdlStatements
in interfaceDatabaseHistory
-
-