Skip to content

Commit 2871fdf

Browse files
committed
code review
1 parent f391075 commit 2871fdf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+971
-748
lines changed

docs/using-the-jdbc-driver/using-plugins/UsingTheBlueGreenPlugin.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The AWS JDBC Driver leverages the Blue/Green Deployment approach by intelligentl
2323
>
2424
2525

26-
## What Blue/Green Deployment Plugin does? Is it worth to use it?
26+
## What is Blue/Green Deployment Plugin?
2727

2828
During a [Blue/Green switchover](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/blue-green-deployments-switching.html), several significant changes occur to your database configuration:
2929
- Connections to blue nodes terminate at a specific point during the transition
@@ -34,7 +34,7 @@ During a [Blue/Green switchover](https://docs.aws.amazon.com/AmazonRDS/latest/Us
3434

3535

3636
All factors mentioned above may cause application disruption. The AWS Advanced JDBC Driver aims to minimize the application disruption during Blue/Green switchover by performing the following actions:
37-
- Actively monitors Blue/Green switchover status and implements appropriate measures to hold, pass-through, or re-route database traffic
37+
- Actively monitors Blue/Green switchover status and implements appropriate measures to suspend, pass-through, or re-route database traffic
3838
- Prior to Blue/Green switchover initiation, compiles a comprehensive inventory of cluster and instance endpoints for both blue and green nodes along with their corresponding IP addresses
3939
- During the active switchover phase, temporarily suspends execution of JDBC calls to blue nodes, which helps unload database nodes and reduces transaction lag for green nodes, thereby enhancing overall switchover performance
4040
- Substitutes provided hostnames with corresponding IP addresses when establishing new blue connections, effectively eliminating stale DNS data and ensuring connections to current blue nodes
@@ -48,15 +48,15 @@ All factors mentioned above may cause application disruption. The AWS Advanced J
4848
To enable the Blue/Green Deployment functionality, add the plugin code `bg` to the [`wrapperPlugins`](../UsingTheJdbcDriver.md#connection-plugin-manager-parameters) parameter value.
4949
The Blue/Green Deployment Plugin supports the following configuration parameters:
5050

51-
| Parameter | Value | Required | Description | Example Value |
52-
|----------------------------|:-------:|:--------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------|
53-
| `bgdId` | String | If using multiple Blue/Green Deployments, yes; otherwise, no | This parameter is optional and defaults to `1`. When supporting multiple Blue/Green Deployments (BGDs), this parameter becomes mandatory. Each connection string must include the `bgdId` parameter with a value that can be any number or string. However, all connection strings associated with the same Blue/Green Deployment must use identical `bgdId` values, while connection strings belonging to different BGDs must specify distinct values. | `1234`, `abc-1`, `abc-2` |
54-
| `bgConnectTimeout` | Integer | No | Maximum waiting time (in milliseconds) for establishing new connections during a Blue/Green switchover when blue and green traffic is temporarily suspended. | `30000` |
55-
| `bgBaseline` | Integer | No | The baseline interval (ms) for checking Blue/Green Deployment status. | `60000` |
56-
| `bgIncreased` | Integer | No | The increased interval (ms) for checking Blue/Green Deployment status. | `1000` |
57-
| `bgHigh` | Integer | No | The high-frequency interval (ms) for checking Blue/Green Deployment status. | `100` |
58-
| `bgSwitchoverTimeout` | Integer | No | Maximum duration (in milliseconds) allowed for switchover completion. If the switchover process stalls or exceeds this timeframe, the driver will automatically assume completion and resume normal operations. | `180000` |
59-
| `bgHoldNewBlueConnections` | Boolean | No | Enables Blue/Green Deployment switchover to suspend new blue connection requests while the switchover process is in progress. | `false` |
51+
| Parameter | Value | Required | Description | Example Value |
52+
|-------------------------------|:-------:|:--------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------|
53+
| `bgdId` | String | If using multiple Blue/Green Deployments, yes; otherwise, no | This parameter is optional and defaults to `1`. When supporting multiple Blue/Green Deployments (BGDs), this parameter becomes mandatory. Each connection string must include the `bgdId` parameter with a value that can be any number or string. However, all connection strings associated with the same Blue/Green Deployment must use identical `bgdId` values, while connection strings belonging to different BGDs must specify distinct values. | `1234`, `abc-1`, `abc-2` |
54+
| `bgConnectTimeoutMs` | Integer | No | Maximum waiting time (in milliseconds) for establishing new connections during a Blue/Green switchover when blue and green traffic is temporarily suspended. | `30000` |
55+
| `bgBaselineMs` | Integer | No | The baseline interval (ms) for checking Blue/Green Deployment status. | `60000` |
56+
| `bgIncreasedMs` | Integer | No | The increased interval (ms) for checking Blue/Green Deployment status. | `1000` |
57+
| `bgHighMs` | Integer | No | The high-frequency interval (ms) for checking Blue/Green Deployment status. | `100` |
58+
| `bgSwitchoverTimeoutMs` | Integer | No | Maximum duration (in milliseconds) allowed for switchover completion. If the switchover process stalls or exceeds this timeframe, the driver will automatically assume completion and resume normal operations. | `180000` |
59+
| `bgSuspendNewBlueConnections` | Boolean | No | Enables Blue/Green Deployment switchover to suspend new blue connection requests while the switchover process is in progress. | `false` |
6060

6161
The plugin establishes dedicated monitoring connections to track Blue/Green Deployment status. To apply specific configurations to these monitoring connections, add the `blue-green-monitoring-` prefix to any configuration parameter, as shown in the following example:
6262

wrapper/build.gradle.kts

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ tasks.register<Test>("test-all-mysql-multi-az") {
443443
}
444444
}
445445

446-
tasks.register<Test>("test-bgd-mysql-rds-instance") {
446+
tasks.register<Test>("test-bgd-mysql-rds-instance-mysql-driver") {
447447
group = "verification"
448448
filter.includeTestsMatching("integration.host.TestRunner.runTests")
449449
doFirst {
@@ -457,7 +457,6 @@ tasks.register<Test>("test-bgd-mysql-rds-instance") {
457457
systemProperty("test-no-openjdk8", "true")
458458
systemProperty("test-no-aurora", "true")
459459
systemProperty("test-no-failover", "true")
460-
//systemProperty("test-no-iam", "true")
461460
systemProperty("test-no-secrets-manager", "true")
462461
systemProperty("test-no-hikari", "true")
463462
systemProperty("test-no-instances-2", "true")
@@ -468,7 +467,31 @@ tasks.register<Test>("test-bgd-mysql-rds-instance") {
468467
}
469468
}
470469

471-
tasks.register<Test>("test-bgd-mysql-aurora") {
470+
tasks.register<Test>("test-bgd-mysql-rds-instance-mariadb-driver") {
471+
group = "verification"
472+
filter.includeTestsMatching("integration.host.TestRunner.runTests")
473+
doFirst {
474+
systemProperty("test-no-docker", "true")
475+
systemProperty("test-no-performance", "true")
476+
systemProperty("test-no-pg-driver", "true")
477+
systemProperty("test-no-pg-engine", "true")
478+
systemProperty("test-no-mysql-driver", "true")
479+
systemProperty("test-no-mariadb-engine", "true")
480+
systemProperty("test-no-graalvm", "true")
481+
systemProperty("test-no-openjdk8", "true")
482+
systemProperty("test-no-aurora", "true")
483+
systemProperty("test-no-failover", "true")
484+
systemProperty("test-no-secrets-manager", "true")
485+
systemProperty("test-no-hikari", "true")
486+
systemProperty("test-no-instances-2", "true")
487+
systemProperty("test-no-instances-3", "true")
488+
systemProperty("test-no-instances-5", "true")
489+
systemProperty("test-no-multi-az-cluster", "true")
490+
systemProperty("test-bg-only", "true")
491+
}
492+
}
493+
494+
tasks.register<Test>("test-bgd-mysql-aurora-mysql-driver") {
472495
group = "verification"
473496
filter.includeTestsMatching("integration.host.TestRunner.runTests")
474497
doFirst {
@@ -482,7 +505,31 @@ tasks.register<Test>("test-bgd-mysql-aurora") {
482505
systemProperty("test-no-openjdk8", "true")
483506
systemProperty("test-no-multi-az-instance", "true")
484507
systemProperty("test-no-failover", "true")
485-
//systemProperty("test-no-iam", "true")
508+
systemProperty("test-no-secrets-manager", "true")
509+
systemProperty("test-no-hikari", "true")
510+
systemProperty("test-no-instances-1", "true")
511+
systemProperty("test-no-instances-2", "false")
512+
systemProperty("test-no-instances-3", "true")
513+
systemProperty("test-no-instances-5", "true")
514+
systemProperty("test-no-multi-az-cluster", "true")
515+
systemProperty("test-bg-only", "true")
516+
}
517+
}
518+
519+
tasks.register<Test>("test-bgd-mysql-aurora-mariadb-driver") {
520+
group = "verification"
521+
filter.includeTestsMatching("integration.host.TestRunner.runTests")
522+
doFirst {
523+
systemProperty("test-no-docker", "true")
524+
systemProperty("test-no-performance", "true")
525+
systemProperty("test-no-pg-driver", "true")
526+
systemProperty("test-no-pg-engine", "true")
527+
systemProperty("test-no-mysql-driver", "true")
528+
systemProperty("test-no-mariadb-engine", "true")
529+
systemProperty("test-no-graalvm", "true")
530+
systemProperty("test-no-openjdk8", "true")
531+
systemProperty("test-no-multi-az-instance", "true")
532+
systemProperty("test-no-failover", "true")
486533
systemProperty("test-no-secrets-manager", "true")
487534
systemProperty("test-no-hikari", "true")
488535
systemProperty("test-no-instances-1", "true")
@@ -508,11 +555,9 @@ tasks.register<Test>("test-bgd-pg-aurora") {
508555
systemProperty("test-no-openjdk8", "true")
509556
systemProperty("test-no-multi-az-instance", "true")
510557
systemProperty("test-no-failover", "true")
511-
//systemProperty("test-no-iam", "true")
512558
systemProperty("test-no-secrets-manager", "true")
513559
systemProperty("test-no-hikari", "true")
514560
systemProperty("test-no-instances-1", "true")
515-
//systemProperty("test-no-instances-2", "true")
516561
systemProperty("test-no-instances-3", "true")
517562
systemProperty("test-no-instances-5", "true")
518563
systemProperty("test-no-multi-az-cluster", "true")
@@ -534,7 +579,6 @@ tasks.register<Test>("test-bgd-pg-rds-instance") {
534579
systemProperty("test-no-graalvm", "true")
535580
systemProperty("test-no-openjdk8", "true")
536581
systemProperty("test-no-failover", "true")
537-
//systemProperty("test-no-iam", "true")
538582
systemProperty("test-no-secrets-manager", "true")
539583
systemProperty("test-no-hikari", "true")
540584
systemProperty("test-no-instances-2", "true")

wrapper/src/main/java/software/amazon/jdbc/dialect/AuroraMysqlDialect.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import software.amazon.jdbc.hostlistprovider.monitoring.MonitoringRdsHostListProvider;
2727
import software.amazon.jdbc.plugin.failover2.FailoverConnectionPlugin;
2828

29-
public class AuroraMysqlDialect extends MysqlDialect implements SupportBlueGreen {
29+
public class AuroraMysqlDialect extends MysqlDialect implements BlueGreenDialect {
3030

3131
private static final String TOPOLOGY_QUERY =
3232
"SELECT SERVER_ID, CASE WHEN SESSION_ID = 'MASTER_SESSION_ID' THEN TRUE ELSE FALSE END, "
@@ -117,7 +117,7 @@ public String getBlueGreenStatusQuery() {
117117
}
118118

119119
@Override
120-
public boolean isStatusAvailable(final Connection connection) {
120+
public boolean isBlueGreenStatusAvailable(final Connection connection) {
121121
try {
122122
try (Statement statement = connection.createStatement();
123123
ResultSet rs = statement.executeQuery(TOPOLOGY_TABLE_EXIST_QUERY)) {

wrapper/src/main/java/software/amazon/jdbc/dialect/AuroraPgDialect.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* Suitable for the following AWS PG configurations.
3131
* - Regional Cluster
3232
*/
33-
public class AuroraPgDialect extends PgDialect implements AuroraLimitlessDialect, SupportBlueGreen {
33+
public class AuroraPgDialect extends PgDialect implements AuroraLimitlessDialect, BlueGreenDialect {
3434
private static final Logger LOGGER = Logger.getLogger(AuroraPgDialect.class.getName());
3535

3636
private static final String extensionsSql =
@@ -168,7 +168,7 @@ public String getBlueGreenStatusQuery() {
168168
}
169169

170170
@Override
171-
public boolean isStatusAvailable(final Connection connection) {
171+
public boolean isBlueGreenStatusAvailable(final Connection connection) {
172172
try {
173173
try (Statement statement = connection.createStatement();
174174
ResultSet rs = statement.executeQuery(TOPOLOGY_TABLE_EXIST_QUERY)) {

wrapper/src/main/java/software/amazon/jdbc/dialect/SupportBlueGreen.java renamed to wrapper/src/main/java/software/amazon/jdbc/dialect/BlueGreenDialect.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
import java.sql.Connection;
2020

21-
public interface SupportBlueGreen {
21+
public interface BlueGreenDialect {
2222
String getBlueGreenStatusQuery();
2323

24-
boolean isStatusAvailable(final Connection connection);
24+
boolean isBlueGreenStatusAvailable(final Connection connection);
2525
}

wrapper/src/main/java/software/amazon/jdbc/dialect/MysqlDialect.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,9 @@ public boolean isDialect(final Connection connection) {
7373
stmt = connection.createStatement();
7474
rs = stmt.executeQuery(this.getServerVersionQuery());
7575
while (rs.next()) {
76-
final int columnCount = rs.getMetaData().getColumnCount();
77-
for (int i = 1; i <= columnCount; i++) {
78-
final String columnValue = rs.getString(i);
79-
if (columnValue != null && columnValue.toLowerCase().contains("mysql")) {
80-
return true;
81-
}
76+
final String columnValue = rs.getString(2);
77+
if (columnValue != null && columnValue.toLowerCase().contains("mysql")) {
78+
return true;
8279
}
8380
}
8481
} catch (final SQLException ex) {

0 commit comments

Comments
 (0)