Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit eb3ad1e

Browse files
committedJul 7, 2017
DATAREDIS-659 - Polishing.
Update JavaDoc and assert nullability contract. Use slowlog-max-len in tests instead of maxclients avoiding potential ulimit errors. Original Pull Request: #253
1 parent 4c88fe1 commit eb3ad1e

11 files changed

+377
-145
lines changed
 

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ build
1515
out
1616
work
1717
*.rdb
18+
*.aof

‎src/main/java/org/springframework/data/redis/connection/ReactiveClusterServerCommands.java

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,102 +23,163 @@
2323
import org.springframework.data.redis.core.types.RedisClientInfo;
2424

2525
/**
26+
* Redis Server commands executed in cluster environment using reactive infrastructure.
27+
*
2628
* @author Mark Paluch
29+
* @author Christoph Strobl
2730
* @since 2.0
2831
*/
2932
public interface ReactiveClusterServerCommands extends ReactiveServerCommands {
3033

3134
/**
35+
* Start an {@literal Append Only File} rewrite process on the specific server.
36+
*
3237
* @param node must not be {@literal null}.
38+
* @return {@link Mono} indicating command completion.
39+
* @throws IllegalArgumentException when {@code node} is {@literal null}.
3340
* @see RedisServerCommands#bgReWriteAof()
3441
*/
3542
Mono<String> bgReWriteAof(RedisClusterNode node);
3643

3744
/**
45+
* Start background saving of db on server.
46+
*
3847
* @param node must not be {@literal null}.
48+
* @return {@link Mono} indicating command received by server. Operation success needs to be checked via
49+
* {@link #lastSave(RedisClusterNode)}.
50+
* @throws IllegalArgumentException when {@code node} is {@literal null}.
3951
* @see RedisServerCommands#bgSave()
4052
*/
4153
Mono<String> bgSave(RedisClusterNode node);
4254

4355
/**
56+
* Get time unix timestamp of last successful {@link #bgSave()} operation in seconds.
57+
*
4458
* @param node must not be {@literal null}.
45-
* @return
59+
* @return @return {@link Mono} wrapping unix timestamp.
60+
* @throws IllegalArgumentException when {@code node} is {@literal null}.
4661
* @see RedisServerCommands#lastSave()
4762
*/
4863
Mono<Long> lastSave(RedisClusterNode node);
4964

5065
/**
66+
* Synchronous save current db snapshot on server.
67+
*
5168
* @param node must not be {@literal null}.
69+
* @return {@link Mono} indicating command completion.
70+
* @throws IllegalArgumentException when {@code node} is {@literal null}.
5271
* @see RedisServerCommands#save()
5372
*/
5473
Mono<String> save(RedisClusterNode node);
5574

5675
/**
76+
* Get the total number of available keys in currently selected database.
77+
*
5778
* @param node must not be {@literal null}.
58-
* @return
79+
* @return {@link Mono} wrapping number of keys.
80+
* @throws IllegalArgumentException when {@code node} is {@literal null}.
5981
* @see RedisServerCommands#dbSize()
6082
*/
6183
Mono<Long> dbSize(RedisClusterNode node);
6284

6385
/**
64-
* @param node must not be {@literal null}.
86+
* Delete all keys of the currently selected database.
87+
*
88+
* @param node must not be {@literal null}. {@link Mono} indicating command completion.
89+
* @throws IllegalArgumentException when {@code node} is {@literal null}.
6590
* @see RedisServerCommands#flushDb()
6691
*/
6792
Mono<String> flushDb(RedisClusterNode node);
6893

6994
/**
95+
* Delete all <b>all keys</b> from <b>all databases</b>.
96+
*
7097
* @param node must not be {@literal null}.
98+
* @return {@link Mono} indicating command completion.
99+
* @throws IllegalArgumentException when {@code node} is {@literal null}.
71100
* @see RedisServerCommands#flushAll()
72101
*/
73102
Mono<String> flushAll(RedisClusterNode node);
74103

75104
/**
105+
* Load {@literal default} server information like
106+
* <ul>
107+
* <li>memory</li>
108+
* <li>cpu utilization</li>
109+
* <li>replication</li>
110+
* </ul>
111+
* <p>
112+
*
76113
* @param node must not be {@literal null}.
77-
* @return
114+
* @return {@link Mono} wrapping server information.
115+
* @throws IllegalArgumentException when {@code node} is {@literal null}.
78116
* @see RedisServerCommands#info()
79117
*/
80118
Mono<Properties> info(RedisClusterNode node);
81119

82120
/**
121+
* Load server information for given {@code selection}.
122+
*
83123
* @param node must not be {@literal null}.
84-
* @param section
85-
* @return
124+
* @param section must not be {@literal null} nor {@literal empty}.
125+
* @return {@link Mono} wrapping server information of given {@code section}.
126+
* @throws IllegalArgumentException when {@code node} is {@literal null}.
127+
* @throws IllegalArgumentException when section is {@literal null} or {@literal empty}.
86128
* @see RedisServerCommands#info(String)
87129
*/
88130
Mono<Properties> info(RedisClusterNode node, String section);
89131

90132
/**
133+
* Load configuration parameters for given {@code pattern} from server.
134+
*
91135
* @param node must not be {@literal null}.
92-
* @param pattern
93-
* @return
136+
* @param pattern must not be {@literal null}.
137+
* @return {@link Mono} wrapping configuration parameters matching given {@code pattern}.
138+
* @throws IllegalArgumentException when {@code node} is {@literal null}.
139+
* @throws IllegalArgumentException when {@code pattern} is {@literal null} or {@literal empty}.
94140
* @see RedisServerCommands#getConfig(String)
95141
*/
96142
Mono<Properties> getConfig(RedisClusterNode node, String pattern);
97143

98144
/**
145+
* Set server configuration for {@code param} to {@code value}.
146+
*
99147
* @param node must not be {@literal null}.
100-
* @param param
101-
* @param value
148+
* @param param must not be {@literal null} nor {@literal empty}.
149+
* @param value must not be {@literal null} nor {@literal empty}.
150+
* @throws IllegalArgumentException when {@code node} is {@literal null}.
151+
* @throws IllegalArgumentException when {@code pattern} / {@code value} is {@literal null} or {@literal empty}.
102152
* @see RedisServerCommands#setConfig(String, String)
103153
*/
104154
Mono<String> setConfig(RedisClusterNode node, String param, String value);
105155

106156
/**
157+
* Reset statistic counters on server. <br>
158+
* Counters can be retrieved using {@link #info()}.
159+
*
107160
* @param node must not be {@literal null}.
161+
* @return {@link Mono} indicating command completion.
162+
* @throws IllegalArgumentException when {@code node} is {@literal null}.
108163
* @see RedisServerCommands#resetConfigStats()
109164
*/
110165
Mono<String> resetConfigStats(RedisClusterNode node);
111166

112167
/**
168+
* Request server timestamp using {@code TIME} command.
169+
*
113170
* @param node must not be {@literal null}.
114-
* @return
171+
* @return {@link Mono} wrapping current server time in milliseconds.
172+
* @throws IllegalArgumentException when {@code node} is {@literal null}.
115173
* @see RedisServerCommands#time()
116174
*/
117175
Mono<Long> time(RedisClusterNode node);
118176

119177
/**
178+
* Request information and statistics about connected clients.
179+
*
120180
* @param node must not be {@literal null}.
121-
* @return
181+
* @return {@link Flux} emitting {@link RedisClientInfo} objects.
182+
* @throws IllegalArgumentException when {@code node} is {@literal null}.
122183
* @see RedisServerCommands#getClientList()
123184
*/
124185
Flux<RedisClientInfo> getClientList(RedisClusterNode node);

‎src/main/java/org/springframework/data/redis/connection/ReactiveRedisClusterConnection.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@
2424
*/
2525
public interface ReactiveRedisClusterConnection extends ReactiveRedisConnection {
2626

27-
/**
28-
* @param node must not be {@literal null}.
29-
* @return
30-
* @see RedisConnectionCommands#ping()
31-
*/
32-
Mono<String> ping(RedisClusterNode node);
33-
3427
@Override
3528
ReactiveClusterKeyCommands keyCommands();
3629

@@ -60,4 +53,14 @@ public interface ReactiveRedisClusterConnection extends ReactiveRedisConnection
6053

6154
@Override
6255
ReactiveClusterServerCommands serverCommands();
56+
57+
/**
58+
* Test the connection to a specific Redis cluster node.
59+
*
60+
* @param node must not be {@literal null}.
61+
* @return {@link Mono} wrapping server response message - usually {@literal PONG}.
62+
* @throws IllegalArgumentException when {@code node} is {@literal null}.
63+
* @see RedisConnectionCommands#ping()
64+
*/
65+
Mono<String> ping(RedisClusterNode node);
6366
}

‎src/main/java/org/springframework/data/redis/connection/ReactiveRedisConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public interface ReactiveRedisConnection extends Closeable {
9797
/**
9898
* Get {@link ReactiveHashCommands}.
9999
*
100-
* @return
100+
* @return never {@literal null}.
101101
*/
102102
ReactiveHashCommands hashCommands();
103103

@@ -125,7 +125,7 @@ public interface ReactiveRedisConnection extends Closeable {
125125
/**
126126
* Test connection.
127127
*
128-
* @return Server response message - usually {@literal PONG}.
128+
* @return {@link Mono} wrapping server response message - usually {@literal PONG}.
129129
* @see <a href="http://redis.io/commands/ping">Redis Documentation: PING</a>
130130
*/
131131
Mono<String> ping();

‎src/main/java/org/springframework/data/redis/connection/ReactiveServerCommands.java

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import reactor.core.publisher.Flux;
1919
import reactor.core.publisher.Mono;
2020

21-
import java.util.List;
2221
import java.util.Properties;
2322

2423
import org.springframework.data.redis.core.types.RedisClientInfo;
@@ -27,57 +26,64 @@
2726
* Redis Server commands executed using reactive infrastructure.
2827
*
2928
* @author Mark Paluch
29+
* @author Christoph Strobl
3030
* @since 2.0
3131
*/
3232
public interface ReactiveServerCommands {
3333

3434
/**
3535
* Start an {@literal Append Only File} rewrite process on server.
3636
*
37+
* @return {@link Mono} indicating command completion.
3738
* @see <a href="http://redis.io/commands/bgrewriteaof">Redis Documentation: BGREWRITEAOF</a>
3839
*/
3940
Mono<String> bgReWriteAof();
4041

4142
/**
4243
* Start background saving of db on server.
4344
*
45+
* @return {@link Mono} indicating command received by server. Operation success needs to be checked via
46+
* {@link #lastSave()}.
4447
* @see <a href="http://redis.io/commands/bgsave">Redis Documentation: BGSAVE</a>
4548
*/
4649
Mono<String> bgSave();
4750

4851
/**
49-
* Get time of last {@link #bgSave()} operation in seconds.
52+
* Get time unix timestamp of last successful {@link #bgSave()} operation in seconds.
5053
*
51-
* @return
54+
* @return {@link Mono} wrapping unix timestamp.
5255
* @see <a href="http://redis.io/commands/lastsave">Redis Documentation: LASTSAVE</a>
5356
*/
5457
Mono<Long> lastSave();
5558

5659
/**
5760
* Synchronous save current db snapshot on server.
5861
*
62+
* @return {@link Mono} indicating command completion.
5963
* @see <a href="http://redis.io/commands/save">Redis Documentation: SAVE</a>
6064
*/
6165
Mono<String> save();
6266

6367
/**
6468
* Get the total number of available keys in currently selected database.
6569
*
66-
* @return
70+
* @return {@link Mono} wrapping number of keys.
6771
* @see <a href="http://redis.io/commands/dbsize">Redis Documentation: DBSIZE</a>
6872
*/
6973
Mono<Long> dbSize();
7074

7175
/**
7276
* Delete all keys of the currently selected database.
7377
*
78+
* @return {@link Mono} indicating command completion.
7479
* @see <a href="http://redis.io/commands/flushdb">Redis Documentation: FLUSHDB</a>
7580
*/
7681
Mono<String> flushDb();
7782

7883
/**
7984
* Delete all <b>all keys</b> from <b>all databases</b>.
8085
*
86+
* @return {@link Mono} indicating command completion.
8187
* @see <a href="http://redis.io/commands/flushall">Redis Documentation: FLUSHALL</a>
8288
*/
8389
Mono<String> flushAll();
@@ -91,34 +97,37 @@ public interface ReactiveServerCommands {
9197
* </ul>
9298
* <p>
9399
*
94-
* @return
100+
* @return {@link Mono} wrapping server information.
95101
* @see <a href="http://redis.io/commands/info">Redis Documentation: INFO</a>
96102
*/
97103
Mono<Properties> info();
98104

99105
/**
100106
* Load server information for given {@code selection}.
101107
*
102-
* @param section
103-
* @return
108+
* @param section must not be {@literal null} nor {@literal empty}.
109+
* @return {@link Mono} wrapping server information of given {@code section}.
110+
* @throws IllegalArgumentException when section is {@literal null} or {@literal empty}.
104111
* @see <a href="http://redis.io/commands/info">Redis Documentation: INFO</a>
105112
*/
106113
Mono<Properties> info(String section);
107114

108115
/**
109116
* Load configuration parameters for given {@code pattern} from server.
110117
*
111-
* @param pattern
112-
* @return
118+
* @param pattern must not be {@literal null}.
119+
* @return {@link Mono} wrapping configuration parameters matching given {@code pattern}.
120+
* @throws IllegalArgumentException when {@code pattern} is {@literal null} or {@literal empty}.
113121
* @see <a href="http://redis.io/commands/config-get">Redis Documentation: CONFIG GET</a>
114122
*/
115123
Mono<Properties> getConfig(String pattern);
116124

117125
/**
118126
* Set server configuration for {@code param} to {@code value}.
119127
*
120-
* @param param
121-
* @param value
128+
* @param param must not be {@literal null} nor {@literal empty}.
129+
* @param value must not be {@literal null} nor {@literal empty}.
130+
* @throws IllegalArgumentException when {@code pattern} / {@code value} is {@literal null} or {@literal empty}.
122131
* @see <a href="http://redis.io/commands/config-set">Redis Documentation: CONFIG SET</a>
123132
*/
124133
Mono<String> setConfig(String param, String value);
@@ -127,47 +136,51 @@ public interface ReactiveServerCommands {
127136
* Reset statistic counters on server. <br>
128137
* Counters can be retrieved using {@link #info()}.
129138
*
139+
* @return {@link Mono} indicating command completion.
130140
* @see <a href="http://redis.io/commands/config-resetstat">Redis Documentation: CONFIG RESETSTAT</a>
131141
*/
132142
Mono<String> resetConfigStats();
133143

134144
/**
135145
* Request server timestamp using {@code TIME} command.
136146
*
137-
* @return current server time in milliseconds.
147+
* @return {@link Mono} wrapping current server time in milliseconds.
138148
* @see <a href="http://redis.io/commands/time">Redis Documentation: TIME</a>
139149
*/
140150
Mono<Long> time();
141151

142152
/**
143153
* Closes a given client connection identified by {@literal host:port}.
144154
*
145-
* @param host of connection to close.
155+
* @param host of connection to close. Must not be {@literal null} nor {@literal empty}.
146156
* @param port of connection to close
157+
* @return {@link Mono} wrapping {@link String} representation of the command result.
158+
* @throws IllegalArgumentException if {@code host} is {@literal null} or {@literal empty}.
147159
* @see <a href="http://redis.io/commands/client-kill">Redis Documentation: CLIENT KILL</a>
148160
*/
149161
Mono<String> killClient(String host, int port);
150162

151163
/**
152164
* Assign given name to current connection.
153165
*
154-
* @param name
166+
* @param name must not be {@literal null} nor {@literal empty}.
167+
* @throws IllegalArgumentException when {@code name} is {@literal null} or {@literal empty}.
155168
* @see <a href="http://redis.io/commands/client-setname">Redis Documentation: CLIENT SETNAME</a>
156169
*/
157170
Mono<String> setClientName(String name);
158171

159172
/**
160173
* Returns the name of the current connection.
161174
*
175+
* @return {@link Mono} wrapping the connection name.
162176
* @see <a href="http://redis.io/commands/client-getname">Redis Documentation: CLIENT GETNAME</a>
163-
* @return
164177
*/
165178
Mono<String> getClientName();
166179

167180
/**
168181
* Request information and statistics about connected clients.
169182
*
170-
* @return {@link List} of {@link RedisClientInfo} objects.
183+
* @return {@link Flux} emitting {@link RedisClientInfo} objects.
171184
* @see <a href="http://redis.io/commands/client-list">Redis Documentation: CLIENT LIST</a>
172185
*/
173186
Flux<RedisClientInfo> getClientList();

‎src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveClusterServerCommands.java

Lines changed: 65 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@
4242
import org.springframework.data.redis.connection.RedisClusterNode;
4343
import org.springframework.data.redis.core.types.RedisClientInfo;
4444
import org.springframework.data.redis.util.ByteUtils;
45+
import org.springframework.util.Assert;
4546

4647
/**
48+
* {@link ReactiveClusterServerCommands} implementation for {@literal Lettuce}.
49+
*
4750
* @author Mark Paluch
51+
* @author Christoph Strobl
4852
* @since 2.0
4953
*/
5054
class LettuceReactiveClusterServerCommands extends LettuceReactiveServerCommands
@@ -57,6 +61,9 @@ class LettuceReactiveClusterServerCommands extends LettuceReactiveServerCommands
5761
* Create new {@link LettuceReactiveGeoCommands}.
5862
*
5963
* @param connection must not be {@literal null}.
64+
* @param topologyProvider must not be {@literal null}.
65+
* @throws IllegalArgumentException when {@code connection} is {@literal null}.
66+
* @throws IllegalArgumentException when {@code topologyProvider} is {@literal null}.
6067
*/
6168
public LettuceReactiveClusterServerCommands(LettuceReactiveRedisClusterConnection connection,
6269
ClusterTopologyProvider topologyProvider) {
@@ -67,71 +74,80 @@ public LettuceReactiveClusterServerCommands(LettuceReactiveRedisClusterConnectio
6774
this.topologyProvider = topologyProvider;
6875
}
6976

70-
/* (non-Javadoc)
77+
/*
78+
* (non-Javadoc)
7179
* @see org.springframework.data.redis.connection.ReactiveClusterServerCommands#bgReWriteAof(org.springframework.data.redis.connection.RedisClusterNode)
7280
*/
7381
@Override
7482
public Mono<String> bgReWriteAof(RedisClusterNode node) {
7583
return connection.execute(node, RedisServerReactiveCommands::bgrewriteaof).next();
7684
}
7785

78-
/* (non-Javadoc)
86+
/*
87+
* (non-Javadoc)
7988
* @see org.springframework.data.redis.connection.ReactiveClusterServerCommands#bgSave(org.springframework.data.redis.connection.RedisClusterNode)
8089
*/
8190
@Override
8291
public Mono<String> bgSave(RedisClusterNode node) {
8392
return connection.execute(node, RedisServerReactiveCommands::bgsave).next();
8493
}
8594

86-
/* (non-Javadoc)
95+
/*
96+
* (non-Javadoc)
8797
* @see org.springframework.data.redis.connection.ReactiveClusterServerCommands#lastSave(org.springframework.data.redis.connection.RedisClusterNode)
8898
*/
8999
@Override
90100
public Mono<Long> lastSave(RedisClusterNode node) {
91101
return connection.execute(node, RedisServerReactiveCommands::lastsave).map(Date::getTime).next();
92102
}
93103

94-
/* (non-Javadoc)
104+
/*
105+
* (non-Javadoc)
95106
* @see org.springframework.data.redis.connection.ReactiveClusterServerCommands#save(org.springframework.data.redis.connection.RedisClusterNode)
96107
*/
97108
@Override
98109
public Mono<String> save(RedisClusterNode node) {
99110
return connection.execute(node, RedisServerReactiveCommands::save).next();
100111
}
101112

102-
/* (non-Javadoc)
113+
/*
114+
* (non-Javadoc)
103115
* @see org.springframework.data.redis.connection.ReactiveClusterServerCommands#dbSize(org.springframework.data.redis.connection.RedisClusterNode)
104116
*/
105117
@Override
106118
public Mono<Long> dbSize(RedisClusterNode node) {
107119
return connection.execute(node, RedisServerReactiveCommands::dbsize).next();
108120
}
109121

110-
/* (non-Javadoc)
122+
/*
123+
* (non-Javadoc)
111124
* @see org.springframework.data.redis.connection.ReactiveClusterServerCommands#flushDb(org.springframework.data.redis.connection.RedisClusterNode)
112125
*/
113126
@Override
114127
public Mono<String> flushDb(RedisClusterNode node) {
115128
return connection.execute(node, RedisServerReactiveCommands::flushdb).next();
116129
}
117130

118-
/* (non-Javadoc)
131+
/*
132+
* (non-Javadoc)
119133
* @see org.springframework.data.redis.connection.ReactiveClusterServerCommands#flushAll(org.springframework.data.redis.connection.RedisClusterNode)
120134
*/
121135
@Override
122136
public Mono<String> flushAll(RedisClusterNode node) {
123137
return connection.execute(node, RedisServerReactiveCommands::flushall).next();
124138
}
125139

126-
/* (non-Javadoc)
140+
/*
141+
* (non-Javadoc)
127142
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveServerCommands#info()
128143
*/
129144
@Override
130145
public Mono<Properties> info() {
131146
return Flux.merge(executeOnAllNodes(this::info)).collect(PropertiesCollector.INSTANCE);
132147
}
133148

134-
/* (non-Javadoc)
149+
/*
150+
* (non-Javadoc)
135151
* @see org.springframework.data.redis.connection.ReactiveClusterServerCommands#info(org.springframework.data.redis.connection.RedisClusterNode)
136152
*/
137153
@Override
@@ -148,74 +164,94 @@ public Mono<Properties> info(RedisClusterNode node) {
148164
@Override
149165
public Mono<Properties> info(String section) {
150166

167+
Assert.hasText(section, "Section must not be null nor empty!");
168+
151169
return Flux.merge(executeOnAllNodes(redisClusterNode -> info(redisClusterNode, section)))
152170
.collect(PropertiesCollector.INSTANCE);
153171
}
154172

155-
/* (non-Javadoc)
173+
/*
174+
* (non-Javadoc)
156175
* @see org.springframework.data.redis.connection.ReactiveClusterServerCommands#info(org.springframework.data.redis.connection.RedisClusterNode, java.lang.String)
157176
*/
158177
@Override
159178
public Mono<Properties> info(RedisClusterNode node, String section) {
160179

180+
Assert.hasText(section, "Section must not be null nor empty!");
181+
161182
return connection.execute(node, c -> c.info(section)) //
162183
.map(LettuceConverters::toProperties).next();
163184
}
164185

165-
/* (non-Javadoc)
186+
/*
187+
* (non-Javadoc)
166188
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveServerCommands#getConfig(java.lang.String)
167189
*/
168190
@Override
169191
public Mono<Properties> getConfig(String pattern) {
170192

193+
Assert.hasText(pattern, "Pattern must not be null nor empty!");
194+
171195
return Flux.merge(executeOnAllNodes(node -> getConfig(node, pattern))) //
172196
.collect(PropertiesCollector.INSTANCE);
173197
}
174198

175-
/* (non-Javadoc)
199+
/*
200+
* (non-Javadoc)
176201
* @see org.springframework.data.redis.connection.ReactiveClusterServerCommands#getConfig(org.springframework.data.redis.connection.RedisClusterNode, java.lang.String)
177202
*/
178203
@Override
179204
public Mono<Properties> getConfig(RedisClusterNode node, String pattern) {
180205

206+
Assert.hasText(pattern, "Pattern must not be null nor empty!");
207+
181208
return connection.execute(node, c -> c.configGet(pattern).collectList()) //
182209
.map(LettuceConverters::toProperties) //
183210
.next();
184211
}
185212

186-
/* (non-Javadoc)
213+
/*
214+
* (non-Javadoc)
187215
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveServerCommands#setConfig(java.lang.String, java.lang.String)
188216
*/
189217
@Override
190218
public Mono<String> setConfig(String param, String value) {
191219
return Flux.merge(executeOnAllNodes(node -> setConfig(node, param, value))).map(Tuple2::getT2).last();
192220
}
193221

194-
/* (non-Javadoc)
222+
/*
223+
* (non-Javadoc)
195224
* @see org.springframework.data.redis.connection.ReactiveClusterServerCommands#setConfig(org.springframework.data.redis.connection.RedisClusterNode, java.lang.String, java.lang.String)
196225
*/
197226
@Override
198227
public Mono<String> setConfig(RedisClusterNode node, String param, String value) {
228+
229+
Assert.hasText(param, "Param must not be null nor empty!");
230+
Assert.hasText(value, "Value must not be null nor empty!");
231+
199232
return connection.execute(node, c -> c.configSet(param, value)).next();
200233
}
201234

202-
/* (non-Javadoc)
235+
/*
236+
* (non-Javadoc)
203237
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveServerCommands#resetConfigStats()
204238
*/
205239
@Override
206240
public Mono<String> resetConfigStats() {
207241
return Flux.merge(executeOnAllNodes(this::resetConfigStats)).map(Tuple2::getT2).last();
208242
}
209243

210-
/* (non-Javadoc)
244+
/*
245+
* (non-Javadoc)
211246
* @see org.springframework.data.redis.connection.ReactiveClusterServerCommands#resetConfigStats(org.springframework.data.redis.connection.RedisClusterNode)
212247
*/
213248
@Override
214249
public Mono<String> resetConfigStats(RedisClusterNode node) {
215250
return connection.execute(node, RedisServerReactiveCommands::configResetstat).next();
216251
}
217252

218-
/* (non-Javadoc)
253+
/*
254+
* (non-Javadoc)
219255
* @see org.springframework.data.redis.connection.ReactiveClusterServerCommands#time(org.springframework.data.redis.connection.RedisClusterNode)
220256
*/
221257
@Override
@@ -227,15 +263,17 @@ public Mono<Long> time(RedisClusterNode node) {
227263
.map(LettuceConverters.toTimeConverter()::convert);
228264
}
229265

230-
/* (non-Javadoc)
266+
/*
267+
* (non-Javadoc)
231268
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveServerCommands#getClientList()
232269
*/
233270
@Override
234271
public Flux<RedisClientInfo> getClientList() {
235272
return Flux.merge(executeOnAllNodesMany(this::getClientList)).map(Tuple2::getT2);
236273
}
237274

238-
/* (non-Javadoc)
275+
/*
276+
* (non-Javadoc)
239277
* @see org.springframework.data.redis.connection.ReactiveClusterServerCommands#getClientList(org.springframework.data.redis.connection.RedisClusterNode)
240278
*/
241279
@Override
@@ -279,7 +317,8 @@ private enum PropertiesCollector implements Collector<Tuple2<RedisClusterNode, P
279317

280318
INSTANCE;
281319

282-
/* (non-Javadoc)
320+
/*
321+
* (non-Javadoc)
283322
* @see java.util.stream.Collector#supplier()
284323
*/
285324
@Override
@@ -301,7 +340,8 @@ public BiConsumer<Properties, Tuple2<RedisClusterNode, Properties>> accumulator(
301340
};
302341
}
303342

304-
/* (non-Javadoc)
343+
/*
344+
* (non-Javadoc)
305345
* @see java.util.stream.Collector#combiner()
306346
*/
307347
@Override
@@ -318,15 +358,17 @@ public BinaryOperator<Properties> combiner() {
318358
};
319359
}
320360

321-
/* (non-Javadoc)
361+
/*
362+
* (non-Javadoc)
322363
* @see java.util.stream.Collector#finisher()
323364
*/
324365
@Override
325366
public Function<Properties, Properties> finisher() {
326367
return properties -> properties;
327368
}
328369

329-
/* (non-Javadoc)
370+
/*
371+
* (non-Javadoc)
330372
* @see java.util.stream.Collector#characteristics()
331373
*/
332374
@Override

‎src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveRedisClusterConnection.java

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import org.springframework.util.StringUtils;
3434

3535
/**
36+
* {@link ReactiveRedisClusterConnection} implementation for {@literal Lettuce}.
37+
*
3638
* @author Christoph Strobl
3739
* @author Mark Paluch
3840
* @since 2.0
@@ -42,94 +44,113 @@ class LettuceReactiveRedisClusterConnection extends LettuceReactiveRedisConnecti
4244

4345
private final ClusterTopologyProvider topologyProvider;
4446

45-
public LettuceReactiveRedisClusterConnection(RedisClusterClient client) {
47+
/**
48+
* Creates new {@link LettuceReactiveRedisClusterConnection}.
49+
*
50+
* @param client must not be {@literal null}.
51+
* @throws IllegalArgumentException when {@code client} is {@literal null}.
52+
* @throws org.springframework.dao.InvalidDataAccessResourceUsageException when {@code client} is not suitable for
53+
* cluster environment.
54+
*/
55+
LettuceReactiveRedisClusterConnection(RedisClusterClient client) {
4656

4757
super(client);
4858

4959
this.topologyProvider = new LettuceClusterTopologyProvider(client);
5060
}
5161

52-
/* (non-Javadoc)
62+
/*
63+
* (non-Javadoc)
5364
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection#keyCommands()
5465
*/
5566
@Override
5667
public LettuceReactiveClusterKeyCommands keyCommands() {
5768
return new LettuceReactiveClusterKeyCommands(this);
5869
}
5970

60-
/* (non-Javadoc)
71+
/*
72+
* (non-Javadoc)
6173
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection#listCommands()
6274
*/
6375
@Override
6476
public LettuceReactiveClusterListCommands listCommands() {
6577
return new LettuceReactiveClusterListCommands(this);
6678
}
6779

68-
/* (non-Javadoc)
80+
/*
81+
* (non-Javadoc)
6982
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection#setCommands()
7083
*/
7184
@Override
7285
public LettuceReactiveClusterSetCommands setCommands() {
7386
return new LettuceReactiveClusterSetCommands(this);
7487
}
7588

76-
/* (non-Javadoc)
89+
/*
90+
* (non-Javadoc)
7791
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection#zSetCommands()
7892
*/
7993
@Override
8094
public LettuceReactiveClusterZSetCommands zSetCommands() {
8195
return new LettuceReactiveClusterZSetCommands(this);
8296
}
8397

84-
/* (non-Javadoc)
98+
/*
99+
* (non-Javadoc)
85100
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection#hyperLogLogCommands()
86101
*/
87102
@Override
88103
public LettuceReactiveClusterHyperLogLogCommands hyperLogLogCommands() {
89104
return new LettuceReactiveClusterHyperLogLogCommands(this);
90105
}
91106

92-
/* (non-Javadoc)
107+
/*
108+
* (non-Javadoc)
93109
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection#stringCommands()
94110
*/
95111
@Override
96112
public LettuceReactiveClusterStringCommands stringCommands() {
97113
return new LettuceReactiveClusterStringCommands(this);
98114
}
99115

100-
/* (non-Javadoc)
116+
/*
117+
* (non-Javadoc)
101118
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection#geoCommands()
102119
*/
103120
@Override
104121
public LettuceReactiveClusterGeoCommands geoCommands() {
105122
return new LettuceReactiveClusterGeoCommands(this);
106123
}
107124

108-
/* (non-Javadoc)
125+
/*
126+
* (non-Javadoc)
109127
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection#hashCommands()
110128
*/
111129
@Override
112130
public LettuceReactiveClusterHashCommands hashCommands() {
113131
return new LettuceReactiveClusterHashCommands(this);
114132
}
115133

116-
/* (non-Javadoc)
134+
/*
135+
* (non-Javadoc)
117136
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection#numberCommands()
118137
*/
119138
@Override
120139
public LettuceReactiveClusterNumberCommands numberCommands() {
121140
return new LettuceReactiveClusterNumberCommands(this);
122141
}
123142

124-
/* (non-Javadoc)
143+
/*
144+
* (non-Javadoc)
125145
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection#serverCommands()
126146
*/
127147
@Override
128148
public LettuceReactiveClusterServerCommands serverCommands() {
129149
return new LettuceReactiveClusterServerCommands(this, topologyProvider);
130150
}
131151

132-
/* (non-Javadoc)
152+
/*
153+
* (non-Javadoc)
133154
* @see org.springframework.data.redis.connection.ReactiveRedisClusterConnection#ping(org.springframework.data.redis.connection.RedisClusterNode)
134155
*/
135156
@Override
@@ -138,8 +159,10 @@ public Mono<String> ping(RedisClusterNode node) {
138159
}
139160

140161
/**
141-
* @param callback
142-
* @return
162+
* @param node must not be {@literal null}.
163+
* @param callback must not be {@literal null}.
164+
* @throws IllegalArgumentException when {@code node} or {@code callback} is {@literal null}.
165+
* @return {@link Flux} emitting execution results.
143166
*/
144167
public <T> Flux<T> execute(RedisNode node, LettuceReactiveCallback<T> callback) {
145168

@@ -153,7 +176,8 @@ public <T> Flux<T> execute(RedisNode node, LettuceReactiveCallback<T> callback)
153176
return Flux.defer(() -> callback.doWithCommands(getCommands(node))).onErrorMap(translateException());
154177
}
155178

156-
/* (non-Javadoc)
179+
/*
180+
* (non-Javadoc)
157181
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection#getConnection()
158182
*/
159183
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -166,7 +190,8 @@ protected StatefulRedisClusterConnection<ByteBuffer, ByteBuffer> getConnection()
166190
return (StatefulRedisClusterConnection) super.getConnection();
167191
}
168192

169-
/* (non-Javadoc)
193+
/*
194+
* (non-Javadoc)
170195
* @see org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection#getCommands()
171196
*/
172197
protected RedisClusterReactiveCommands<ByteBuffer, ByteBuffer> getCommands() {

‎src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveRedisConnection.java

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,17 @@
3333
import org.reactivestreams.Publisher;
3434
import org.springframework.dao.DataAccessException;
3535
import org.springframework.dao.InvalidDataAccessResourceUsageException;
36-
import org.springframework.data.redis.connection.*;
36+
import org.springframework.data.redis.connection.ReactiveGeoCommands;
37+
import org.springframework.data.redis.connection.ReactiveHashCommands;
38+
import org.springframework.data.redis.connection.ReactiveHyperLogLogCommands;
39+
import org.springframework.data.redis.connection.ReactiveKeyCommands;
40+
import org.springframework.data.redis.connection.ReactiveListCommands;
41+
import org.springframework.data.redis.connection.ReactiveNumberCommands;
42+
import org.springframework.data.redis.connection.ReactiveRedisConnection;
43+
import org.springframework.data.redis.connection.ReactiveServerCommands;
44+
import org.springframework.data.redis.connection.ReactiveSetCommands;
45+
import org.springframework.data.redis.connection.ReactiveStringCommands;
46+
import org.springframework.data.redis.connection.ReactiveZSetCommands;
3747
import org.springframework.util.Assert;
3848

3949
/**
@@ -43,11 +53,18 @@
4353
*/
4454
class LettuceReactiveRedisConnection implements ReactiveRedisConnection {
4555

46-
private StatefulConnection<ByteBuffer, ByteBuffer> connection;
47-
4856
private static final RedisCodec<ByteBuffer, ByteBuffer> CODEC = ByteBufferCodec.INSTANCE;
4957

50-
public LettuceReactiveRedisConnection(AbstractRedisClient client) {
58+
private StatefulConnection<ByteBuffer, ByteBuffer> connection;
59+
60+
/**
61+
* Creates new {@link LettuceReactiveRedisConnection}.
62+
*
63+
* @param client must not be {@literal null}.
64+
* @throws IllegalArgumentException when {@code client} is {@literal null}.
65+
* @throws InvalidDataAccessResourceUsageException when {@code client} is not suitable for connection.
66+
*/
67+
LettuceReactiveRedisConnection(AbstractRedisClient client) {
5168

5269
Assert.notNull(client, "RedisClient must not be null!");
5370

@@ -70,79 +87,89 @@ public ReactiveKeyCommands keyCommands() {
7087
return new LettuceReactiveKeyCommands(this);
7188
}
7289

73-
/* (non-Javadoc)
90+
/*
91+
* (non-Javadoc)
7492
* @see org.springframework.data.redis.connection.ReactiveRedisConnection#stringCommands()
7593
*/
7694
@Override
7795
public ReactiveStringCommands stringCommands() {
7896
return new LettuceReactiveStringCommands(this);
7997
}
8098

81-
/* (non-Javadoc)
99+
/*
100+
* (non-Javadoc)
82101
* @see org.springframework.data.redis.connection.ReactiveRedisConnection#numberCommands()
83102
*/
84103
@Override
85104
public ReactiveNumberCommands numberCommands() {
86105
return new LettuceReactiveNumberCommands(this);
87106
}
88107

89-
/* (non-Javadoc)
108+
/*
109+
* (non-Javadoc)
90110
* @see org.springframework.data.redis.connection.ReactiveRedisConnection#listCommands()
91111
*/
92112
@Override
93113
public ReactiveListCommands listCommands() {
94114
return new LettuceReactiveListCommands(this);
95115
}
96116

97-
/* (non-Javadoc)
117+
/*
118+
* (non-Javadoc)
98119
* @see org.springframework.data.redis.connection.ReactiveRedisConnection#setCommands()
99120
*/
100121
@Override
101122
public ReactiveSetCommands setCommands() {
102123
return new LettuceReactiveSetCommands(this);
103124
}
104125

105-
/* (non-Javadoc)
126+
/*
127+
* (non-Javadoc)
106128
* @see org.springframework.data.redis.connection.ReactiveRedisConnection#zSetCommands()
107129
*/
108130
@Override
109131
public ReactiveZSetCommands zSetCommands() {
110132
return new LettuceReactiveZSetCommands(this);
111133
}
112134

113-
/* (non-Javadoc)
135+
/*
136+
* (non-Javadoc)
114137
* @see org.springframework.data.redis.connection.ReactiveRedisConnection#hashCommands()
115138
*/
116139
@Override
117140
public ReactiveHashCommands hashCommands() {
118141
return new LettuceReactiveHashCommands(this);
119142
}
120143

121-
/* (non-Javadoc)
144+
/*
145+
* (non-Javadoc)
122146
* @see org.springframework.data.redis.connection.ReactiveRedisConnection#geoCommands()
123147
*/
124148
@Override
125149
public ReactiveGeoCommands geoCommands() {
126150
return new LettuceReactiveGeoCommands(this);
127151
}
128152

129-
/* (non-Javadoc)
153+
/*
154+
* (non-Javadoc)
130155
* @see org.springframework.data.redis.connection.ReactiveRedisConnection#hyperLogLogCommands()
131156
*/
132157
@Override
133158
public ReactiveHyperLogLogCommands hyperLogLogCommands() {
134159
return new LettuceReactiveHyperLogLogCommands(this);
135160
}
136161

137-
/* (non-Javadoc)
162+
/*
163+
* (non-Javadoc)
138164
* @see org.springframework.data.redis.connection.ReactiveRedisConnection#hyperLogLogCommands()
139165
*/
140166
@Override
141167
public ReactiveServerCommands serverCommands() {
142168
return new LettuceReactiveServerCommands(this);
143169
}
144170

145-
/* (non-Javadoc)
171+
/*
172+
* (non-Javadoc)
146173
* @see org.springframework.data.redis.connection.ReactiveRedisConnection#ping()
147174
*/
148175
@Override
@@ -200,7 +227,7 @@ interface LettuceReactiveCallback<T> {
200227
Publisher<T> doWithCommands(RedisClusterReactiveCommands<ByteBuffer, ByteBuffer> cmd);
201228
}
202229

203-
static enum ByteBufferCodec implements RedisCodec<ByteBuffer, ByteBuffer> {
230+
enum ByteBufferCodec implements RedisCodec<ByteBuffer, ByteBuffer> {
204231

205232
INSTANCE;
206233

‎src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveServerCommands.java

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
import org.springframework.util.Assert;
3030

3131
/**
32+
* {@link ReactiveServerCommands} implementation for {@literal Lettuce}.
33+
*
3234
* @author Mark Paluch
35+
* @author Christoph Strobl
3336
*/
3437
class LettuceReactiveServerCommands implements ReactiveServerCommands {
3538

@@ -39,70 +42,80 @@ class LettuceReactiveServerCommands implements ReactiveServerCommands {
3942
* Create new {@link LettuceReactiveGeoCommands}.
4043
*
4144
* @param connection must not be {@literal null}.
45+
* @throws IllegalArgumentException when {@code connection} is {@literal null}.
4246
*/
43-
public LettuceReactiveServerCommands(LettuceReactiveRedisConnection connection) {
47+
LettuceReactiveServerCommands(LettuceReactiveRedisConnection connection) {
4448

4549
Assert.notNull(connection, "Connection must not be null!");
50+
4651
this.connection = connection;
4752
}
4853

49-
/* (non-Javadoc)
54+
/*
55+
* (non-Javadoc)
5056
* @see org.springframework.data.redis.connection.ReactiveServerCommands#bgReWriteAof()
5157
*/
5258
@Override
5359
public Mono<String> bgReWriteAof() {
5460
return connection.execute(RedisServerReactiveCommands::bgrewriteaof).next();
5561
}
5662

57-
/* (non-Javadoc)
63+
/*
64+
* (non-Javadoc)
5865
* @see org.springframework.data.redis.connection.ReactiveServerCommands#bgSave()
5966
*/
6067
@Override
6168
public Mono<String> bgSave() {
6269
return connection.execute(RedisServerReactiveCommands::bgsave).next();
6370
}
6471

65-
/* (non-Javadoc)
72+
/*
73+
* (non-Javadoc)
6674
* @see org.springframework.data.redis.connection.ReactiveServerCommands#lastSave()
6775
*/
6876
@Override
6977
public Mono<Long> lastSave() {
7078
return connection.execute(RedisServerReactiveCommands::lastsave).next().map(Date::getTime);
7179
}
7280

73-
/* (non-Javadoc)
81+
/*
82+
* (non-Javadoc)
7483
* @see org.springframework.data.redis.connection.ReactiveServerCommands#save()
7584
*/
7685
@Override
7786
public Mono<String> save() {
7887
return connection.execute(RedisServerReactiveCommands::save).next();
7988
}
8089

81-
/* (non-Javadoc)
90+
/*
91+
* (non-Javadoc)
8292
* @see org.springframework.data.redis.connection.ReactiveServerCommands#dbSize()
8393
*/
8494
@Override
8595
public Mono<Long> dbSize() {
8696
return connection.execute(RedisServerReactiveCommands::dbsize).next();
8797
}
8898

89-
/* (non-Javadoc)
99+
/*
100+
* (non-Javadoc)
90101
* @see org.springframework.data.redis.connection.ReactiveServerCommands#flushDb()
91102
*/
92103
@Override
93104
public Mono<String> flushDb() {
94105
return connection.execute(RedisServerReactiveCommands::flushdb).next();
95106
}
96107

97-
/* (non-Javadoc)
108+
/*
109+
* (non-Javadoc)
98110
* @see org.springframework.data.redis.connection.ReactiveServerCommands#flushAll()
99111
*/
100112
@Override
101113
public Mono<String> flushAll() {
102114
return connection.execute(RedisServerReactiveCommands::flushall).next();
103115
}
104116

105-
/* (non-Javadoc)
117+
/*
118+
* (non-Javadoc)
106119
* @see org.springframework.data.redis.connection.ReactiveServerCommands#info()
107120
*/
108121
@Override
@@ -113,44 +126,57 @@ public Mono<Properties> info() {
113126
.next();
114127
}
115128

116-
/* (non-Javadoc)
129+
/*
130+
* (non-Javadoc)
117131
* @see org.springframework.data.redis.connection.ReactiveServerCommands#info(java.lang.String)
118132
*/
119133
@Override
120134
public Mono<Properties> info(String section) {
121135

136+
Assert.hasText(section, "Section must not be null nor empty!");
137+
122138
return connection.execute(c -> c.info(section)) //
123139
.map(LettuceConverters::toProperties) //
124140
.next();
125141
}
126142

127-
/* (non-Javadoc)
143+
/*
144+
* (non-Javadoc)
128145
* @see org.springframework.data.redis.connection.ReactiveServerCommands#getConfig(java.lang.String)
129146
*/
130147
@Override
131148
public Mono<Properties> getConfig(String pattern) {
132149

150+
Assert.hasText(pattern, "Pattern must not be null nor empty!");
151+
133152
return connection.execute(c -> c.configGet(pattern).collectList()) //
134153
.map(LettuceConverters::toProperties).next();
135154
}
136155

137-
/* (non-Javadoc)
156+
/*
157+
* (non-Javadoc)
138158
* @see org.springframework.data.redis.connection.ReactiveServerCommands#setConfig(java.lang.String, java.lang.String)
139159
*/
140160
@Override
141161
public Mono<String> setConfig(String param, String value) {
162+
163+
Assert.hasText(param, "Param must not be null nor empty!");
164+
Assert.hasText(value, "Value must not be null nor empty!");
165+
142166
return connection.execute(c -> c.configSet(param, value)).next();
143167
}
144168

145-
/* (non-Javadoc)
169+
/*
170+
* (non-Javadoc)
146171
* @see org.springframework.data.redis.connection.ReactiveServerCommands#resetConfigStats()
147172
*/
148173
@Override
149174
public Mono<String> resetConfigStats() {
150175
return connection.execute(RedisServerReactiveCommands::configResetstat).next();
151176
}
152177

153-
/* (non-Javadoc)
178+
/*
179+
* (non-Javadoc)
154180
* @see org.springframework.data.redis.connection.ReactiveServerCommands#time()
155181
*/
156182
@Override
@@ -162,27 +188,32 @@ public Mono<Long> time() {
162188
.map(LettuceConverters.toTimeConverter()::convert);
163189
}
164190

165-
/* (non-Javadoc)
191+
/*
192+
* (non-Javadoc)
166193
* @see org.springframework.data.redis.connection.ReactiveServerCommands#killClient(java.lang.String, int)
167194
*/
168195
@Override
169196
public Mono<String> killClient(String host, int port) {
170197

171-
Assert.notNull(host, "Host must not be null");
198+
Assert.notNull(host, "Host must not be null nor empty!");
172199

173-
String client = String.format("%s:%s", host, port);
174-
return connection.execute(c -> c.clientKill(client)).next();
200+
return connection.execute(c -> c.clientKill(String.format("%s:%s", host, port))).next();
175201
}
176202

177-
/* (non-Javadoc)
203+
/*
204+
* (non-Javadoc)
178205
* @see org.springframework.data.redis.connection.ReactiveServerCommands#setClientName(java.lang.String)
179206
*/
180207
@Override
181208
public Mono<String> setClientName(String name) {
209+
210+
Assert.hasText(name, "Name must not be null nor empty!");
211+
182212
return connection.execute(c -> c.clientSetname(ByteBuffer.wrap(LettuceConverters.toBytes(name)))).next();
183213
}
184214

185-
/* (non-Javadoc)
215+
/*
216+
* (non-Javadoc)
186217
* @see org.springframework.data.redis.connection.ReactiveServerCommands#getClientName()
187218
*/
188219
@Override
@@ -194,7 +225,8 @@ public Mono<String> getClientName() {
194225
.next();
195226
}
196227

197-
/* (non-Javadoc)
228+
/*
229+
* (non-Javadoc)
198230
* @see org.springframework.data.redis.connection.ReactiveServerCommands#getClientList()
199231
*/
200232
@Override

‎src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveClusterServerCommandsTests.java

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
/**
2828
* @author Mark Paluch
29+
* @author Christoph Strobl
2930
*/
3031
public class LettuceReactiveClusterServerCommandsTests extends LettuceReactiveClusterCommandsTestsBase {
3132

@@ -132,25 +133,38 @@ public void getConfigShouldRespondCorrectly() {
132133
@Test // DATAREDIS-659
133134
public void setConfigShouldApplyConfiguration() throws InterruptedException {
134135

135-
StepVerifier.create(connection.serverCommands().setConfig("maxclients", "10000")) //
136-
.expectNext("OK") //
137-
.verifyComplete();
138-
139-
StepVerifier.create(connection.serverCommands().setConfig(NODE1, "maxclients", "9999")) //
140-
.expectNext("OK") //
141-
.verifyComplete();
142-
143-
StepVerifier.create(connection.serverCommands().getConfig(NODE1, "maxclients")) //
144-
.consumeNextWith(properties -> {
145-
assertThat(properties).containsEntry("maxclients", "9999");
146-
}) //
147-
.verifyComplete();
148-
149-
StepVerifier.create(connection.serverCommands().getConfig(NODE2, "maxclients")) //
150-
.consumeNextWith(properties -> {
151-
assertThat(properties).containsEntry("maxclients", "10000");
152-
}) //
153-
.verifyComplete();
136+
final String slowLogKey = "slowlog-max-len";
137+
138+
String resetValue = connection.serverCommands().getConfig(slowLogKey).map(it -> {
139+
if (it.containsKey(slowLogKey)) {
140+
return it.get(slowLogKey);
141+
}
142+
return it.get("127.0.0.1:7379." + slowLogKey);
143+
}).block().toString();
144+
145+
try {
146+
StepVerifier.create(connection.serverCommands().setConfig(slowLogKey, resetValue)) //
147+
.expectNext("OK") //
148+
.verifyComplete();
149+
150+
StepVerifier.create(connection.serverCommands().setConfig(NODE1, slowLogKey, "127")) //
151+
.expectNext("OK") //
152+
.verifyComplete();
153+
154+
StepVerifier.create(connection.serverCommands().getConfig(NODE1, slowLogKey)) //
155+
.consumeNextWith(properties -> {
156+
assertThat(properties).containsEntry(slowLogKey, "127");
157+
}) //
158+
.verifyComplete();
159+
160+
StepVerifier.create(connection.serverCommands().getConfig(NODE2, slowLogKey)) //
161+
.consumeNextWith(properties -> {
162+
assertThat(properties).containsEntry(slowLogKey, resetValue);
163+
}) //
164+
.verifyComplete();
165+
} finally {
166+
connection.serverCommands().setConfig(slowLogKey, resetValue).block();
167+
}
154168
}
155169

156170
@Test // DATAREDIS-659

‎src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveServerCommandsTests.java

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
/**
2626
* @author Mark Paluch
27+
* @author Christoph Strobl
2728
*/
2829
public class LettuceReactiveServerCommandsTests extends LettuceReactiveCommandsTestsBase {
2930

@@ -156,22 +157,35 @@ public void getConfigShouldRespondCorrectly() {
156157
@Test // DATAREDIS-659
157158
public void setConfigShouldApplyConfiguration() {
158159

159-
StepVerifier.create(connection.serverCommands().setConfig("maxclients", "9999")) //
160-
.expectNext("OK") //
161-
.verifyComplete();
160+
final String slowLogKey = "slowlog-max-len";
162161

163-
if (connection instanceof LettuceReactiveRedisClusterConnection) {
164-
StepVerifier.create(connection.serverCommands().getConfig("maxclients")) //
165-
.consumeNextWith(properties -> {
166-
assertThat(properties).containsEntry("127.0.0.1:7379.maxclients", "9999");
167-
}) //
168-
.verifyComplete();
169-
} else {
170-
StepVerifier.create(connection.serverCommands().getConfig("maxclients")) //
171-
.consumeNextWith(properties -> {
172-
assertThat(properties).containsEntry("maxclients", "9999");
173-
}) //
162+
String resetValue = connection.serverCommands().getConfig(slowLogKey).map(it -> {
163+
if (it.containsKey(slowLogKey)) {
164+
return it.get(slowLogKey);
165+
}
166+
return it.get("127.0.0.1:7379." + slowLogKey);
167+
}).block().toString();
168+
169+
try {
170+
StepVerifier.create(connection.serverCommands().setConfig(slowLogKey, "127")) //
171+
.expectNext("OK") //
174172
.verifyComplete();
173+
174+
if (connection instanceof LettuceReactiveRedisClusterConnection) {
175+
StepVerifier.create(connection.serverCommands().getConfig(slowLogKey)) //
176+
.consumeNextWith(properties -> {
177+
assertThat(properties).containsEntry("127.0.0.1:7379." + slowLogKey, "127");
178+
}) //
179+
.verifyComplete();
180+
} else {
181+
StepVerifier.create(connection.serverCommands().getConfig(slowLogKey)) //
182+
.consumeNextWith(properties -> {
183+
assertThat(properties).containsEntry(slowLogKey, "127");
184+
}) //
185+
.verifyComplete();
186+
}
187+
} finally {
188+
connection.serverCommands().setConfig(slowLogKey, resetValue).block();
175189
}
176190
}
177191

0 commit comments

Comments
 (0)
Please sign in to comment.