22
33import jdbc .client .RedisMode ;
44import jdbc .client .impl .RedisClientBase ;
5+ import jdbc .client .impl .RedisJedisURIBase .CompleteHostAndPortMapper ;
56import jdbc .client .impl .standalone .RedisJedisClient ;
67import jdbc .client .structures .query .NodeHint ;
78import jdbc .client .structures .query .RedisKeysPatternQuery ;
89import jdbc .client .structures .query .RedisQuery ;
910import org .jetbrains .annotations .NotNull ;
11+ import org .jetbrains .annotations .Nullable ;
1012import redis .clients .jedis .*;
1113import redis .clients .jedis .Protocol .Command ;
14+ import redis .clients .jedis .exceptions .JedisConnectionException ;
1215import redis .clients .jedis .exceptions .JedisDataException ;
1316import redis .clients .jedis .exceptions .JedisException ;
1417import redis .clients .jedis .util .JedisClusterHashTag ;
@@ -29,11 +32,22 @@ public class RedisJedisClusterClient extends RedisClientBase {
2932 public RedisJedisClusterClient (@ NotNull RedisJedisClusterURI uri ) throws SQLException {
3033 try {
3134 jedisCluster = new JedisCluster (uri .getNodes (), uri , uri .getMaxAttempts (), new SingleConnectionPoolConfig ());
35+ checkClusterNodes (jedisCluster , uri .getHostAndPortMapper ());
3236 } catch (JedisException e ) {
3337 throw sqlWrap (e );
3438 }
3539 }
3640
41+ private static void checkClusterNodes (@ NotNull JedisCluster cluster ,
42+ @ Nullable CompleteHostAndPortMapper hostAndPortMapper ) throws JedisConnectionException {
43+ if (hostAndPortMapper == null ) return ;
44+ Iterable <String > nodeKeys = cluster .getClusterNodes ().keySet ();
45+ for (String nodeKey : nodeKeys ) {
46+ HostAndPort nodeHostAndPort = HostAndPort .from (nodeKey );
47+ hostAndPortMapper .getHostAndPort (nodeHostAndPort );
48+ }
49+ }
50+
3751
3852 @ Override
3953 public Object execute (@ NotNull RedisQuery query ) throws SQLException {
0 commit comments