1
1
package redis .clients .jedis ;
2
2
3
- import redis .clients .jedis .MultiClusterClientConfig . ClusterConfig ;
3
+ import redis .clients .jedis .MultiDatabaseConfig . 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 ;
9
9
import redis .clients .jedis .mcf .MultiClusterPipeline ;
10
10
import redis .clients .jedis .mcf .MultiClusterTransaction ;
11
11
import redis .clients .jedis .providers .ConnectionProvider ;
12
- import redis .clients .jedis .mcf .MultiClusterPooledConnectionProvider ;
12
+ import redis .clients .jedis .mcf .MultiDatabaseConnectionProvider ;
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
+ * MultiDatabaseConfig .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())
76
76
* </p>
77
77
* @author Ivo Gaydazhiev
78
78
* @since 5.2.0
79
- * @see MultiClusterPooledConnectionProvider
79
+ * @see MultiDatabaseConnectionProvider
80
80
* @see CircuitBreakerCommandExecutor
81
- * @see MultiClusterClientConfig
81
+ * @see MultiDatabaseConfig
82
82
*/
83
83
@ Experimental
84
84
public class MultiDbClient extends UnifiedJedis {
@@ -91,8 +91,7 @@ public class MultiDbClient extends UnifiedJedis {
91
91
* {@link #builder()} to create instances.
92
92
* </p>
93
93
* @param commandExecutor the command executor (typically CircuitBreakerCommandExecutor)
94
- * @param connectionProvider the connection provider (typically
95
- * MultiClusterPooledConnectionProvider)
94
+ * @param connectionProvider the connection provider (typically MultiDatabaseConnectionProvider)
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 MultiDatabaseConnectionProvider .
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 MultiDatabaseConnectionProvider
113
112
*/
114
- private MultiClusterPooledConnectionProvider getMultiClusterProvider () {
115
- return (MultiClusterPooledConnectionProvider ) this .provider ;
113
+ private MultiDatabaseConnectionProvider getMultiDatabaseConnectionProvider () {
114
+ return (MultiDatabaseConnectionProvider ) 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
+ getMultiDatabaseConnectionProvider ().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
+ getMultiDatabaseConnectionProvider ().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
+ getMultiDatabaseConnectionProvider ().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 getMultiDatabaseConnectionProvider ().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 getMultiDatabaseConnectionProvider ().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
+ getMultiDatabaseConnectionProvider ().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
+ getMultiDatabaseConnectionProvider ().forceActiveDatabase (endpoint , forcedActiveDurationMs );
215
214
}
216
215
217
216
/**
@@ -224,7 +223,7 @@ public void forceActiveEndpoint(Endpoint endpoint, long forcedActiveDurationMs)
224
223
*/
225
224
@ Override
226
225
public MultiClusterPipeline pipelined () {
227
- return new MultiClusterPipeline (getMultiClusterProvider (), commandObjects );
226
+ return new MultiClusterPipeline (getMultiDatabaseConnectionProvider (), commandObjects );
228
227
}
229
228
230
229
/**
@@ -237,7 +236,7 @@ public MultiClusterPipeline pipelined() {
237
236
*/
238
237
@ Override
239
238
public MultiClusterTransaction multi () {
240
- return new MultiClusterTransaction ((MultiClusterPooledConnectionProvider ) provider , true ,
239
+ return new MultiClusterTransaction ((MultiDatabaseConnectionProvider ) provider , true ,
241
240
commandObjects );
242
241
}
243
242
@@ -252,11 +251,12 @@ public MultiClusterTransaction transaction(boolean doMulti) {
252
251
"It is not allowed to create Transaction from this " + getClass ());
253
252
}
254
253
255
- return new MultiClusterTransaction (getMultiClusterProvider (), doMulti , commandObjects );
254
+ return new MultiClusterTransaction (getMultiDatabaseConnectionProvider (), doMulti ,
255
+ commandObjects );
256
256
}
257
257
258
258
public Endpoint getActiveEndpoint () {
259
- return getMultiClusterProvider ().getCluster ().getEndpoint ();
259
+ return getMultiDatabaseConnectionProvider ().getDatabase ().getEndpoint ();
260
260
}
261
261
262
262
/**
0 commit comments