@NotThreadSafe public class KafkaDatabaseHistory extends AbstractDatabaseHistory
DatabaseHistory 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.| Modifier and Type | Field and Description |
|---|---|
static Field.Set |
ALL_FIELDS |
static Field |
BOOTSTRAP_SERVERS |
private ExecutorService |
checkTopicSettingsExecutor |
private static String |
CLEANUP_POLICY_NAME |
private static String |
CLEANUP_POLICY_VALUE |
private static String |
CONSUMER_PREFIX |
private Configuration |
consumerConfig |
private static short |
DEFAULT_TOPIC_REPLICATION_FACTOR
The default replication factor for the history topic which is used in case
the value couldn't be retrieved from the broker.
|
private static String |
DEFAULT_TOPIC_REPLICATION_FACTOR_PROP_NAME
The name of broker property defining default replication factor for topics without the explicit setting.
|
static Field |
INTERNAL_CONNECTOR_CLASS |
static Field |
INTERNAL_CONNECTOR_ID |
private static Duration |
KAFKA_QUERY_TIMEOUT |
private static org.slf4j.Logger |
LOGGER |
private int |
maxRecoveryAttempts |
private static Integer |
PARTITION
The one and only partition of the history topic.
|
private static short |
PARTITION_COUNT |
private Duration |
pollInterval |
private org.apache.kafka.clients.producer.KafkaProducer<String,String> |
producer |
private static String |
PRODUCER_PREFIX |
private Configuration |
producerConfig |
private DocumentReader |
reader |
static Field |
RECOVERY_POLL_ATTEMPTS |
static Field |
RECOVERY_POLL_INTERVAL_MS |
private static String |
RETENTION_BYTES_NAME |
private static long |
RETENTION_MS_MAX |
private static long |
RETENTION_MS_MIN |
private static String |
RETENTION_MS_NAME |
static Field |
TOPIC |
private String |
topicName |
private static int |
UNLIMITED_VALUE |
config, loggerCONFIGURATION_FIELD_PREFIX_STRING, DDL_FILTER, NAME, SKIP_UNPARSEABLE_DDL_STATEMENTS, STORE_ONLY_MONITORED_TABLES_DDL| Constructor and Description |
|---|
KafkaDatabaseHistory() |
| Modifier and Type | Method and Description |
|---|---|
private void |
checkTopicSettings(String topicName) |
void |
configure(Configuration config,
HistoryRecordComparator comparator,
DatabaseHistoryListener listener,
boolean useCatalogBeforeSchema)
Configure this instance.
|
protected static String |
consumerConfigPropertyName(String kafkaConsumerPropertyName) |
boolean |
exists()
Determines if the DatabaseHistory entity exists
|
private short |
getDefaultTopicReplicationFactor(org.apache.kafka.clients.admin.AdminClient admin) |
private Long |
getEndOffsetOfDbHistoryTopic(Long previousEndOffset,
org.apache.kafka.clients.consumer.KafkaConsumer<String,String> historyConsumer) |
private org.apache.kafka.clients.admin.Config |
getKafkaBrokerConfig(org.apache.kafka.clients.admin.AdminClient admin) |
void |
initializeStorage()
Called to initialize permanent storage of the history.
|
protected void |
recoverRecords(Consumer<HistoryRecord> records) |
void |
start()
Start the history.
|
void |
stop()
Stop recording history and release any resources acquired since
#configure(Configuration, HistoryRecordComparator, DatabaseHistoryListener). |
private void |
stopCheckTopicSettingsExecutor() |
protected void |
storeRecord(HistoryRecord record) |
String |
toString() |
record, record, recoverprivate static final org.slf4j.Logger LOGGER
private static final String CLEANUP_POLICY_NAME
private static final String CLEANUP_POLICY_VALUE
private static final String RETENTION_MS_NAME
private static final long RETENTION_MS_MAX
private static final long RETENTION_MS_MIN
private static final String RETENTION_BYTES_NAME
private static final int UNLIMITED_VALUE
private static final short PARTITION_COUNT
private static final String DEFAULT_TOPIC_REPLICATION_FACTOR_PROP_NAME
kafka.server.KafkaConfig.DefaultReplicationFactorProp,
Constant Field Valuesprivate static final short DEFAULT_TOPIC_REPLICATION_FACTOR
public static final Field TOPIC
public static final Field BOOTSTRAP_SERVERS
public static final Field RECOVERY_POLL_INTERVAL_MS
public static final Field RECOVERY_POLL_ATTEMPTS
public static final Field INTERNAL_CONNECTOR_CLASS
public static final Field INTERNAL_CONNECTOR_ID
public static Field.Set ALL_FIELDS
private static final String CONSUMER_PREFIX
private static final String PRODUCER_PREFIX
private static final Duration KAFKA_QUERY_TIMEOUT
private static final Integer PARTITION
private final DocumentReader reader
private String topicName
private Configuration consumerConfig
private Configuration producerConfig
private int maxRecoveryAttempts
private Duration pollInterval
private ExecutorService checkTopicSettingsExecutor
public void configure(Configuration config, HistoryRecordComparator comparator, DatabaseHistoryListener listener, boolean useCatalogBeforeSchema)
DatabaseHistoryconfigure in interface DatabaseHistoryconfigure in class AbstractDatabaseHistoryconfig - the configuration for this history storecomparator - the function that should be used to compare history records during
recovery; may be null if the
default 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 namepublic void start()
DatabaseHistorystart in interface DatabaseHistorystart in class AbstractDatabaseHistoryprotected void storeRecord(HistoryRecord record) throws DatabaseHistoryException
storeRecord in class AbstractDatabaseHistoryDatabaseHistoryExceptionprotected void recoverRecords(Consumer<HistoryRecord> records)
recoverRecords in class AbstractDatabaseHistoryprivate Long getEndOffsetOfDbHistoryTopic(Long previousEndOffset, org.apache.kafka.clients.consumer.KafkaConsumer<String,String> historyConsumer)
public boolean exists()
DatabaseHistoryprivate void checkTopicSettings(String topicName)
public void stop()
DatabaseHistory#configure(Configuration, HistoryRecordComparator, DatabaseHistoryListener).stop in interface DatabaseHistorystop in class AbstractDatabaseHistoryprivate void stopCheckTopicSettingsExecutor()
protected static String consumerConfigPropertyName(String kafkaConsumerPropertyName)
public void initializeStorage()
DatabaseHistoryinitializeStorage in interface DatabaseHistoryinitializeStorage in class AbstractDatabaseHistoryprivate short getDefaultTopicReplicationFactor(org.apache.kafka.clients.admin.AdminClient admin)
throws Exception
ExceptionCopyright © 2020 JBoss by Red Hat. All rights reserved.