Package io.debezium.relational.history
Class DatabaseHistoryMetrics
- java.lang.Object
-
- io.debezium.metrics.Metrics
-
- io.debezium.relational.history.DatabaseHistoryMetrics
-
- All Implemented Interfaces:
DatabaseHistoryListener,DatabaseHistoryMXBean
public class DatabaseHistoryMetrics extends Metrics implements DatabaseHistoryListener, DatabaseHistoryMXBean
Implementation ofDatabaseSchemametrics.- Author:
- Jiri Pechanec
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDatabaseHistoryMetrics.DatabaseHistoryStatus
-
Field Summary
Fields Modifier and Type Field Description private AtomicLongchangesRecoveredprivate static StringCONTEXT_NAMEprivate HistoryRecordlastAppliedChangeprivate InstantlastChangeAppliedTimestampprivate InstantlastChangeRecoveredTimestampprivate HistoryRecordlastRecoveredChangeprivate static org.slf4j.LoggerLOGGERprivate static DurationPAUSE_BETWEEN_LOG_MESSAGESprivate InstantrecoveryStartTimeprivate DatabaseHistoryMetrics.DatabaseHistoryStatusstatusprivate AtomicLongtotalChangesApplied-
Fields inherited from interface io.debezium.relational.history.DatabaseHistoryListener
NOOP
-
-
Constructor Summary
Constructors Modifier Constructor Description DatabaseHistoryMetrics(CommonConnectorConfig connectorConfig)protectedDatabaseHistoryMetrics(T taskContext, String contextName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetChangesApplied()longgetChangesRecovered()StringgetLastAppliedChange()StringgetLastRecoveredChange()longgetMilliSecondsSinceLastAppliedChange()longgetMilliSecondsSinceLastRecoveredChange()longgetRecoveryStartTime()StringgetStatus()The database history starts inSTOPPEDstate.voidonChangeApplied(HistoryRecord record)Invoked for every change applied and not filtered.voidonChangeFromHistory(HistoryRecord record)Invoked for every change read from the history during recovery.voidrecoveryStarted()voidrecoveryStopped()voidstarted()voidstopped()-
Methods inherited from class io.debezium.metrics.Metrics
metricName, register, unregister
-
-
-
-
Field Detail
-
CONTEXT_NAME
private static final String CONTEXT_NAME
- See Also:
- Constant Field Values
-
PAUSE_BETWEEN_LOG_MESSAGES
private static final Duration PAUSE_BETWEEN_LOG_MESSAGES
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
status
private DatabaseHistoryMetrics.DatabaseHistoryStatus status
-
recoveryStartTime
private Instant recoveryStartTime
-
changesRecovered
private AtomicLong changesRecovered
-
totalChangesApplied
private AtomicLong totalChangesApplied
-
lastChangeAppliedTimestamp
private Instant lastChangeAppliedTimestamp
-
lastChangeRecoveredTimestamp
private Instant lastChangeRecoveredTimestamp
-
lastAppliedChange
private HistoryRecord lastAppliedChange
-
lastRecoveredChange
private HistoryRecord lastRecoveredChange
-
-
Constructor Detail
-
DatabaseHistoryMetrics
protected DatabaseHistoryMetrics(T taskContext, String contextName)
-
DatabaseHistoryMetrics
public DatabaseHistoryMetrics(CommonConnectorConfig connectorConfig)
-
-
Method Detail
-
getStatus
public String getStatus()
Description copied from interface:DatabaseHistoryMXBeanThe database history starts inSTOPPEDstate. Upon start it transitions toRECOVERINGstate. When all changes from stored history were applied then it switches toRUNNINGstate.Maps to
DatabaseHistoryMetrics.DatabaseHistoryStatusenum.- Specified by:
getStatusin interfaceDatabaseHistoryMXBean- Returns:
- database history component state
-
getRecoveryStartTime
public long getRecoveryStartTime()
- Specified by:
getRecoveryStartTimein interfaceDatabaseHistoryMXBean- Returns:
- time in epoch seconds when recovery has started
-
getChangesRecovered
public long getChangesRecovered()
- Specified by:
getChangesRecoveredin interfaceDatabaseHistoryMXBean- Returns:
- number of changes that were read during recovery phase
-
getChangesApplied
public long getChangesApplied()
- Specified by:
getChangesAppliedin interfaceDatabaseHistoryMXBean- Returns:
- number of changes that were applied during recovery phase increased by number of changes applied during runtime
-
getMilliSecondsSinceLastAppliedChange
public long getMilliSecondsSinceLastAppliedChange()
- Specified by:
getMilliSecondsSinceLastAppliedChangein interfaceDatabaseHistoryMXBean- Returns:
- elapsed time in milliseconds since the last change was applied
-
getMilliSecondsSinceLastRecoveredChange
public long getMilliSecondsSinceLastRecoveredChange()
- Specified by:
getMilliSecondsSinceLastRecoveredChangein interfaceDatabaseHistoryMXBean- Returns:
- elapsed time in milliseconds since the last record was recovered from history
-
getLastAppliedChange
public String getLastAppliedChange()
- Specified by:
getLastAppliedChangein interfaceDatabaseHistoryMXBean- Returns:
- String representation of the last applied change
-
getLastRecoveredChange
public String getLastRecoveredChange()
- Specified by:
getLastRecoveredChangein interfaceDatabaseHistoryMXBean- Returns:
- String representation of the last recovered change
-
started
public void started()
- Specified by:
startedin interfaceDatabaseHistoryListener
-
stopped
public void stopped()
- Specified by:
stoppedin interfaceDatabaseHistoryListener
-
recoveryStarted
public void recoveryStarted()
- Specified by:
recoveryStartedin interfaceDatabaseHistoryListener
-
recoveryStopped
public void recoveryStopped()
- Specified by:
recoveryStoppedin interfaceDatabaseHistoryListener
-
onChangeFromHistory
public void onChangeFromHistory(HistoryRecord record)
Description copied from interface:DatabaseHistoryListenerInvoked for every change read from the history during recovery.- Specified by:
onChangeFromHistoryin interfaceDatabaseHistoryListener
-
onChangeApplied
public void onChangeApplied(HistoryRecord record)
Description copied from interface:DatabaseHistoryListenerInvoked for every change applied and not filtered.- Specified by:
onChangeAppliedin interfaceDatabaseHistoryListener
-
-