@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 static String |
CONSUMER_PREFIX |
private Configuration |
consumerConfig |
private static String |
DEFAULT_TOPIC_REPLICATION_FACTOR_PROP_NAME
The name of broker property defining default replication factor for topics without the explicit setting.
|
private static Duration |
KAFKA_QUERY_TIMEOUT |
private int |
maxRecoveryAttempts |
private static Integer |
PARTITION
The one and only partition of the history topic.
|
private int |
pollIntervalMs |
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 |
static Field |
TOPIC |
private String |
topicName |
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 |
|---|---|
void |
configure(Configuration config,
HistoryRecordComparator comparator)
Configure this instance.
|
protected static String |
consumerConfigPropertyName(String kafkaConsumerPropertyName) |
boolean |
exists()
Determines if the DatabaseHistory entity exists
|
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
DatabaseHistory.configure(Configuration, HistoryRecordComparator). |
protected void |
storeRecord(HistoryRecord record) |
String |
toString() |
record, record, recoverprivate static final String DEFAULT_TOPIC_REPLICATION_FACTOR_PROP_NAME
kafka.server.KafkaConfig.DefaultReplicationFactorProp,
Constant Field Valuespublic 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 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 int pollIntervalMs
public void configure(Configuration config, HistoryRecordComparator comparator)
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 usedpublic 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()
DatabaseHistorypublic void stop()
DatabaseHistoryDatabaseHistory.configure(Configuration, HistoryRecordComparator).stop in interface DatabaseHistorystop in class AbstractDatabaseHistoryprotected static String consumerConfigPropertyName(String kafkaConsumerPropertyName)
public void initializeStorage()
DatabaseHistoryinitializeStorage in interface DatabaseHistoryinitializeStorage in class AbstractDatabaseHistoryCopyright © 2018 JBoss by Red Hat. All rights reserved.