Class LogFileCollector
java.lang.Object
io.debezium.connector.oracle.logminer.LogFileCollector
A collector that is responsible for fetching, deduplication, and supplying Debezium with a set of
LogFile instances that should be mined given a specific Scn.- Author:
- Chris Cranford
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classRepresents an inclusive range between two values. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate final Stringprivate final booleanprivate final Durationprivate final OracleConnectionprivate final Durationprivate static final org.slf4j.Loggerprivate final intprivate final Durationprivate static final Stringprivate static final String -
Constructor Summary
ConstructorsConstructorDescriptionLogFileCollector(OracleConnectorConfig connectorConfig, OracleConnection connection) -
Method Summary
Modifier and TypeMethodDescriptiondeduplicateLogFiles(Collection<LogFile> archiveLogFiles, Collection<LogFile> onlineLogFiles) getFirstLogMissingSequence(List<LogFile> logFiles) Searches the specified redo-thread logs and returns the first missing log sequence; if any exist.Get a list of all log files that should be mined given the specified system change number.getLogsForOffsetScn(Scn offsetScn) private StringgetLogsQuery(Scn offsetScn) Get the SQL query to fetch logs that contain or come after the specified system change number.private ScngetScnFromString(String value) Converts the specified stringvalueto anScn.private LogFileCollector.SequenceRangegetSequenceRangeForRedoThreadLogs(List<LogFile> redoThreadLogs) Calculates the sequence range for a collection of logs for a given redo thread.private booleanhasLogFileWithSequenceNumber(long sequenceId, List<LogFile> redoThreadLogs) Check whether there is a log file in the collection with the specified sequence number.private booleanisClosedThreadConsistent(RedoThreadState.RedoThread thread, Scn startScn, List<LogFile> threadLogs) Checks whether the specified closedthreadhas consistent redo-logs in the specified collection.booleanisLogFileListConsistent(Scn startScn, List<LogFile> logs, RedoThreadState currentRedoThreadState) Checks consistency of the list of log files for redo threads in thecurrentRedoThreadStatestate.private booleanisOpenThreadConsistent(RedoThreadState.RedoThread thread, Scn startScn, List<LogFile> threadLogs) Checks whether the specified openthreadhas consistent redo-logs in the specified collection.private static voidlogException(String message) private voidlogThreadCheckSkippedNotInDatabase(int threadId) Logs a warning that the thread check was skipped because the specified thread has no matchingV$THREADentry.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
STATUS_CURRENT
- See Also:
-
ONLINE_LOG_TYPE
- See Also:
-
ARCHIVE_LOG_TYPE
- See Also:
-
initialDelay
-
maxRetryDelay
-
maxAttempts
private final int maxAttempts -
archiveLogRetention
-
archiveLogOnlyMode
private final boolean archiveLogOnlyMode -
archiveLogDestinationName
-
connection
-
-
Constructor Details
-
LogFileCollector
-
-
Method Details
-
getLogs
Get a list of all log files that should be mined given the specified system change number.- Parameters:
offsetScn- minimum system change number to start reading changes from, should not benull- Returns:
- list of log file instances that should be added to the mining session, never
null - Throws:
SQLException- if there is a database failure during the collectionDebeziumException- if we were unable to collect logs due to a non-SQL related failure
-
getLogsForOffsetScn
- Throws:
SQLException
-
deduplicateLogFiles
@VisibleForTesting public List<LogFile> deduplicateLogFiles(Collection<LogFile> archiveLogFiles, Collection<LogFile> onlineLogFiles) -
isLogFileListConsistent
@VisibleForTesting public boolean isLogFileListConsistent(Scn startScn, List<LogFile> logs, RedoThreadState currentRedoThreadState) Checks consistency of the list of log files for redo threads in thecurrentRedoThreadStatestate.- Parameters:
startScn- the read position system change number, should not benulllogs- the list of logs to inspect, should not benullcurrentRedoThreadState- the current database redo thread state, should not benull- Returns:
trueif the logs are consistent;falseotherwise
-
isOpenThreadConsistent
private boolean isOpenThreadConsistent(RedoThreadState.RedoThread thread, Scn startScn, List<LogFile> threadLogs) Checks whether the specified openthreadhas consistent redo-logs in the specified collection.- Parameters:
thread- the redo thread to inspect; should not benullstartScn- the read position system change number, should not benullthreadLogs- the redo-thread logs to check consistency against, may benullor empty- Returns:
trueif the open thread's logs are consistent;falseotherwise
-
isClosedThreadConsistent
private boolean isClosedThreadConsistent(RedoThreadState.RedoThread thread, Scn startScn, List<LogFile> threadLogs) Checks whether the specified closedthreadhas consistent redo-logs in the specified collection.- Parameters:
thread- the redo thread to inspect; should not benullstartScn- the read position system change number, should not benullthreadLogs- the redo-thread logs to check consistency against, may benullor empty- Returns:
trueif the closed thread's logs are consistent;falseotherwise
-
getFirstLogMissingSequence
Searches the specified redo-thread logs and returns the first missing log sequence; if any exist. This method will return an empty value if there are no sequence gaps.- Parameters:
logFiles- the redo-thread logs to search; should not benullor empty- Returns:
- the first missing sequence or an empty value if no gaps are detected
-
logThreadCheckSkippedNotInDatabase
private void logThreadCheckSkippedNotInDatabase(int threadId) Logs a warning that the thread check was skipped because the specified thread has no matchingV$THREADentry.- Parameters:
threadId- the redo thread id with no matching database record.
-
getLogsQuery
Get the SQL query to fetch logs that contain or come after the specified system change number.- Parameters:
offsetScn- the starting system change number to read from, should not benull- Returns:
- query string
-
getScnFromString
Converts the specified stringvalueto anScn.- Parameters:
value- the value to convert, can benullor empty- Returns:
- the system change number for the specified value
-
hasLogFileWithSequenceNumber
Check whether there is a log file in the collection with the specified sequence number.- Parameters:
sequenceId- the sequence number to checkredoThreadLogs- the collection of redo-thread specific logs to inspect- Returns:
trueif a log exists with the sequence;falseotherwise
-
getSequenceRangeForRedoThreadLogs
private LogFileCollector.SequenceRange getSequenceRangeForRedoThreadLogs(List<LogFile> redoThreadLogs) Calculates the sequence range for a collection of logs for a given redo thread.- Parameters:
redoThreadLogs- the redo logs collection, should not beempty.- Returns:
- the sequence range for the collection of logs
- Throws:
DebeziumException- if the log collection is empty
-
logException
-