Add support for CONFIG REWRITE.

Signed-off-by: Manousos Mathioudakis <manoumathioudakis@yahoo.gr>

Closes #1992
Original pull request: #2012.
This commit is contained in:
Manousos Mathioudakis
2021-03-22 16:29:48 +02:00
committed by Mark Paluch
parent 3a1fbe1cf7
commit 2d56eaf3c6
10 changed files with 48 additions and 1 deletions

View File

@@ -3731,6 +3731,11 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco
delegate.migrate(key, target, dbIndex, option, timeout);
}
@Override
public void rewriteConfig() {
delegate.rewriteConfig();
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.StringRedisConnection#xAck(java.lang.String, java.lang.String, RecordId[])

View File

@@ -280,4 +280,9 @@ public interface RedisServerCommands {
* @see <a href="https://redis.io/commands/migrate">Redis Documentation: MIGRATE</a>
*/
void migrate(byte[] key, RedisNode target, int dbIndex, @Nullable MigrateOption option, long timeout);
/**
* Rewrites the redis.conf file.
*/
void rewriteConfig();
}

View File

@@ -869,6 +869,11 @@ public class JedisClusterConnection implements DefaultedRedisClusterConnection {
throw new UnsupportedOperationException("Sentinel is currently not supported for JedisClusterConnection.");
}
@Override
public void rewriteConfig() {
serverCommands().rewriteConfig();
}
/**
* {@link Jedis} specific {@link ClusterCommandCallback}.
*

View File

@@ -520,6 +520,12 @@ class JedisClusterServerCommands implements RedisClusterServerCommands {
node);
}
@Override
public void rewriteConfig() {
connection.getClusterCommandExecutor()
.executeCommandOnAllNodes((JedisClusterCommandCallback<String>) client -> client.configRewrite());
}
private Long convertListOfStringToTime(List<String> serverTimeInformation, TimeUnit timeUnit) {
Assert.notEmpty(serverTimeInformation, "Received invalid result from server. Expected 2 items in collection.");

View File

@@ -806,4 +806,8 @@ public class JedisConnection extends AbstractRedisConnection {
}
}
@Override
public void rewriteConfig() {
serverCommands().rewriteConfig();
}
}

View File

@@ -317,6 +317,11 @@ class JedisServerCommands implements RedisServerCommands {
target.getPort(), key, dbIndex, timeoutToUse);
}
@Override
public void rewriteConfig() {
connection.invokeStatus().just(Jedis::configRewrite);
}
private boolean isPipelined() {
return connection.isPipelined();
}

View File

@@ -137,6 +137,11 @@ public class LettuceConnection extends AbstractRedisConnection {
return LettuceResultBuilder.<T, R> forResponse(resultHolder).buildStatusResult();
}
@Override
public void rewriteConfig() {
serverCommands().rewriteConfig();
}
private class LettuceTransactionResultConverter<T> extends TransactionResultConverter<T> {
public LettuceTransactionResultConverter(Queue<FutureResult<T>> txResults,
Converter<Exception, DataAccessException> exceptionConverter) {

View File

@@ -304,6 +304,11 @@ class LettuceServerCommands implements RedisServerCommands {
connection.invoke().just(RedisKeyAsyncCommands::migrate, target.getHost(), target.getPort(), key, dbIndex, timeout);
}
@Override
public void rewriteConfig() {
connection.invoke().just(RedisServerAsyncCommands::configRewrite);
}
public RedisClusterCommands<byte[], byte[]> getConnection() {
return connection.getConnection();
}