Skip to content

Commit

Permalink
fix - update limitless DB Shard Group DNS pattern (#1147)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronchung-bitquill authored Oct 9, 2024
1 parent 37a73b0 commit 441af36
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class ConnectionPluginManager implements CanReleaseResources, Wrapper {
protected static final Map<Class<? extends ConnectionPlugin>, String> pluginNameByClass =
new HashMap<Class<? extends ConnectionPlugin>, String>() {
{
put(LimitlessConnectionPlugin.class, "plugin:endpoint");
put(LimitlessConnectionPlugin.class, "plugin:limitless");
put(ExecutionTimeConnectionPlugin.class, "plugin:executionTime");
put(AuroraConnectionTrackerPlugin.class, "plugin:auroraConnectionTracker");
put(LogQueryConnectionPlugin.class, "plugin:logQuery");
Expand Down
16 changes: 8 additions & 8 deletions wrapper/src/main/java/software/amazon/jdbc/util/RdsUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class RdsUtils {
private static final Pattern AURORA_DNS_PATTERN =
Pattern.compile(
"^(?<instance>.+)\\."
+ "(?<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|limitless-)?"
+ "(?<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|shardgrp-)?"
+ "(?<domain>[a-zA-Z0-9]+\\.(?<region>[a-zA-Z0-9\\-]+)"
+ "\\.rds\\.amazonaws\\.com)$",
Pattern.CASE_INSENSITIVE);
Expand All @@ -90,14 +90,14 @@ public class RdsUtils {
private static final Pattern AURORA_LIMITLESS_CLUSTER_PATTERN =
Pattern.compile(
"(?<instance>.+)\\."
+ "(?<dns>limitless-)+"
+ "(?<dns>shardgrp-)+"
+ "(?<domain>[a-zA-Z0-9]+\\.(?<region>[a-zA-Z0-9\\-]+)"
+ "\\.rds\\.(amazonaws\\.com(\\.cn)?|sc2s\\.sgov\\.gov|c2s\\.ic\\.gov))",
+ "\\.rds\\.(amazonaws\\.com(\\.cn)?|sc2s\\.sgov\\.gov|c2s\\.ic\\.gov))$",
Pattern.CASE_INSENSITIVE);
private static final Pattern AURORA_CHINA_DNS_PATTERN =
Pattern.compile(
"^(?<instance>.+)\\."
+ "(?<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|limitless-)?"
+ "(?<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|shardgrp-)?"
+ "(?<domain>[a-zA-Z0-9]+\\.rds\\.(?<region>[a-zA-Z0-9\\-]+)"
+ "\\.amazonaws\\.com\\.cn)$",
Pattern.CASE_INSENSITIVE);
Expand All @@ -113,7 +113,7 @@ public class RdsUtils {
private static final Pattern AURORA_OLD_CHINA_DNS_PATTERN =
Pattern.compile(
"^(?<instance>.+)\\."
+ "(?<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|limitless-)?"
+ "(?<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|shardgrp-)?"
+ "(?<domain>[a-zA-Z0-9]+\\.(?<region>[a-zA-Z0-9\\-]+)"
+ "\\.rds\\.amazonaws\\.com\\.cn)$",
Pattern.CASE_INSENSITIVE);
Expand All @@ -129,7 +129,7 @@ public class RdsUtils {
private static final Pattern AURORA_GOV_DNS_PATTERN =
Pattern.compile(
"^(?<instance>.+)\\."
+ "(?<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|limitless-)?"
+ "(?<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|shardgrp-)?"
+ "(?<domain>[a-zA-Z0-9]+\\.rds\\.(?<region>[a-zA-Z0-9\\-]+)"
+ "\\.(amazonaws\\.com|c2s\\.ic\\.gov|sc2s\\.sgov\\.gov))$",
Pattern.CASE_INSENSITIVE);
Expand Down Expand Up @@ -258,7 +258,7 @@ public boolean isReaderClusterDns(final String host) {

public boolean isLimitlessDbShardGroupDns(final String host) {
final String dnsGroup = getDnsGroup(host);
return dnsGroup != null && dnsGroup.equalsIgnoreCase("limitless-");
return dnsGroup != null && dnsGroup.equalsIgnoreCase("shardgrp-");
}

public String getRdsClusterHostUrl(final String host) {
Expand All @@ -284,7 +284,7 @@ public String getRdsClusterHostUrl(final String host) {
}
final Matcher limitlessMatcher = AURORA_LIMITLESS_CLUSTER_PATTERN.matcher(host);
if (limitlessMatcher.find()) {
return host.replaceAll(AURORA_LIMITLESS_CLUSTER_PATTERN.pattern(), "${instance}.limitless-${domain}");
return host.replaceAll(AURORA_LIMITLESS_CLUSTER_PATTERN.pattern(), "${instance}.cluster-${domain}");
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class RdsUtilsTests {
private static final String usEastRegionCustomDomain =
"custom-test-name.cluster-custom-XYZ.us-east-2.rds.amazonaws.com";
private static final String usEastRegionLimitlessDbShardGroup =
"database-test-name.limitless-XYZ.us-east-2.rds.amazonaws.com";
"database-test-name.shardgrp-XYZ.us-east-2.rds.amazonaws.com";

private static final String chinaRegionCluster =
"database-test-name.cluster-XYZ.rds.cn-northwest-1.amazonaws.com.cn";
Expand All @@ -51,7 +51,7 @@ public class RdsUtilsTests {
private static final String chinaRegionCustomDomain =
"custom-test-name.cluster-custom-XYZ.rds.cn-northwest-1.amazonaws.com.cn";
private static final String chinaRegionLimitlessDbShardGroup =
"database-test-name.limitless-XYZ.rds.cn-northwest-1.amazonaws.com.cn";
"database-test-name.shardgrp-XYZ.rds.cn-northwest-1.amazonaws.com.cn";

private static final String oldChinaRegionCluster =
"database-test-name.cluster-XYZ.cn-northwest-1.rds.amazonaws.com.cn";
Expand All @@ -64,7 +64,7 @@ public class RdsUtilsTests {
private static final String oldChinaRegionCustomDomain =
"custom-test-name.cluster-custom-XYZ.cn-northwest-1.rds.amazonaws.com.cn";
private static final String oldChinaRegionLimitlessDbShardGroup =
"database-test-name.limitless-XYZ.cn-northwest-1.rds.amazonaws.com.cn";
"database-test-name.shardgrp-XYZ.cn-northwest-1.rds.amazonaws.com.cn";

private static final String extraRdsChinaPath =
"database-test-name.cluster-XYZ.rds.cn-northwest-1.rds.amazonaws.com.cn";
Expand All @@ -88,7 +88,7 @@ public class RdsUtilsTests {
private static final String usIsobEastRegionCustomDomain =
"custom-test-name.cluster-custom-XYZ.rds.us-isob-east-1.sc2s.sgov.gov";
private static final String usIsobEastRegionLimitlessDbShardGroup =
"database-test-name.limitless-XYZ.rds.us-isob-east-1.sc2s.sgov.gov";
"database-test-name.shardgrp-XYZ.rds.us-isob-east-1.sc2s.sgov.gov";

private static final String usGovEastRegionCluster =
"database-test-name.cluster-XYZ.rds.us-gov-east-1.amazonaws.com";
Expand All @@ -103,7 +103,7 @@ public class RdsUtilsTests {
private static final String usIsoEastRegionCustomDomain =
"custom-test-name.cluster-custom-XYZ.rds.us-iso-east-1.c2s.ic.gov";
private static final String usIsoEastRegionLimitlessDbShardGroup =
"database-test-name.limitless-XYZ.rds.us-iso-east-1.c2s.ic.gov";
"database-test-name.shardgrp-XYZ.rds.us-iso-east-1.c2s.ic.gov";

@BeforeEach
public void setupTests() {
Expand Down

0 comments on commit 441af36

Please sign in to comment.