[FLINK-36406][cdc-runtime] Close MetadataApplier when the job stops

This closes  #3623
pull/3864/head
Sergei Morozov 2 weeks ago committed by GitHub
parent 9ad071c1fa
commit 5691b7bf97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -30,7 +30,7 @@ import java.util.stream.Collectors;
/** {@code MetadataApplier} is used to apply metadata changes to external systems. */
@PublicEvolving
public interface MetadataApplier extends Serializable {
public interface MetadataApplier extends Serializable, AutoCloseable {
/** Apply the given {@link SchemaChangeEvent} to external systems. */
void applySchemaChange(SchemaChangeEvent schemaChangeEvent) throws SchemaEvolveException;
@ -50,4 +50,8 @@ public interface MetadataApplier extends Serializable {
default Set<SchemaChangeEventType> getSupportedSchemaEvolutionTypes() {
return Arrays.stream(SchemaChangeEventTypeFamily.ALL).collect(Collectors.toSet());
}
/** Closes the metadata applier and its underlying resources. */
@Override
default void close() throws Exception {}
}

@ -153,6 +153,13 @@ public class PaimonMetadataApplier implements MetadataApplier {
});
}
@Override
public void close() throws Exception {
if (catalog != null) {
catalog.close();
}
}
private void applyCreateTable(CreateTableEvent event) throws SchemaEvolveException {
try {
if (!catalog.databaseExists(event.tableId().getSchemaName())) {

Loading…
Cancel
Save