Skip to content

[3.0][flink-cdc-composer] Connector JAR discovery utilities#2662

Merged
PatrickRen merged 5 commits intoapache:masterfrom
GOODBOY008:master-composer
Nov 14, 2023
Merged

[3.0][flink-cdc-composer] Connector JAR discovery utilities#2662
PatrickRen merged 5 commits intoapache:masterfrom
GOODBOY008:master-composer

Conversation

@GOODBOY008
Copy link
Copy Markdown
Member

@GOODBOY008 GOODBOY008 commented Nov 7, 2023

After #2661 (review) merged will carry on.
[3.0][flink-cdc-composer] Connector JAR discovery utilities.
Close #2620

@GOODBOY008 GOODBOY008 requested a review from PatrickRen November 7, 2023 08:19
@GOODBOY008 GOODBOY008 self-assigned this Nov 7, 2023
Copy link
Copy Markdown
Contributor

@PatrickRen PatrickRen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GOODBOY008 Thanks for the PR! I left some comments.

private FactoryDiscoveryUtils() {}

/** Returns the {@link Factory} for the given identifier. */
public static Factory getFactoryByIdentifier(String identifier) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about the scenario: MySQL connector defines two classes: MySQLDataSourceFactory and MySQLDataSinkFactory, and both factories use "mysql" as the identifier. In this case this method will throw exception because two factories are found.

I think using generic type here would be more friendly to callers, like this one in Flink. To resolve the issue above, callers can use getFactoryByIdentifier("mysql", DataSourceFactory.class) to get the only MySQLDataSourceFactory.


@Override
public void handleEventFromOperator(int i, int i1, OperatorEvent operatorEvent)
public void notifyCheckpointAborted(long checkpointId) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe splitting this into a hotfix commit, or sync with @ruanhang1993 ?

Copy link
Copy Markdown
Contributor

@PatrickRen PatrickRen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GOODBOY008 Thanks for the update! I left some comments. Also please add tests for new utilities.

/** Returns the {@link Factory} for the given identifier. */
@SuppressWarnings("unchecked")
public static <T extends Factory> T getFactoryByIdentifier(
String identifier, Class<T> implementClass) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using factoryClass instead of implementClass for the second argument? The function uses a factory interface for searching an implementation.

factoryList.add(factory);
}
} catch (Throwable e) {
if (e.getCause() instanceof NoClassDefFoundError) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite get the logic of handling NoClassDefFoundError here. The same logic in Flink is for handling a special case where flink-connector-files is missing. I think we don't have that issue in our project, so maybe just throw the exception directly?

@GOODBOY008 GOODBOY008 requested a review from PatrickRen November 8, 2023 12:24
Copy link
Copy Markdown
Contributor

@PatrickRen PatrickRen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GOODBOY008 Thanks for the update! LGTM overall. I pushed a commit to use AssertJ-style assertions in FactoryDiscoveryUtilsTest. Will merge the PR after all CI tests pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[flink-cdc-composer] Connector JAR discovery utilities

2 participants