Skip to content

Commit 203a063

Browse files
committed
code review
1 parent 03d3a25 commit 203a063

18 files changed

+135
-164
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: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,13 +451,12 @@ tasks.register<Test>("test-bgd-mysql-rds-instance") {
451451
systemProperty("test-no-performance", "true")
452452
systemProperty("test-no-pg-driver", "true")
453453
systemProperty("test-no-pg-engine", "true")
454-
systemProperty("test-no-mariadb-driver", "true")
454+
//systemProperty("test-no-mariadb-driver", "true") // TODO: verify
455455
systemProperty("test-no-mariadb-engine", "true")
456456
systemProperty("test-no-graalvm", "true")
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")
@@ -476,13 +475,12 @@ tasks.register<Test>("test-bgd-mysql-aurora") {
476475
systemProperty("test-no-performance", "true")
477476
systemProperty("test-no-pg-driver", "true")
478477
systemProperty("test-no-pg-engine", "true")
479-
systemProperty("test-no-mariadb-driver", "true")
478+
//systemProperty("test-no-mariadb-driver", "true") // TODO: verify
480479
systemProperty("test-no-mariadb-engine", "true")
481480
systemProperty("test-no-graalvm", "true")
482481
systemProperty("test-no-openjdk8", "true")
483482
systemProperty("test-no-multi-az-instance", "true")
484483
systemProperty("test-no-failover", "true")
485-
//systemProperty("test-no-iam", "true")
486484
systemProperty("test-no-secrets-manager", "true")
487485
systemProperty("test-no-hikari", "true")
488486
systemProperty("test-no-instances-1", "true")
@@ -508,11 +506,9 @@ tasks.register<Test>("test-bgd-pg-aurora") {
508506
systemProperty("test-no-openjdk8", "true")
509507
systemProperty("test-no-multi-az-instance", "true")
510508
systemProperty("test-no-failover", "true")
511-
//systemProperty("test-no-iam", "true")
512509
systemProperty("test-no-secrets-manager", "true")
513510
systemProperty("test-no-hikari", "true")
514511
systemProperty("test-no-instances-1", "true")
515-
//systemProperty("test-no-instances-2", "true")
516512
systemProperty("test-no-instances-3", "true")
517513
systemProperty("test-no-instances-5", "true")
518514
systemProperty("test-no-multi-az-cluster", "true")
@@ -534,7 +530,6 @@ tasks.register<Test>("test-bgd-pg-rds-instance") {
534530
systemProperty("test-no-graalvm", "true")
535531
systemProperty("test-no-openjdk8", "true")
536532
systemProperty("test-no-failover", "true")
537-
//systemProperty("test-no-iam", "true")
538533
systemProperty("test-no-secrets-manager", "true")
539534
systemProperty("test-no-hikari", "true")
540535
systemProperty("test-no-instances-2", "true")

wrapper/src/main/java/software/amazon/jdbc/plugin/bluegreen/BlueGreenConnectionPlugin.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@
4646
public class BlueGreenConnectionPlugin extends AbstractConnectionPlugin {
4747

4848
private static final Logger LOGGER = Logger.getLogger(BlueGreenConnectionPlugin.class.getName());
49+
4950
public static final AwsWrapperProperty BG_CONNECT_TIMEOUT = new AwsWrapperProperty(
50-
"bgConnectTimeout", "30000",
51+
"bgConnectTimeoutMs", "30000",
5152
"Connect timeout (in msec) during Blue/Green Deployment switchover.");
5253

5354
public static final AwsWrapperProperty BGD_ID = new AwsWrapperProperty(
@@ -66,13 +67,24 @@ public class BlueGreenConnectionPlugin extends AbstractConnectionPlugin {
6667
"ResultSet.close"
6768
)));
6869

70+
protected static final Set<String> subscribedMethods =
71+
Collections.unmodifiableSet(new HashSet<String>() {
72+
{
73+
/*
74+
We should NOT to subscribe to "forceConnect" pipeline since it's used by
75+
BG monitoring, and we don't want to intercept/block those monitoring connections.
76+
*/
77+
add("connect");
78+
addAll(SubscribedMethodHelper.NETWORK_BOUND_METHODS);
79+
}
80+
});
81+
6982
static {
7083
PropertyDefinition.registerPluginProperties(BlueGreenConnectionPlugin.class);
7184
}
7285

7386
protected final PluginService pluginService;
7487
protected final Properties props;
75-
protected final Set<String> subscribedMethods;
7688
protected BlueGreenProviderSupplier providerSupplier;
7789

7890
protected final TelemetryFactory telemetryFactory;
@@ -102,20 +114,11 @@ public BlueGreenConnectionPlugin(
102114
this.telemetryFactory = pluginService.getTelemetryFactory();
103115
this.providerSupplier = providerSupplier;
104116
this.bgdId = Objects.requireNonNull(BGD_ID.getString(this.props)).trim().toLowerCase();
105-
106-
final Set<String> methods = new HashSet<>();
107-
/*
108-
We should NOT to subscribe to "forceConnect" pipeline since it's used by
109-
BG monitoring, and we don't want to intercept/block those monitoring connections.
110-
*/
111-
methods.add("connect");
112-
methods.addAll(SubscribedMethodHelper.NETWORK_BOUND_METHODS);
113-
this.subscribedMethods = Collections.unmodifiableSet(methods);
114117
}
115118

116119
@Override
117120
public Set<String> getSubscribedMethods() {
118-
return this.subscribedMethods;
121+
return subscribedMethods;
119122
}
120123

121124
@Override

wrapper/src/main/java/software/amazon/jdbc/plugin/bluegreen/IntervalType.java renamed to wrapper/src/main/java/software/amazon/jdbc/plugin/bluegreen/BlueGreenIntervalRate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package software.amazon.jdbc.plugin.bluegreen;
1818

19-
public enum IntervalType {
19+
public enum BlueGreenIntervalRate {
2020
BASELINE,
2121
INCREASED,
2222
HIGH

wrapper/src/main/java/software/amazon/jdbc/plugin/bluegreen/BlueGreenPhases.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ public enum BlueGreenPhases {
2626
COMPLETED(5, true); // all changes are completed
2727

2828
private final int value;
29-
private final boolean activeSwitchover;
29+
private final boolean activeSwitchoverOrCompleted;
3030

31-
BlueGreenPhases(final int newValue, final boolean activeSwitchover) {
31+
BlueGreenPhases(final int newValue, final boolean activeSwitchoverOrCompleted) {
3232

3333
this.value = newValue;
34-
this.activeSwitchover = activeSwitchover;
34+
this.activeSwitchoverOrCompleted = activeSwitchoverOrCompleted;
3535
}
3636

3737
public int getValue() {
3838
return this.value;
3939
}
4040

41-
public boolean isActiveSwitchover() {
42-
return this.activeSwitchover;
41+
public boolean isActiveSwitchoverOrCompleted() {
42+
return this.activeSwitchoverOrCompleted;
4343
}
4444
}

wrapper/src/main/java/software/amazon/jdbc/plugin/bluegreen/BlueGreenRole.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package software.amazon.jdbc.plugin.bluegreen;
1818

1919
import java.util.HashMap;
20+
import java.util.Map;
2021
import software.amazon.jdbc.util.Messages;
2122
import software.amazon.jdbc.util.StringUtils;
2223

@@ -25,7 +26,7 @@ public enum BlueGreenRole {
2526
TARGET(1);
2627

2728
// ver 1.0 mapping
28-
protected static final HashMap<String, BlueGreenRole> blueGreenRoleMapping_1_0 =
29+
private static final Map<String, BlueGreenRole> blueGreenRoleMapping_1_0 =
2930
new HashMap<String, BlueGreenRole>() {
3031
{
3132
put("BLUE_GREEN_DEPLOYMENT_SOURCE", BlueGreenRole.SOURCE);

0 commit comments

Comments
 (0)