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 included. This method will override previously included and * {@link #excludeTables(String) excluded} table names. * <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 include; may be null or * empty * @return this builder so that methods can be chained together; never null */ public TableSelectionPredicateBuilder includeTables(String fullyQualifiedTableNames) { return includeTables(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 shouldCreateFilterWithDatabaseBlacklistAndTableWhitelist() { filter = Selectors.tableSelector() .excludeDatabases("db3,db4") .includeTables("db1\\.A,db1\\.B,db2\\.C") .build(); assertAllowed(filter, "db1", "A"); assertAllowed(filter, "db1", "B"); assertNotAllowed(filter, "db1", "D"); assertNotAllowed(filter, "db1", "E"); assertNotAllowed(filter, "db1", "F"); assertAllowed(filter, "db2", "C"); assertNotAllowed(filter, "db2", "G"); assertNotAllowed(filter, "db2", "H"); assertNotAllowed(filter, "db3", "A"); assertNotAllowed(filter, "db4", "A"); }
@Test public void shouldCreateFilterWithDatabaseWhitelistAndTableWhitelist() { filter = Selectors.tableSelector() .includeDatabases("db1,db2") .includeTables("db1\\.A,db1\\.B,db2\\.C") .build(); assertAllowed(filter, "db1", "A"); assertAllowed(filter, "db1", "B"); assertNotAllowed(filter, "db1", "D"); assertNotAllowed(filter, "db1", "E"); assertNotAllowed(filter, "db1", "F"); assertAllowed(filter, "db2", "C"); assertNotAllowed(filter, "db2", "G"); assertNotAllowed(filter, "db2", "H"); assertNotAllowed(filter, "db3", "A"); assertNotAllowed(filter, "db4", "A"); }
@Test public void shouldCreateFilterWithNoDatabaseFilterAndTableWhitelist() { filter = Selectors.tableSelector() .includeTables("db1\\.A,db1\\.B,db2\\.C") .build(); assertAllowed(filter, "db1", "A"); assertAllowed(filter, "db1", "B"); assertNotAllowed(filter, "db1", "D"); assertNotAllowed(filter, "db1", "E"); assertNotAllowed(filter, "db1", "F"); assertAllowed(filter, "db2", "C"); assertNotAllowed(filter, "db2", "G"); assertNotAllowed(filter, "db2", "H"); assertNotAllowed(filter, "db3", "A"); assertNotAllowed(filter, "db4", "A"); }
@Test public void shouldCreateFilterWithSchemaWhitelistAndTableWhitelist() { filter = Selectors.tableSelector() .includeSchemas("sc1,sc2") .includeTables("db\\.sc1\\.A,db\\.sc2\\.B") .build(); assertAllowed(filter, "db", "sc1", "A"); assertNotAllowed(filter, "db", "sc1", "B"); assertAllowed(filter, "db", "sc2", "B"); assertNotAllowed(filter, "db", "sc2", "A"); assertNotAllowed(filter, "db", "sc1", "C"); assertNotAllowed(filter, "db2", "sc2", "D"); assertNotAllowed(filter, "db", "sc3", "A"); assertNotAllowed(filter, "db2", "sc4", "B"); }
@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"); }
/** * Specify the names of the tables that should be included. This method will override previously included and * {@link #excludeTables(String) excluded} table names. * <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 include; may be null or * empty * @return this builder so that methods can be chained together; never null */ public TableSelectionPredicateBuilder includeTables(String fullyQualifiedTableNames) { return includeTables(fullyQualifiedTableNames, TableId::toString); }