Package io.debezium.relational.history
Interface SchemaHistory
- All Known Implementing Classes:
AbstractFileBasedSchemaHistory,AbstractSchemaHistory,MemorySchemaHistory
public interface SchemaHistory
A history of the database schema described by a
Tables. Changes to the database schema can be
recorded, and a database schema can be
recovered to various points in that history.- Author:
- Randall Hauch
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final io.debezium.config.Fieldstatic final io.debezium.config.Fieldstatic final io.debezium.config.Fieldstatic final io.debezium.config.Fieldstatic final io.debezium.config.Fieldstatic final io.debezium.config.Fieldstatic final io.debezium.config.Fieldstatic final io.debezium.config.Field -
Method Summary
Modifier and TypeMethodDescriptiondefault voidValidates that the underlying storage is configured as needed by the specific implementation.voidconfigure(io.debezium.config.Configuration config, HistoryRecordComparator comparator, SchemaHistoryListener listener, boolean useCatalogBeforeSchema) Configure this instance.booleanexists()Determines if the database schema history entity exists; i.e. the storage must have been initialized and the history must have been populated.voidCalled to initialize permanent storage of the history.voidRecord 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, Instant timestamp) default voidRecover thedatabase schemato a known point in its history.default voidDeprecated.voidDeprecated.Userecover(Offsets, Tables, DdlParser)instead.voidstart()Start the history.default voidStarts buffering write operations.voidstop()Stop recording history and release any resources acquired sinceconfigure(Configuration, HistoryRecordComparator, SchemaHistoryListener, boolean).default voidStops buffering and ensures all pending writes are flushed and verified before returning.booleanDetermines if the underlying storage exists (e.g. a Kafka topic, file or similar).
-
Field Details
-
CONFIGURATION_FIELD_PREFIX_STRING
- See Also:
-
NAME
static final io.debezium.config.Field NAME -
SKIP_UNPARSEABLE_DDL_STATEMENTS
static final io.debezium.config.Field SKIP_UNPARSEABLE_DDL_STATEMENTS -
STORE_ONLY_CAPTURED_TABLES_DDL
static final io.debezium.config.Field STORE_ONLY_CAPTURED_TABLES_DDL -
STORE_ONLY_CAPTURED_DATABASES_DDL
static final io.debezium.config.Field STORE_ONLY_CAPTURED_DATABASES_DDL -
DDL_FILTER
static final io.debezium.config.Field DDL_FILTER -
INTERNAL_CONNECTOR_CLASS
static final io.debezium.config.Field INTERNAL_CONNECTOR_CLASS -
INTERNAL_CONNECTOR_ID
static final io.debezium.config.Field INTERNAL_CONNECTOR_ID -
INTERNAL_PREFER_DDL
static final io.debezium.config.Field INTERNAL_PREFER_DDL
-
-
Method Details
-
configure
void configure(io.debezium.config.Configuration config, HistoryRecordComparator comparator, SchemaHistoryListener listener, boolean useCatalogBeforeSchema) Configure this instance.- 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
void start()Start the history. -
record
void record(Map<String, ?> source, Map<String, throws SchemaHistoryException?> position, String databaseName, String ddl) Record a change to the schema of the named database, and store it in the schema storage.- 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:
SchemaHistoryException- if the record could not be written
-
record
void record(Map<String, ?> source, Map<String, throws SchemaHistoryException?> position, String databaseName, String schemaName, String ddl, TableChanges changes, Instant timestamp) - Throws:
SchemaHistoryException
-
recover
@Deprecated default void recover(Map<String, ?> source, Map<String, throws InterruptedException?> position, Tables schema, DdlParser ddlParser) Deprecated.Userecover(Offsets, Tables, DdlParser)instead.- Throws:
InterruptedException
-
recover
default void recover(Offsets<?, ?> offsets, Tables schema, DdlParser ddlParser) throws InterruptedExceptionRecover thedatabase schemato a known point in its history. Note that it is possible to recover the database schema to a point in history that is earlier than what has beenrecorded. Likewise, when recovering to a point in history later than what was recorded, the database schema will reflect the latest state known to the history.- Parameters:
offsets- the map of information about the source database to corresponding point in history at which database schema should be recovered; should contain at least one non-null offset which is enforced inHistorizedRelationalDatabaseSchema.recover(Offsets)schema- the table definitions that should be changed to reflect the database schema at the desired point in history; may not be nullddlParser- the DDL parser that can be used to apply DDL statements to the givenschema; may not be null- Throws:
InterruptedException
-
recover
@Deprecated void recover(Map<Map<String, ?>, throws InterruptedExceptionMap<String, ?>> offsets, Tables schema, DdlParser ddlParser) Deprecated.Userecover(Offsets, Tables, DdlParser)instead.- Throws:
InterruptedException
-
stop
void stop()Stop recording history and release any resources acquired sinceconfigure(Configuration, HistoryRecordComparator, SchemaHistoryListener, boolean). -
exists
boolean exists()Determines if the database schema history entity exists; i.e. the storage must have been initialized and the history must have been populated. -
storageExists
boolean storageExists()Determines if the underlying storage exists (e.g. a Kafka topic, file or similar). Note: storage may exist while history entities not yet written, seeexists() -
initializeStorage
void initializeStorage()Called to initialize permanent storage of the history. -
checkStorageSettings
default void checkStorageSettings()Validates that the underlying storage is configured as needed by the specific implementation. -
startBuffering
default void startBuffering()Starts buffering write operations. While buffering is active, calls torecord()may defer persistence to improve throughput. When buffering is not active, each record is persisted and acknowledged individually before returning. Callers must guarantee thatstopBuffering()is called in a finally block to flush and verify all pending writes. -
stopBuffering
default void stopBuffering()Stops buffering and ensures all pending writes are flushed and verified before returning. After this call, subsequentrecord()calls revert to the default behavior of persisting each record individually.- Throws:
SchemaHistoryException- if any pending writes failed
-
recover(Offsets, Tables, DdlParser)instead.