public RelationalTableFilters(Configuration config, TableFilter systemTablesFilter, TableIdToStringMapper tableIdMapper) { // Define the filter using the whitelists and blacklists for tables and database names ... Predicate<TableId> predicate = Selectors.tableSelector() // .includeDatabases(config.getString(RelationalDatabaseConnectorConfig.DATABASE_WHITELIST)) // .excludeDatabases(config.getString(RelationalDatabaseConnectorConfig.DATABASE_BLACKLIST)) .includeTables(config.getString(RelationalDatabaseConnectorConfig.TABLE_WHITELIST), tableIdMapper) .excludeTables(config.getString(RelationalDatabaseConnectorConfig.TABLE_BLACKLIST), tableIdMapper) .build(); Predicate<TableId> finalPredicate = config.getBoolean(RelationalDatabaseConnectorConfig.TABLE_IGNORE_BUILTIN) ? predicate.and(systemTablesFilter::isIncluded) : predicate; this.tableFilter = t -> finalPredicate.test(t); }
private void setFiltersFromStrings(String dbWhitelist, String dbBlacklist, String tableWhitelist, String tableBlacklist) { Predicate<String> dbFilter = Selectors.databaseSelector() .includeDatabases(dbWhitelist) .excludeDatabases(dbBlacklist) .build(); // Define the filter using the whitelists and blacklists for tables and database names ... Predicate<TableId> tableFilter = Selectors.tableSelector() .includeDatabases(dbWhitelist) .excludeDatabases(dbBlacklist) .includeTables(tableWhitelist) .excludeTables(tableBlacklist) .build(); // Ignore built-in databases and tables ... if (config.getBoolean(MySqlConnectorConfig.TABLES_IGNORE_BUILTIN)) { this.tableFilter = tableFilter.and(isBuiltInTable.negate()); this.dbFilter = dbFilter.and(isBuiltInDb.negate()); } else { this.tableFilter = tableFilter; this.dbFilter = dbFilter; } }
public RelationalTableFilters(Configuration config, TableFilter systemTablesFilter, TableIdToStringMapper tableIdMapper) { // Define the filter using the whitelists and blacklists for tables and database names ... Predicate<TableId> predicate = Selectors.tableSelector() // .includeDatabases(config.getString(RelationalDatabaseConnectorConfig.DATABASE_WHITELIST)) // .excludeDatabases(config.getString(RelationalDatabaseConnectorConfig.DATABASE_BLACKLIST)) .includeTables(config.getString(RelationalDatabaseConnectorConfig.TABLE_WHITELIST), tableIdMapper) .excludeTables(config.getString(RelationalDatabaseConnectorConfig.TABLE_BLACKLIST), tableIdMapper) .build(); Predicate<TableId> finalPredicate = config.getBoolean(RelationalDatabaseConnectorConfig.TABLE_IGNORE_BUILTIN) ? predicate.and(systemTablesFilter::isIncluded) : predicate; this.tableFilter = t -> finalPredicate.test(t); }
/** * @param config the configuration; may not be null */ public Filters(PostgresConnectorConfig config) { // we always want to exclude PG system schemas as they are never part of logical decoding events String schemaBlacklist = config.schemaBlacklist(); if (schemaBlacklist != null) { schemaBlacklist = schemaBlacklist + "," + SYSTEM_SCHEMA_BLACKLIST; } else { schemaBlacklist = SYSTEM_SCHEMA_BLACKLIST; } String tableBlacklist = config.tableBlacklist(); if (tableBlacklist != null) { tableBlacklist = tableBlacklist + "," + TEMP_TABLE_BLACKLIST; } else { tableBlacklist = TEMP_TABLE_BLACKLIST; } // Define the filter using the whitelists and blacklists for table names ... this.tableFilter = TableFilter.fromPredicate(Selectors.tableSelector() .includeTables(config.tableWhitelist()) .excludeTables(tableBlacklist) .includeSchemas(config.schemaWhitelist()) .excludeSchemas(schemaBlacklist) .build()); // Define the filter that excludes blacklisted columns, truncated columns, and masked columns ... this.columnFilter = Selectors.excludeColumns(config.columnBlacklist()); }
/** * Specify the names of the tables that should be excluded. This method will override previously {@link * #excludeDatabases(String) excluded} tables, although {@link #includeTables(String) including tables} overrides * exclusions. * <p> * Note that any specified tables that are in an {@link #excludeDatabases(String) excluded database} will not be included. * * @param fullyQualifiedTableNames the comma-separated list of fully-qualified table names to exclude; may be null or * empty * @return this builder so that methods can be chained together; never null */ public TableSelectionPredicateBuilder excludeTables(String fullyQualifiedTableNames) { return excludeTables(fullyQualifiedTableNames, TableId::toString); }
/** * @param config the configuration; may not be null */ public Filters(PostgresConnectorConfig config) { // we always want to exclude PG system schemas as they are never part of logical decoding events String schemaBlacklist = config.schemaBlacklist(); if (schemaBlacklist != null) { schemaBlacklist = schemaBlacklist + "," + SYSTEM_SCHEMA_BLACKLIST; } else { schemaBlacklist = SYSTEM_SCHEMA_BLACKLIST; } String tableBlacklist = config.tableBlacklist(); if (tableBlacklist != null) { tableBlacklist = tableBlacklist + "," + TEMP_TABLE_BLACKLIST; } else { tableBlacklist = TEMP_TABLE_BLACKLIST; } // Define the filter using the whitelists and blacklists for table names ... this.tableFilter = TableFilter.fromPredicate(Selectors.tableSelector() .includeTables(config.tableWhitelist()) .excludeTables(tableBlacklist) .includeSchemas(config.schemaWhitelist()) .excludeSchemas(schemaBlacklist) .build()); // Define the filter that excludes blacklisted columns, truncated columns, and masked columns ... this.columnFilter = Selectors.excludeColumns(config.columnBlacklist()); }
@Test public void shouldCreateFilterWithDatabaseBlacklistAndTableBlacklist() { filter = Selectors.tableSelector() .excludeDatabases("db3,db4") .excludeTables("db1\\.A,db1\\.B,db2\\.C") .build(); assertNotAllowed(filter, "db1", "A"); assertNotAllowed(filter, "db1", "B"); assertAllowed(filter, "db1", "D"); assertAllowed(filter, "db1", "E"); assertAllowed(filter, "db1", "F"); assertNotAllowed(filter, "db2", "C"); assertAllowed(filter, "db2", "G"); assertAllowed(filter, "db2", "H"); assertNotAllowed(filter, "db3", "A"); assertNotAllowed(filter, "db4", "A"); }
@Test public void shouldCreateFilterWithDatabaseWhitelistAndTableBlacklist() { filter = Selectors.tableSelector() .includeDatabases("db1,db2") .excludeTables("db1\\.A,db1\\.B,db2\\.C") .build(); assertNotAllowed(filter, "db1", "A"); assertNotAllowed(filter, "db1", "B"); assertAllowed(filter, "db1", "D"); assertAllowed(filter, "db1", "E"); assertAllowed(filter, "db1", "F"); assertNotAllowed(filter, "db2", "C"); assertAllowed(filter, "db2", "G"); assertAllowed(filter, "db2", "H"); assertNotAllowed(filter, "db3", "A"); assertNotAllowed(filter, "db4", "A"); }
@Test public void shouldCreateFilterWithNoDatabaseFilterAndTableBlacklist() { filter = Selectors.tableSelector() .excludeTables("db1\\.A,db1\\.B,db2\\.C") .build(); assertNotAllowed(filter, "db1", "A"); assertNotAllowed(filter, "db1", "B"); assertAllowed(filter, "db1", "D"); assertAllowed(filter, "db1", "E"); assertAllowed(filter, "db1", "F"); assertNotAllowed(filter, "db2", "C"); assertAllowed(filter, "db2", "G"); assertAllowed(filter, "db2", "H"); assertAllowed(filter, "db3", "A"); assertAllowed(filter, "db4", "A"); }
/** * Specify the names of the tables that should be excluded. This method will override previously {@link * #excludeDatabases(String) excluded} tables, although {@link #includeTables(String) including tables} overrides * exclusions. * <p> * Note that any specified tables that are in an {@link #excludeDatabases(String) excluded database} will not be included. * * @param fullyQualifiedTableNames the comma-separated list of fully-qualified table names to exclude; may be null or * empty * @return this builder so that methods can be chained together; never null */ public TableSelectionPredicateBuilder excludeTables(String fullyQualifiedTableNames) { return excludeTables(fullyQualifiedTableNames, TableId::toString); }
@Test public void shouldCreateFilterWithAllLists() { filter = Selectors.tableSelector() .includeDatabases("connector_test") .excludeDatabases("") .includeTables("") .excludeTables("") .build(); assertAllowed(filter, "connector_test", "A"); assertAllowed(filter, "connector_test", "B"); assertNotAllowed(filter, "other_test", "A"); assertNotAllowed(filter, "other_test", "B"); }