DBZ-8050 Skip data collection names that fails to be parsed as TableId
This commit is contained in:
parent
3bd71a5e69
commit
3499f9e80d
@ -197,20 +197,29 @@ public List<DataCollection<T>> addDataCollectionNamesToSnapshot(String correlati
|
|||||||
LOGGER.trace("Adding data collections names {} to snapshot", dataCollectionIds);
|
LOGGER.trace("Adding data collections names {} to snapshot", dataCollectionIds);
|
||||||
final List<DataCollection<T>> newDataCollectionIds = dataCollectionIds.stream()
|
final List<DataCollection<T>> newDataCollectionIds = dataCollectionIds.stream()
|
||||||
.map(buildDataCollection(additionalCondition, surrogateKey))
|
.map(buildDataCollection(additionalCondition, surrogateKey))
|
||||||
|
.filter(Optional::isPresent)
|
||||||
|
.map(Optional::get)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
addTablesIdsToSnapshot(newDataCollectionIds);
|
addTablesIdsToSnapshot(newDataCollectionIds);
|
||||||
this.correlationId = correlationId;
|
this.correlationId = correlationId;
|
||||||
return newDataCollectionIds;
|
return newDataCollectionIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Function<String, DataCollection<T>> buildDataCollection(List<AdditionalCondition> additionalCondition, String surrogateKey) {
|
private Function<String, Optional<DataCollection<T>>> buildDataCollection(List<AdditionalCondition> additionalCondition, String surrogateKey) {
|
||||||
return expandedCollectionName -> {
|
return expandedCollectionName -> {
|
||||||
String filter = additionalCondition.stream()
|
String filter = additionalCondition.stream()
|
||||||
.filter(condition -> condition.getDataCollection().matcher(expandedCollectionName).matches())
|
.filter(condition -> condition.getDataCollection().matcher(expandedCollectionName).matches())
|
||||||
.map(AdditionalCondition::getFilter)
|
.map(AdditionalCondition::getFilter)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse("");
|
.orElse("");
|
||||||
return new DataCollection<T>((T) TableId.parse(expandedCollectionName, useCatalogBeforeSchema), filter, surrogateKey);
|
try {
|
||||||
|
TableId parsedTable = TableId.parse(expandedCollectionName, useCatalogBeforeSchema);
|
||||||
|
return Optional.of(new DataCollection<T>((T) parsedTable, filter, surrogateKey));
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
LOGGER.warn("Unable to parse table identifier from {}. Skipping it.", expandedCollectionName);
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,6 +553,21 @@ public void snapshotWithRegexDataCollections() throws Exception {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void snapshotWithRegexDataCollectionsNotExist() throws Exception {
|
||||||
|
|
||||||
|
LogInterceptor interceptor = new LogInterceptor(AbstractIncrementalSnapshotChangeEventSource.class);
|
||||||
|
|
||||||
|
populateTable();
|
||||||
|
startConnector();
|
||||||
|
sendAdHocSnapshotSignal(".*notExist");
|
||||||
|
|
||||||
|
// Wait until the stop has been processed, verifying it was removed from the snapshot.
|
||||||
|
Awaitility.await().atMost(60, TimeUnit.SECONDS)
|
||||||
|
.until(() -> interceptor.containsMessage("Skipping read chunk because snapshot is not running"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FixFor("DBZ-6945")
|
@FixFor("DBZ-6945")
|
||||||
public void snapshotWithDuplicateDataCollections() throws Exception {
|
public void snapshotWithDuplicateDataCollections() throws Exception {
|
||||||
|
Loading…
Reference in New Issue
Block a user