public class LogMinerHelper extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
LogMinerHelper.DATATYPE |
| Modifier and Type | Field and Description |
|---|---|
private static org.slf4j.Logger |
LOGGER |
static BigInteger |
MAX_SCN_BI |
static String |
MAX_SCN_S |
private static Map<String,OracleConnection> |
racFlushConnections |
private static String |
TOTAL |
private static String |
UNKNOWN |
| Constructor and Description |
|---|
LogMinerHelper() |
| Modifier and Type | Method and Description |
|---|---|
(package private) static void |
buildDataDictionary(Connection connection)
This builds data dictionary objects in redo log files.
|
(package private) static void |
checkSupplementalLogging(OracleConnection connection,
String pdbName,
OracleDatabaseSchema schema)
This method validates the supplemental logging configuration for the source database.
|
private static OracleConnection |
createFlushConnection(io.debezium.jdbc.JdbcConfiguration config,
String host) |
(package private) static void |
createFlushTable(Connection connection) |
(package private) static void |
createLogMiningHistoryObjects(Connection connection,
String historyTableName) |
(package private) static void |
deleteOutdatedHistory(Connection connection,
long retention) |
static void |
endMining(Connection connection)
This call completes log miner session.
|
private static void |
executeCallableStatement(Connection connection,
String statement) |
(package private) static void |
flushLogWriter(Connection connection,
io.debezium.jdbc.JdbcConfiguration config,
boolean isRac,
Set<String> racHosts)
It is critical to flush LogWriter(s) buffer
|
private static void |
flushRacLogWriters(long currentScn,
io.debezium.jdbc.JdbcConfiguration config,
Set<String> racHosts)
Oracle RAC has one LogWriter per node (instance), we have to flush them all
We cannot use a query like from gv_instance view to get all the nodes, because not all nodes could be load balanced.
|
static Map<String,BigInteger> |
getArchivedLogFilesForOffsetScn(Connection connection,
Long offsetScn,
Duration archiveLogRetention)
This method returns all archived log files for one day, containing given offset scn
|
(package private) static Set<String> |
getCurrentRedoLogFiles(Connection connection,
LogMinerMetrics metrics)
This method query the database to get CURRENT online redo log file(s).
|
static long |
getCurrentScn(Connection connection)
This method returns current SCN from the database
|
(package private) static long |
getEndScn(Connection connection,
long startScn,
LogMinerMetrics metrics)
This method returns next SCN for mining and also updates MBean metrics
We use a configurable limit, because the larger mining range, the slower query from Log Miner content view.
|
(package private) static long |
getFirstOnlineLogScn(Connection connection,
Duration archiveLogRetention)
This method fetches the oldest SCN from online redo log files
|
static Optional<Long> |
getLastScnToAbandon(Connection connection,
Long offsetScn,
int hoursToKeepTransaction)
This method calculates SCN as a watermark to abandon long lasting transactions.
|
static Map<String,String> |
getMap(Connection connection,
String query,
String nullReplacement) |
static Map<String,BigInteger> |
getOnlineLogFilesForOffsetScn(Connection connection,
Long offsetScn)
This method returns all online log files, starting from one which contains offset SCN and ending with one containing largest SCN
18446744073709551615 on Ora 19c is the max value of the nextScn in the current redo todo replace all Long with BigInteger for SCN
|
private static int |
getRedoLogGroupSize(Connection connection)
get size of online REDO groups
|
private static Map<String,String> |
getRedoLogStatus(Connection connection)
This fetches online redo log statuses
|
static Object |
getSingleResult(Connection connection,
String query,
LogMinerHelper.DATATYPE type) |
private static int |
getSwitchCount(Connection connection)
This fetches REDO LOG switch count for the last day
|
(package private) static Duration |
getTimeDifference(Connection connection)
Calculate time difference between database and connector timers.
|
(package private) static void |
instantiateFlushConnections(io.debezium.jdbc.JdbcConfiguration config,
Set<String> hosts) |
(package private) static void |
logError(TransactionalBufferMetrics metrics,
String format,
Object... args) |
(package private) static void |
logWarn(TransactionalBufferMetrics metrics,
String format,
Object... args) |
static void |
removeLogFilesFromMining(Connection conn)
This method removes all added log files from mining
|
(package private) static void |
setNlsSessionParameters(io.debezium.jdbc.JdbcConnection connection)
Sets NLS parameters for mining session.
|
static void |
setRedoLogFilesForMining(Connection connection,
Long lastProcessedScn,
Duration archiveLogRetention)
This method substitutes CONTINUOUS_MINE functionality
|
(package private) static void |
startLogMining(Connection connection,
Long startScn,
Long endScn,
OracleConnectorConfig.LogMiningStrategy strategy,
boolean isContinuousMining)
This method builds mining view to query changes from.
|
private static void |
updateRedoLogMetrics(Connection connection,
LogMinerMetrics metrics,
Set<String> fileNames)
This is to update MBean metrics associated with REDO LOG groups
|
private static final String UNKNOWN
private static final String TOTAL
private static final org.slf4j.Logger LOGGER
public static final String MAX_SCN_S
public static final BigInteger MAX_SCN_BI
private static Map<String,OracleConnection> racFlushConnections
static void instantiateFlushConnections(io.debezium.jdbc.JdbcConfiguration config,
Set<String> hosts)
static void buildDataDictionary(Connection connection) throws SQLException
connection - connection to the database as log miner user (connection to the container)SQLException - any exceptionpublic static long getCurrentScn(Connection connection) throws SQLException
connection - container level database connectionSQLException - if anything unexpected happensstatic void createFlushTable(Connection connection) throws SQLException
SQLExceptionstatic void createLogMiningHistoryObjects(Connection connection, String historyTableName) throws SQLException
SQLExceptionstatic void deleteOutdatedHistory(Connection connection, long retention) throws SQLException
SQLExceptionstatic long getEndScn(Connection connection, long startScn, LogMinerMetrics metrics) throws SQLException
connection - container level database connectionstartScn - start SCNmetrics - MBean accessible metricsSQLException - if anything unexpected happensstatic void flushLogWriter(Connection connection, io.debezium.jdbc.JdbcConfiguration config, boolean isRac, Set<String> racHosts) throws SQLException
connection - container level database connectionconfig - configurationisRac - true if this is the RAC systemracHosts - set of RAC hostSQLException - exceptionstatic Duration getTimeDifference(Connection connection) throws SQLException
connection - connectionDurationSQLExceptionstatic void startLogMining(Connection connection, Long startScn, Long endScn, OracleConnectorConfig.LogMiningStrategy strategy, boolean isContinuousMining) throws SQLException
connection - container level database connectionstartScn - the SCN to mine fromendScn - the SCN to mine tostrategy - this is about dictionary locationisContinuousMining - works < 19 version onlySQLException - if anything unexpected happensstatic Set<String> getCurrentRedoLogFiles(Connection connection, LogMinerMetrics metrics) throws SQLException
connection - connection to reusemetrics - MBean accessible metricsSQLException - if anything unexpected happensstatic long getFirstOnlineLogScn(Connection connection, Duration archiveLogRetention) throws SQLException
connection - container level database connectionarchiveLogRetention - duration that archive logs are minedSQLException - if anything unexpected happensstatic void setNlsSessionParameters(io.debezium.jdbc.JdbcConnection connection)
throws SQLException
connection - session level database connectionSQLException - if anything unexpected happensprivate static void updateRedoLogMetrics(Connection connection, LogMinerMetrics metrics, Set<String> fileNames)
connection - connectionfileNames - name of current REDO LOG filesmetrics - current metricsprivate static Map<String,String> getRedoLogStatus(Connection connection) throws SQLException
connection - privileged connectionSQLException - if anything unexpected happensprivate static int getSwitchCount(Connection connection)
connection - privileged connectionprivate static void flushRacLogWriters(long currentScn,
io.debezium.jdbc.JdbcConfiguration config,
Set<String> racHosts)
private static OracleConnection createFlushConnection(io.debezium.jdbc.JdbcConfiguration config, String host) throws SQLException
SQLExceptionstatic void checkSupplementalLogging(OracleConnection connection, String pdbName, OracleDatabaseSchema schema) throws SQLException
connection - oracle connection on logminer levelpdbName - pdb nameschema - oracle schemaSQLException - if anything unexpected happenspublic static void endMining(Connection connection)
connection - container level database connectionpublic static void setRedoLogFilesForMining(Connection connection, Long lastProcessedScn, Duration archiveLogRetention) throws SQLException
connection - connectionlastProcessedScn - current offsetarchiveLogRetention - the duration that archive logs will be minedSQLException - if anything unexpected happenspublic static Optional<Long> getLastScnToAbandon(Connection connection, Long offsetScn, int hoursToKeepTransaction)
connection - connectionoffsetScn - current offset scnhoursToKeepTransaction - hours to tolerate long transactionstatic void logWarn(TransactionalBufferMetrics metrics, String format, Object... args)
static void logError(TransactionalBufferMetrics metrics, String format, Object... args)
private static int getRedoLogGroupSize(Connection connection) throws SQLException
connection - connectionSQLExceptionpublic static Map<String,BigInteger> getOnlineLogFilesForOffsetScn(Connection connection, Long offsetScn) throws SQLException
SQLExceptionpublic static Map<String,BigInteger> getArchivedLogFilesForOffsetScn(Connection connection, Long offsetScn, Duration archiveLogRetention) throws SQLException
connection - connectionoffsetScn - offset scnarchiveLogRetention - duration that archive logs will be minedSQLException - if something happenspublic static void removeLogFilesFromMining(Connection conn) throws SQLException
conn - connectionSQLException - something happenedprivate static void executeCallableStatement(Connection connection, String statement) throws SQLException
SQLExceptionpublic static Map<String,String> getMap(Connection connection, String query, String nullReplacement) throws SQLException
SQLExceptionpublic static Object getSingleResult(Connection connection, String query, LogMinerHelper.DATATYPE type) throws SQLException
SQLExceptionCopyright © 2021 JBoss by Red Hat. All rights reserved.