Skip to content

Commit 379fdf4

Browse files
authored
[hitless upgrade] Rename maintenance notification configuration properties (#3450)
* Rename MaintenanceEventsOptions to MaintNotificationsConfig Rename configuration class and properties for maintenance notifications: - MaintenanceEventsOptions → MaintNotificationsConfig - supportMaintenanceEvents() → enableMaintNotifications() - supportsMaintenanceEvents() → maintNotificationsEnabled() - getMaintenanceEventsOptions() → getMaintNotificationsConfig() Updates all references across codebase and tests. * Rename AddressType to EndpointType in maintenance notifications Rename maintenance notification address types to endpoint types: - AddressType → EndpointType enum - AddressTypeSource → EndpointTypeSource class - getAddressType() → getEndpointType() method - fixedAddressType() → endpointType() builder method - autoResolveAddressType() → autoResolveEndpointType() method * Fix relaxedTimeouts API doc * format * remove duplicated TypeType from method name * rename timeoutsRelaxingDuringMaintenance to relaxedTimeoutsDuringMaintenance
1 parent 6c63efa commit 379fdf4

18 files changed

+500
-493
lines changed

src/main/java/io/lettuce/core/AbstractRedisClient.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
package io.lettuce.core;
2121

2222
import java.io.Closeable;
23-
import java.net.InetAddress;
24-
import java.net.InetSocketAddress;
2523
import java.net.SocketAddress;
2624
import java.time.Duration;
2725
import java.util.ArrayList;
@@ -36,7 +34,7 @@
3634
import java.util.concurrent.atomic.AtomicBoolean;
3735
import java.util.concurrent.atomic.AtomicInteger;
3836

39-
import io.lettuce.core.MaintenanceEventsOptions.AddressTypeSource;
37+
import io.lettuce.core.MaintNotificationsConfig.EndpointTypeSource;
4038
import reactor.core.publisher.Mono;
4139
import io.lettuce.core.event.command.CommandListener;
4240
import io.lettuce.core.event.connection.ConnectEvent;
@@ -589,12 +587,12 @@ private CompletableFuture<Void> closeClientResources(long quietPeriod, long time
589587
}
590588

591589
protected RedisHandshake createHandshake(ConnectionState state) {
592-
AddressTypeSource source = null;
593-
if (clientOptions.getMaintenanceEventsOptions().supportsMaintenanceEvents()) {
594-
LettuceAssert.notNull(clientOptions.getMaintenanceEventsOptions().getAddressTypeSource(),
590+
EndpointTypeSource source = null;
591+
if (clientOptions.getMaintNotificationsConfig().maintNotificationsEnabled()) {
592+
LettuceAssert.notNull(clientOptions.getMaintNotificationsConfig().getEndpointTypeSource(),
595593
"Address type source must not be null");
596594

597-
source = clientOptions.getMaintenanceEventsOptions().getAddressTypeSource();
595+
source = clientOptions.getMaintNotificationsConfig().getEndpointTypeSource();
598596
}
599597

600598
return new RedisHandshake(clientOptions.getConfiguredProtocolVersion(), clientOptions.isPingBeforeActivateConnection(),

src/main/java/io/lettuce/core/ClientOptions.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class ClientOptions implements Serializable {
5151

5252
public static final boolean DEFAULT_AUTO_RECONNECT = true;
5353

54-
public static final MaintenanceEventsOptions DEFAULT_MAINTENANCE_EVENTS_OPTIONS = MaintenanceEventsOptions.enabled();
54+
public static final MaintNotificationsConfig DEFAULT_MAINT_NOTIFICATIONS_CONFIG = MaintNotificationsConfig.enabled();
5555

5656
public static final Predicate<RedisCommand<?, ?, ?>> DEFAULT_REPLAY_FILTER = (cmd) -> false;
5757

@@ -95,7 +95,7 @@ public class ClientOptions implements Serializable {
9595

9696
private final boolean autoReconnect;
9797

98-
private final MaintenanceEventsOptions maintenanceEventsOptions;
98+
private final MaintNotificationsConfig maintNotificationsConfig;
9999

100100
private final Predicate<RedisCommand<?, ?, ?>> replayFilter;
101101

@@ -131,7 +131,7 @@ public class ClientOptions implements Serializable {
131131

132132
protected ClientOptions(Builder builder) {
133133
this.autoReconnect = builder.autoReconnect;
134-
this.maintenanceEventsOptions = builder.maintenanceEventsOptions;
134+
this.maintNotificationsConfig = builder.maintNotificationsConfig;
135135
this.replayFilter = builder.replayFilter;
136136
this.decodeBufferPolicy = builder.decodeBufferPolicy;
137137
this.disconnectedBehavior = builder.disconnectedBehavior;
@@ -152,7 +152,7 @@ protected ClientOptions(Builder builder) {
152152

153153
protected ClientOptions(ClientOptions original) {
154154
this.autoReconnect = original.isAutoReconnect();
155-
this.maintenanceEventsOptions = original.getMaintenanceEventsOptions();
155+
this.maintNotificationsConfig = original.getMaintNotificationsConfig();
156156
this.replayFilter = original.getReplayFilter();
157157
this.decodeBufferPolicy = original.getDecodeBufferPolicy();
158158
this.disconnectedBehavior = original.getDisconnectedBehavior();
@@ -206,7 +206,7 @@ public static class Builder {
206206

207207
private boolean autoReconnect = DEFAULT_AUTO_RECONNECT;
208208

209-
private MaintenanceEventsOptions maintenanceEventsOptions = DEFAULT_MAINTENANCE_EVENTS_OPTIONS;
209+
private MaintNotificationsConfig maintNotificationsConfig = DEFAULT_MAINT_NOTIFICATIONS_CONFIG;
210210

211211
private Predicate<RedisCommand<?, ?, ?>> replayFilter = DEFAULT_REPLAY_FILTER;
212212

@@ -259,14 +259,14 @@ public Builder autoReconnect(boolean autoReconnect) {
259259
* Configure whether the driver should listen for server events that notify on current maintenance activities. When
260260
* enabled, this option will help with the connection handover and reduce the number of failed commands. This feature
261261
* requires the server to support maintenance events. Defaults to {@code false}. See
262-
* {@link #DEFAULT_MAINTENANCE_EVENTS_OPTIONS}.
262+
* {@link #DEFAULT_MAINT_NOTIFICATIONS_CONFIG}.
263263
*
264-
* @param maintenanceEventsOptions true/false
264+
* @param maintNotificationsConfig true/false
265265
* @return {@code this}
266266
* @since 7.0
267267
*/
268-
public Builder supportMaintenanceEvents(MaintenanceEventsOptions maintenanceEventsOptions) {
269-
this.maintenanceEventsOptions = maintenanceEventsOptions;
268+
public Builder maintNotificationsConfig(MaintNotificationsConfig maintNotificationsConfig) {
269+
this.maintNotificationsConfig = maintNotificationsConfig;
270270
return this;
271271
}
272272

@@ -530,7 +530,7 @@ public ClientOptions build() {
530530
public ClientOptions.Builder mutate() {
531531
Builder builder = new Builder();
532532

533-
builder.autoReconnect(isAutoReconnect()).supportMaintenanceEvents(getMaintenanceEventsOptions())
533+
builder.autoReconnect(isAutoReconnect()).maintNotificationsConfig(getMaintNotificationsConfig())
534534
.replayFilter(getReplayFilter()).decodeBufferPolicy(getDecodeBufferPolicy())
535535
.disconnectedBehavior(getDisconnectedBehavior()).reauthenticateBehavior(getReauthenticateBehaviour())
536536
.readOnlyCommands(getReadOnlyCommands()).publishOnScheduler(isPublishOnScheduler())
@@ -556,15 +556,15 @@ public boolean isAutoReconnect() {
556556
}
557557

558558
/**
559-
* Returns the {@link MaintenanceEventsOptions} to listen for server events that notify on current maintenance activities.
559+
* Returns the {@link MaintNotificationsConfig} to listen for server events that notify on current maintenance activities.
560560
*
561-
* @return {@link MaintenanceEventsOptions}
561+
* @return {@link MaintNotificationsConfig}
562562
* @since 7.0
563-
* @see #DEFAULT_MAINTENANCE_EVENTS_OPTIONS
564-
* @see #getMaintenanceEventsOptions()
563+
* @see #DEFAULT_MAINT_NOTIFICATIONS_CONFIG
564+
* @see #getMaintNotificationsConfig()
565565
*/
566-
public MaintenanceEventsOptions getMaintenanceEventsOptions() {
567-
return maintenanceEventsOptions;
566+
public MaintNotificationsConfig getMaintNotificationsConfig() {
567+
return maintNotificationsConfig;
568568
}
569569

570570
/**

src/main/java/io/lettuce/core/ConnectionBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ protected ConnectionWatchdog createConnectionWatchdog() {
156156
LettuceAssert.assertState(socketAddressSupplier != null, "SocketAddressSupplier must be set for autoReconnect=true");
157157

158158
ConnectionWatchdog watchdog;
159-
if (clientOptions.getMaintenanceEventsOptions().supportsMaintenanceEvents()) {
159+
if (clientOptions.getMaintNotificationsConfig().maintNotificationsEnabled()) {
160160
MaintenanceAwareConnectionWatchdog maintenanceAwareWatchdog = new MaintenanceAwareConnectionWatchdog(
161161
clientResources.reconnectDelay(), clientOptions, bootstrap, clientResources.timer(),
162162
clientResources.eventExecutorGroup(), socketAddressSupplier, reconnectionListener, connection,

0 commit comments

Comments
 (0)