-
Notifications
You must be signed in to change notification settings - Fork 54
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
fix: issues with custom domains during failover #1265
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -19,7 +19,9 @@ | |||||
import java.sql.Connection; | ||||||
import java.sql.SQLException; | ||||||
import java.util.Collections; | ||||||
import java.util.HashMap; | ||||||
import java.util.HashSet; | ||||||
import java.util.Map; | ||||||
import java.util.Properties; | ||||||
import java.util.Set; | ||||||
import java.util.concurrent.TimeUnit; | ||||||
|
@@ -67,16 +69,46 @@ | |||||
"1000", | ||||||
"Time between each retry of opening a connection."); | ||||||
|
||||||
public static final AwsWrapperProperty VERIFY_OPENED_CONNECTION_TYPE = | ||||||
new AwsWrapperProperty( | ||||||
"verifyOpenedConnectionType", | ||||||
null, | ||||||
"Force to verify an opened connection to be either a writer or a reader."); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
private enum VerifyOpenedConnectionType { | ||||||
WRITER, | ||||||
READER; | ||||||
|
||||||
private static final Map<String, VerifyOpenedConnectionType> nameToValue = | ||||||
new HashMap<String, VerifyOpenedConnectionType>() { | ||||||
{ | ||||||
put("writer", WRITER); | ||||||
put("reader", READER); | ||||||
} | ||||||
}; | ||||||
|
||||||
public static VerifyOpenedConnectionType fromValue(String value) { | ||||||
if (value == null) { | ||||||
return null; | ||||||
} | ||||||
return nameToValue.get(value.toLowerCase()); | ||||||
} | ||||||
} | ||||||
|
||||||
private final PluginService pluginService; | ||||||
private HostListProviderService hostListProviderService; | ||||||
private final RdsUtils rdsUtils = new RdsUtils(); | ||||||
|
||||||
private VerifyOpenedConnectionType verifyOpenedConnectionType = null; | ||||||
|
||||||
sergiyvamz marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
static { | ||||||
PropertyDefinition.registerPluginProperties(AuroraInitialConnectionStrategyPlugin.class); | ||||||
} | ||||||
|
||||||
public AuroraInitialConnectionStrategyPlugin(final PluginService pluginService, final Properties properties) { | ||||||
this.pluginService = pluginService; | ||||||
this.verifyOpenedConnectionType = | ||||||
VerifyOpenedConnectionType.fromValue(VERIFY_OPENED_CONNECTION_TYPE.getString(properties)); | ||||||
} | ||||||
|
||||||
@Override | ||||||
|
@@ -110,12 +142,8 @@ | |||||
|
||||||
final RdsUrlType type = this.rdsUtils.identifyRdsType(hostSpec.getHost()); | ||||||
|
||||||
if (!type.isRdsCluster()) { | ||||||
// It's not a cluster endpoint. Continue with a normal workflow. | ||||||
return connectFunc.call(); | ||||||
} | ||||||
|
||||||
if (type == RdsUrlType.RDS_WRITER_CLUSTER) { | ||||||
if (type == RdsUrlType.RDS_WRITER_CLUSTER | ||||||
|| isInitialConnection && this.verifyOpenedConnectionType == VerifyOpenedConnectionType.WRITER) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need an extra set of brackets, otherwise we will still verify when using a writer cluster and it is not an initial connection
Suggested change
|
||||||
Connection writerCandidateConn = this.getVerifiedWriterConnection(props, isInitialConnection, connectFunc); | ||||||
if (writerCandidateConn == null) { | ||||||
// Can't get writer connection. Continue with a normal workflow. | ||||||
|
@@ -124,7 +152,8 @@ | |||||
return writerCandidateConn; | ||||||
} | ||||||
|
||||||
if (type == RdsUrlType.RDS_READER_CLUSTER) { | ||||||
if (type == RdsUrlType.RDS_READER_CLUSTER | ||||||
|| isInitialConnection && this.verifyOpenedConnectionType == VerifyOpenedConnectionType.READER) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Connection readerCandidateConn = this.getVerifiedReaderConnection(props, isInitialConnection, connectFunc); | ||||||
if (readerCandidateConn == null) { | ||||||
// Can't get a reader connection. Continue with a normal workflow. | ||||||
|
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 you please add this property to UsingTheAuroraInitialConnectionStrategyPlugin.md?