DBZ-3218 Handle duplicate warnings for deprecated options

This commit is contained in:
Anisha Mohanty 2021-03-09 14:49:35 +05:30 committed by Gunnar Morling
parent a3ddd3861f
commit 6856dd9a80
2 changed files with 56 additions and 14 deletions

View File

@ -235,7 +235,7 @@ public static DecimalHandlingMode parse(String value, String defaultValue) {
.withType(Type.LIST)
.withWidth(Width.LONG)
.withImportance(Importance.LOW)
.withValidation(Field::isListOfRegex, RelationalDatabaseConnectorConfig::validateTableExcludeList)
.withValidation(Field::isListOfRegex, RelationalDatabaseConnectorConfig::validateTableBlacklist)
.withInvisibleRecommender()
.withDescription(
"A comma-separated list of regular expressions that match the fully-qualified names of tables to be excluded from monitoring (deprecated, use \""
@ -273,7 +273,7 @@ public static DecimalHandlingMode parse(String value, String defaultValue) {
.withType(Type.LIST)
.withWidth(Width.LONG)
.withImportance(Importance.LOW)
.withValidation(Field::isListOfRegex, RelationalDatabaseConnectorConfig::validateColumnExcludeList)
.withValidation(Field::isListOfRegex, RelationalDatabaseConnectorConfig::validateColumnBlacklist)
.withInvisibleRecommender()
.withDescription("Regular expressions matching columns to exclude from change events (deprecated, use \"" + COLUMN_EXCLUDE_LIST.name() + "\" instead)");
@ -288,7 +288,7 @@ public static DecimalHandlingMode parse(String value, String defaultValue) {
.withType(Type.LIST)
.withWidth(Width.LONG)
.withImportance(Importance.MEDIUM)
.withValidation(Field::isListOfRegex, RelationalDatabaseConnectorConfig::validateColumnExcludeList)
.withValidation(Field::isListOfRegex)
.withDescription("Regular expressions matching columns to include in change events");
/**
@ -300,7 +300,7 @@ public static DecimalHandlingMode parse(String value, String defaultValue) {
.withType(Type.LIST)
.withWidth(Width.LONG)
.withImportance(Importance.LOW)
.withValidation(Field::isListOfRegex, RelationalDatabaseConnectorConfig::validateColumnExcludeList)
.withValidation(Field::isListOfRegex)
.withInvisibleRecommender()
.withDescription("Regular expressions matching columns to include in change events (deprecated, use \"" + COLUMN_INCLUDE_LIST.name() + "\" instead)");
@ -390,7 +390,7 @@ public static DecimalHandlingMode parse(String value, String defaultValue) {
.withType(Type.LIST)
.withWidth(Width.LONG)
.withImportance(Importance.LOW)
.withValidation(Field::isListOfRegex, RelationalDatabaseConnectorConfig::validateSchemaExcludeList)
.withValidation(Field::isListOfRegex, RelationalDatabaseConnectorConfig::validateSchemaBlacklist)
.withInvisibleRecommender()
.withDescription("The schemas for which events must not be captured (deprecated, use \"" + SCHEMA_EXCLUDE_LIST.name() + "\" instead)");
@ -435,7 +435,7 @@ public static DecimalHandlingMode parse(String value, String defaultValue) {
.withType(Type.LIST)
.withWidth(Width.LONG)
.withImportance(Importance.LOW)
.withValidation(Field::isListOfRegex, RelationalDatabaseConnectorConfig::validateDatabaseExcludeList)
.withValidation(Field::isListOfRegex, RelationalDatabaseConnectorConfig::validateDatabaseBlacklist)
.withInvisibleRecommender()
.withDescription("A comma-separated list of regular expressions that match database names to be excluded from monitoring (deprecated, use \""
+ DATABASE_EXCLUDE_LIST.name() + "\" instead)");
@ -637,9 +637,20 @@ public Boolean isFullColummnScanRequired() {
return getConfig().getBoolean(SNAPSHOT_FULL_COLUMN_SCAN_FORCE);
}
private static int validateColumnBlacklist(Configuration config, Field field, Field.ValidationOutput problems) {
String blacklist = Configuration.getFallbackStringProperty(config, COLUMN_INCLUDE_LIST, COLUMN_WHITELIST);
String whitelist = Configuration.getFallbackStringProperty(config, COLUMN_EXCLUDE_LIST, COLUMN_BLACKLIST);
if (whitelist != null && blacklist != null) {
problems.accept(COLUMN_BLACKLIST, blacklist, COLUMN_INCLUDE_LIST_ALREADY_SPECIFIED_ERROR_MSG);
return 1;
}
return 0;
}
private static int validateColumnExcludeList(Configuration config, Field field, Field.ValidationOutput problems) {
String includeList = Configuration.getFallbackStringProperty(config, COLUMN_INCLUDE_LIST, COLUMN_WHITELIST);
String excludeList = Configuration.getFallbackStringProperty(config, COLUMN_EXCLUDE_LIST, COLUMN_BLACKLIST);
String includeList = config.getString(COLUMN_INCLUDE_LIST);
String excludeList = config.getString(COLUMN_EXCLUDE_LIST);
if (includeList != null && excludeList != null) {
problems.accept(COLUMN_EXCLUDE_LIST, excludeList, COLUMN_INCLUDE_LIST_ALREADY_SPECIFIED_ERROR_MSG);
@ -657,15 +668,25 @@ public TableIdToStringMapper getTableIdMapper() {
return tableIdMapper;
}
private static int validateTableBlacklist(Configuration config, Field field, ValidationOutput problems) {
String whitelist = Configuration.getFallbackStringProperty(config, TABLE_INCLUDE_LIST, TABLE_WHITELIST);
String blacklist = Configuration.getFallbackStringProperty(config, TABLE_EXCLUDE_LIST, TABLE_BLACKLIST);
if (whitelist != null && blacklist != null) {
problems.accept(TABLE_BLACKLIST, blacklist, TABLE_INCLUDE_LIST_ALREADY_SPECIFIED_ERROR_MSG);
return 1;
}
return 0;
}
private static int validateTableExcludeList(Configuration config, Field field, ValidationOutput problems) {
String includeList = Configuration.getFallbackStringProperty(config, TABLE_INCLUDE_LIST, TABLE_WHITELIST);
String excludeList = Configuration.getFallbackStringProperty(config, TABLE_EXCLUDE_LIST, TABLE_BLACKLIST);
String includeList = config.getString(TABLE_WHITELIST);
String excludeList = config.getString(TABLE_BLACKLIST);
if (includeList != null && excludeList != null) {
problems.accept(TABLE_EXCLUDE_LIST, excludeList, TABLE_INCLUDE_LIST_ALREADY_SPECIFIED_ERROR_MSG);
return 1;
}
return 0;
}
@ -690,9 +711,20 @@ public Map<TableId, String> getSnapshotSelectOverridesByTable() {
return Collections.unmodifiableMap(snapshotSelectOverridesByTable);
}
private static int validateSchemaBlacklist(Configuration config, Field field, Field.ValidationOutput problems) {
String whitelist = Configuration.getFallbackStringProperty(config, SCHEMA_INCLUDE_LIST, SCHEMA_WHITELIST);
String blacklist = Configuration.getFallbackStringProperty(config, SCHEMA_EXCLUDE_LIST, SCHEMA_BLACKLIST);
if (whitelist != null && blacklist != null) {
problems.accept(SCHEMA_BLACKLIST, blacklist, SCHEMA_INCLUDE_LIST_ALREADY_SPECIFIED_ERROR_MSG);
return 1;
}
return 0;
}
private static int validateSchemaExcludeList(Configuration config, Field field, Field.ValidationOutput problems) {
String includeList = Configuration.getFallbackStringProperty(config, SCHEMA_INCLUDE_LIST, SCHEMA_WHITELIST);
String excludeList = Configuration.getFallbackStringProperty(config, SCHEMA_EXCLUDE_LIST, SCHEMA_BLACKLIST);
String includeList = config.getString(SCHEMA_INCLUDE_LIST);
String excludeList = config.getString(SCHEMA_EXCLUDE_LIST);
if (includeList != null && excludeList != null) {
problems.accept(SCHEMA_EXCLUDE_LIST, excludeList, SCHEMA_INCLUDE_LIST_ALREADY_SPECIFIED_ERROR_MSG);
@ -711,6 +743,16 @@ private static int validateDatabaseExcludeList(Configuration config, Field field
return 0;
}
private static int validateDatabaseBlacklist(Configuration config, Field field, ValidationOutput problems) {
String whitelist = Configuration.getFallbackStringProperty(config, DATABASE_INCLUDE_LIST, DATABASE_WHITELIST);
String blacklist = Configuration.getFallbackStringProperty(config, DATABASE_EXCLUDE_LIST, DATABASE_BLACKLIST);
if (whitelist != null && blacklist != null) {
problems.accept(DATABASE_BLACKLIST, blacklist, DATABASE_INCLUDE_LIST_ALREADY_SPECIFIED_ERROR_MSG);
return 1;
}
return 0;
}
private static int validateMessageKeyColumnsField(Configuration config, Field field, Field.ValidationOutput problems) {
String msgKeyColumns = config.getString(MSG_KEY_COLUMNS);
int problemCount = 0;

View File

@ -70,7 +70,7 @@ public void shouldThrowValidationOnDuplicateOldColumnFilterConfigurationOld() {
.with(COLUMN_BLACKLIST, ".+bb")
.build();
List<String> errorMessages = config.validate(Field.setOf(COLUMN_EXCLUDE_LIST)).get(COLUMN_EXCLUDE_LIST.name()).errorMessages();
List<String> errorMessages = config.validate(Field.setOf(COLUMN_BLACKLIST)).get(COLUMN_BLACKLIST.name()).errorMessages();
assertThat(errorMessages).isNotEmpty();
assertThat(errorMessages.get(0)).isEqualTo(RelationalDatabaseConnectorConfig.COLUMN_INCLUDE_LIST_ALREADY_SPECIFIED_ERROR_MSG);
}