-
Notifications
You must be signed in to change notification settings - Fork 72
refactor: host alias logic in wrapper #431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
wrapper/src/main/java/software/amazon/jdbc/PluginServiceImpl.java
Outdated
Show resolved
Hide resolved
wrapper/src/main/java/software/amazon/jdbc/hostlistprovider/AuroraHostListProvider.java
Show resolved
Hide resolved
| if (resultSet.next()) { | ||
| final String instanceName = resultSet.getString(1); | ||
| if (this.getCachedTopology() == null) { | ||
| final HostSpec host = new HostSpec(getHostEndpoint(instanceName)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we refresh topology with provided connection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return null;
wrapper/src/main/java/software/amazon/jdbc/hostlistprovider/AuroraHostListProvider.java
Outdated
Show resolved
Hide resolved
|
|
||
| @Override | ||
| public HostSpec identifyConnection(Connection connection) throws SQLException { | ||
| return this.hostList.get(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, we need to get sql from dialect, fetch node id, try to find it in topology.
|
|
||
| if (conn != null) { | ||
| generateHostAliases(driverProtocol, conn, hostSpec); | ||
| hostSpec.resetAliases(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why to reset? Some other plugin might already filled aliases for this host spec.
wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorServiceImpl.java
Outdated
Show resolved
Hide resolved
… instead of instance endpoints during status checks.
3a0b9c6 to
2997d86
Compare
wrapper/src/main/java/software/amazon/jdbc/plugin/efm/HostMonitoringConnectionPlugin.java
Show resolved
Hide resolved
| "MonitorServiceImpl.emptyAliasSet", | ||
| new Object[] {hostSpec})); | ||
| hostSpec.addAlias(hostSpec.asAlias()); | ||
| try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this entire try-catch block. We just rely on provided nodeKeys, and if they empty then we raise an exception.
acf1b5b to
d4c4586
Compare
d4c4586 to
9f49f77
Compare
9f49f77 to
10f4a56
Compare
| PluginServiceImpl.hostAliasNotFound=Can''t find any host by the following aliases: ''{0}''. | ||
| PluginServiceImpl.hostsChangelistEmpty=There are no changes in the hosts' availability. | ||
| PluginServiceImpl.failedToRetrieveHostPort=Could not retrieve Host:Port for connection. | ||
| PluginServiceImpl.nonEmptyAliases=fillAliases called when HostSpec already contains the following aliases: ''{0}''. Please reset HostSpec aliases before calling this method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Please reset HostSpec aliases before calling this method."
I think it may mislead developers.
"Please reset HostSpec aliases if you need to re-fill them again." ?
e3b98ad to
c9a45a7
Compare
Summary
Integration Test Run
https://github.com/Bit-Quill/aws-advanced-jdbc-wrapper/actions/runs/4920404497
Description
Issues fixed
Issue 1 Solution
Issue one is caused by the following check.
We need to remove the check for
PROMOTED_TO_WRITERIssue 2 & 3
Issues 2 and 3 are both caused by missing or incorrect instance endpoint in the hostspec's aliases. Issues 2 and 3 were originally fixed in #428 and #428, and the fixes contain a lot of similarities. This refactoring centralizes the logic populating the aliases and make it less error prone.
More information in respective tickets:
https://github.com/orgs/awslabs/projects/91/views/13?pane=issue&itemId=27190320
https://github.com/orgs/awslabs/projects/91/views/13?pane=issue&itemId=27190427
Additional Reviewers
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.