1
1
package redis .clients .jedis ;
2
2
3
- import redis .clients .jedis .MultiClusterClientConfig . ClusterConfig ;
3
+ import redis .clients .jedis .MultiDbConfig . DatabaseConfig ;
4
4
import redis .clients .jedis .annots .Experimental ;
5
5
import redis .clients .jedis .builders .MultiDbClientBuilder ;
6
6
import redis .clients .jedis .csc .Cache ;
7
7
import redis .clients .jedis .executors .CommandExecutor ;
8
- import redis .clients .jedis .mcf .CircuitBreakerCommandExecutor ;
9
- import redis .clients .jedis .mcf .MultiClusterPipeline ;
10
- import redis .clients .jedis .mcf .MultiClusterTransaction ;
8
+ import redis .clients .jedis .mcf .MultiDbCommandExecutor ;
9
+ import redis .clients .jedis .mcf .MultiDbPipeline ;
10
+ import redis .clients .jedis .mcf .MultiDbTransaction ;
11
11
import redis .clients .jedis .providers .ConnectionProvider ;
12
- import redis .clients .jedis .mcf .MultiClusterPooledConnectionProvider ;
12
+ import redis .clients .jedis .mcf .MultiDbConnectionProvider ;
13
13
14
14
import java .util .Set ;
15
15
43
43
*
44
44
* MultiDbClient client = MultiDbClient.builder()
45
45
* .multiDbConfig(
46
- * MultiClusterClientConfig .builder()
46
+ * MultiDbConfig .builder()
47
47
* .endpoint(
48
- * ClusterConfig .builder(
48
+ * DatabaseConfig .builder(
49
49
* primary,
50
50
* DefaultJedisClientConfig.builder().build())
51
51
* .weight(100.0f)
52
52
* .build())
53
- * .endpoint(ClusterConfig .builder(
53
+ * .endpoint(DatabaseConfig .builder(
54
54
* secondary,
55
55
* DefaultJedisClientConfig.builder().build())
56
56
* .weight(50.0f).build())
75
75
* resilience features.
76
76
* </p>
77
77
* @author Ivo Gaydazhiev
78
- * @since 5.2 .0
79
- * @see MultiClusterPooledConnectionProvider
80
- * @see CircuitBreakerCommandExecutor
81
- * @see MultiClusterClientConfig
78
+ * @since 7.0 .0
79
+ * @see MultiDbConnectionProvider
80
+ * @see MultiDbCommandExecutor
81
+ * @see MultiDbConfig
82
82
*/
83
83
@ Experimental
84
84
public class MultiDbClient extends UnifiedJedis {
@@ -90,9 +90,8 @@ public class MultiDbClient extends UnifiedJedis {
90
90
* the builder pattern for advanced configurations. For most use cases, prefer using
91
91
* {@link #builder()} to create instances.
92
92
* </p>
93
- * @param commandExecutor the command executor (typically CircuitBreakerCommandExecutor)
94
- * @param connectionProvider the connection provider (typically
95
- * MultiClusterPooledConnectionProvider)
93
+ * @param commandExecutor the command executor (typically MultiDbCommandExecutor)
94
+ * @param connectionProvider the connection provider (typically MultiDbConnectionProvider)
96
95
* @param commandObjects the command objects
97
96
* @param redisProtocol the Redis protocol version
98
97
* @param cache the client-side cache (may be null)
@@ -103,16 +102,16 @@ public class MultiDbClient extends UnifiedJedis {
103
102
}
104
103
105
104
/**
106
- * Returns the underlying MultiClusterPooledConnectionProvider .
105
+ * Returns the underlying MultiDbConnectionProvider .
107
106
* <p>
108
107
* This provides access to multi-cluster specific operations like manual failover, health status
109
108
* monitoring, and cluster switch event handling.
110
109
* </p>
111
110
* @return the multi-cluster connection provider
112
- * @throws ClassCastException if the provider is not a MultiClusterPooledConnectionProvider
111
+ * @throws ClassCastException if the provider is not a MultiDbConnectionProvider
113
112
*/
114
- private MultiClusterPooledConnectionProvider getMultiClusterProvider () {
115
- return (MultiClusterPooledConnectionProvider ) this .provider ;
113
+ private MultiDbConnectionProvider getMultiDbConnectionProvider () {
114
+ return (MultiDbConnectionProvider ) this .provider ;
116
115
}
117
116
118
117
/**
@@ -124,20 +123,20 @@ private MultiClusterPooledConnectionProvider getMultiClusterProvider() {
124
123
* @param endpoint the endpoint to switch to
125
124
*/
126
125
public void setActiveDatabase (Endpoint endpoint ) {
127
- getMultiClusterProvider ().setActiveCluster (endpoint );
126
+ getMultiDbConnectionProvider ().setActiveDatabase (endpoint );
128
127
}
129
128
130
129
/**
131
130
* Adds a pre-configured cluster configuration.
132
131
* <p>
133
- * This method allows adding a fully configured ClusterConfig instance, providing maximum
132
+ * This method allows adding a fully configured DatabaseConfig instance, providing maximum
134
133
* flexibility for advanced configurations including custom health check strategies, connection
135
134
* pool settings, etc.
136
135
* </p>
137
- * @param clusterConfig the pre-configured cluster configuration
136
+ * @param databaseConfig the pre-configured database configuration
138
137
*/
139
- public void addEndpoint (ClusterConfig clusterConfig ) {
140
- getMultiClusterProvider ().add (clusterConfig );
138
+ public void addEndpoint (DatabaseConfig databaseConfig ) {
139
+ getMultiDbConnectionProvider ().add (databaseConfig );
141
140
}
142
141
143
142
/**
@@ -153,10 +152,10 @@ public void addEndpoint(ClusterConfig clusterConfig) {
153
152
* @throws redis.clients.jedis.exceptions.JedisValidationException if the endpoint already exists
154
153
*/
155
154
public void addEndpoint (Endpoint endpoint , float weight , JedisClientConfig clientConfig ) {
156
- ClusterConfig clusterConfig = ClusterConfig .builder (endpoint , clientConfig ).weight (weight )
155
+ DatabaseConfig databaseConfig = DatabaseConfig .builder (endpoint , clientConfig ).weight (weight )
157
156
.build ();
158
157
159
- getMultiClusterProvider ().add (clusterConfig );
158
+ getMultiDbConnectionProvider ().add (databaseConfig );
160
159
}
161
160
162
161
/**
@@ -167,7 +166,7 @@ public void addEndpoint(Endpoint endpoint, float weight, JedisClientConfig clien
167
166
* @return the set of all configured endpoints
168
167
*/
169
168
public Set <Endpoint > getEndpoints () {
170
- return getMultiClusterProvider ().getEndpoints ();
169
+ return getMultiDbConnectionProvider ().getEndpoints ();
171
170
}
172
171
173
172
/**
@@ -179,7 +178,7 @@ public Set<Endpoint> getEndpoints() {
179
178
* @return the health status of the endpoint
180
179
*/
181
180
public boolean isHealthy (Endpoint endpoint ) {
182
- return getMultiClusterProvider ().isHealthy (endpoint );
181
+ return getMultiDbConnectionProvider ().isHealthy (endpoint );
183
182
}
184
183
185
184
/**
@@ -195,7 +194,7 @@ public boolean isHealthy(Endpoint endpoint) {
195
194
* healthy clusters available
196
195
*/
197
196
public void removeEndpoint (Endpoint endpoint ) {
198
- getMultiClusterProvider ().remove (endpoint );
197
+ getMultiDbConnectionProvider ().remove (endpoint );
199
198
}
200
199
201
200
/**
@@ -211,7 +210,7 @@ public void removeEndpoint(Endpoint endpoint) {
211
210
* or doesn't exist
212
211
*/
213
212
public void forceActiveEndpoint (Endpoint endpoint , long forcedActiveDurationMs ) {
214
- getMultiClusterProvider ().forceActiveCluster (endpoint , forcedActiveDurationMs );
213
+ getMultiDbConnectionProvider ().forceActiveDatabase (endpoint , forcedActiveDurationMs );
215
214
}
216
215
217
216
/**
@@ -220,11 +219,11 @@ public void forceActiveEndpoint(Endpoint endpoint, long forcedActiveDurationMs)
220
219
* The returned pipeline supports the same resilience features as the main client, including
221
220
* automatic failover during batch execution.
222
221
* </p>
223
- * @return a new MultiClusterPipeline instance
222
+ * @return a new MultiDbPipeline instance
224
223
*/
225
224
@ Override
226
- public MultiClusterPipeline pipelined () {
227
- return new MultiClusterPipeline ( getMultiClusterProvider (), commandObjects );
225
+ public MultiDbPipeline pipelined () {
226
+ return new MultiDbPipeline ( getMultiDbConnectionProvider (), commandObjects );
228
227
}
229
228
230
229
/**
@@ -233,30 +232,29 @@ public MultiClusterPipeline pipelined() {
233
232
* The returned transaction supports the same resilience features as the main client, including
234
233
* automatic failover during transaction execution.
235
234
* </p>
236
- * @return a new MultiClusterTransaction instance
235
+ * @return a new MultiDbTransaction instance
237
236
*/
238
237
@ Override
239
- public MultiClusterTransaction multi () {
240
- return new MultiClusterTransaction ((MultiClusterPooledConnectionProvider ) provider , true ,
241
- commandObjects );
238
+ public MultiDbTransaction multi () {
239
+ return new MultiDbTransaction ((MultiDbConnectionProvider ) provider , true , commandObjects );
242
240
}
243
241
244
242
/**
245
243
* @param doMulti {@code false} should be set to enable manual WATCH, UNWATCH and MULTI
246
244
* @return transaction object
247
245
*/
248
246
@ Override
249
- public MultiClusterTransaction transaction (boolean doMulti ) {
247
+ public MultiDbTransaction transaction (boolean doMulti ) {
250
248
if (provider == null ) {
251
249
throw new IllegalStateException (
252
250
"It is not allowed to create Transaction from this " + getClass ());
253
251
}
254
252
255
- return new MultiClusterTransaction ( getMultiClusterProvider (), doMulti , commandObjects );
253
+ return new MultiDbTransaction ( getMultiDbConnectionProvider (), doMulti , commandObjects );
256
254
}
257
255
258
256
public Endpoint getActiveEndpoint () {
259
- return getMultiClusterProvider ().getCluster ().getEndpoint ();
257
+ return getMultiDbConnectionProvider ().getDatabase ().getEndpoint ();
260
258
}
261
259
262
260
/**
0 commit comments