Polishing.
Reorder methods. Move rewriteConfig directly implemented on connection to DefaultedRedisConnection respective DefaultedRedisClusterConnection. Add overload to run config rewrite on individual cluster nodes. Add tests. Add since tags and update Javadoc. See #1992 Original pull request: #2012.
This commit is contained in:
@@ -878,6 +878,15 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco
|
||||
delegate.resetConfigStats();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisServerCommands#rewriteConfig()
|
||||
*/
|
||||
@Override
|
||||
public void rewriteConfig() {
|
||||
delegate.rewriteConfig();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisListCommands#rPop(byte[])
|
||||
@@ -3731,11 +3740,6 @@ 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[])
|
||||
|
||||
@@ -122,6 +122,13 @@ public interface DefaultedRedisClusterConnection extends RedisClusterConnection,
|
||||
serverCommands().resetConfigStats(node);
|
||||
}
|
||||
|
||||
/** @deprecated in favor of {@link RedisConnection#serverCommands()}. */
|
||||
@Override
|
||||
@Deprecated
|
||||
default void rewriteConfig(RedisClusterNode node) {
|
||||
serverCommands().rewriteConfig(node);
|
||||
}
|
||||
|
||||
/** @deprecated in favor of {@link RedisConnection#serverCommands()}. */
|
||||
@Override
|
||||
@Deprecated
|
||||
|
||||
@@ -1430,6 +1430,13 @@ public interface DefaultedRedisConnection extends RedisConnection {
|
||||
serverCommands().resetConfigStats();
|
||||
}
|
||||
|
||||
/** @deprecated in favor of {@link RedisConnection#serverCommands()}. */
|
||||
@Override
|
||||
@Deprecated
|
||||
default void rewriteConfig() {
|
||||
serverCommands().rewriteConfig();
|
||||
}
|
||||
|
||||
/** @deprecated in favor of {@link RedisConnection#serverCommands()}. */
|
||||
@Override
|
||||
@Deprecated
|
||||
|
||||
@@ -114,6 +114,13 @@ public interface RedisClusterServerCommands extends RedisServerCommands {
|
||||
*/
|
||||
void resetConfigStats(RedisClusterNode node);
|
||||
|
||||
/**
|
||||
* @param node must not be {@literal null}.
|
||||
* @see RedisServerCommands#rewriteConfig()
|
||||
* @since 2.5
|
||||
*/
|
||||
void rewriteConfig(RedisClusterNode node);
|
||||
|
||||
/**
|
||||
* @param node must not be {@literal null}.
|
||||
* @return
|
||||
|
||||
@@ -174,6 +174,14 @@ public interface RedisServerCommands {
|
||||
*/
|
||||
void resetConfigStats();
|
||||
|
||||
/**
|
||||
* Rewrites the {@code redis.conf} file.
|
||||
*
|
||||
* @since 2.5
|
||||
* @see <a href="https://redis.io/commands/config-rewrite">Redis Documentation: CONFIG REWRITE</a>
|
||||
*/
|
||||
void rewriteConfig();
|
||||
|
||||
/**
|
||||
* Request server timestamp using {@code TIME} command in {@link TimeUnit#MILLISECONDS}.
|
||||
*
|
||||
@@ -281,8 +289,4 @@ public interface RedisServerCommands {
|
||||
*/
|
||||
void migrate(byte[] key, RedisNode target, int dbIndex, @Nullable MigrateOption option, long timeout);
|
||||
|
||||
/**
|
||||
* Rewrites the redis.conf file.
|
||||
*/
|
||||
void rewriteConfig();
|
||||
}
|
||||
|
||||
@@ -381,6 +381,16 @@ class JedisClusterServerCommands implements RedisClusterServerCommands {
|
||||
.executeCommandOnAllNodes((JedisClusterCommandCallback<String>) BinaryJedis::configResetStat);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisServerCommands#rewriteConfig()
|
||||
*/
|
||||
@Override
|
||||
public void rewriteConfig() {
|
||||
connection.getClusterCommandExecutor()
|
||||
.executeCommandOnAllNodes((JedisClusterCommandCallback<String>) BinaryJedis::configRewrite);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisClusterServerCommands#resetConfigStats(org.springframework.data.redis.connection.RedisClusterNode)
|
||||
@@ -390,6 +400,15 @@ class JedisClusterServerCommands implements RedisClusterServerCommands {
|
||||
executeCommandOnSingleNode(BinaryJedis::configResetStat, node);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisClusterServerCommands#rewriteConfig(org.springframework.data.redis.connection.RedisClusterNode)
|
||||
*/
|
||||
@Override
|
||||
public void rewriteConfig(RedisClusterNode node) {
|
||||
executeCommandOnSingleNode(BinaryJedis::configRewrite, node);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisServerCommands#time(TimeUnit)
|
||||
@@ -520,12 +539,6 @@ 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.");
|
||||
|
||||
@@ -806,8 +806,4 @@ public class JedisConnection extends AbstractRedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rewriteConfig() {
|
||||
serverCommands().rewriteConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +189,15 @@ class JedisServerCommands implements RedisServerCommands {
|
||||
connection.invokeStatus().just(BinaryJedis::configResetStat, MultiKeyPipelineBase::configResetStat);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisServerCommands#resetConfigStats()
|
||||
*/
|
||||
@Override
|
||||
public void rewriteConfig() {
|
||||
connection.invokeStatus().just(Jedis::configRewrite);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisServerCommands#time(TimeUnit)
|
||||
@@ -317,11 +326,6 @@ class JedisServerCommands implements RedisServerCommands {
|
||||
target.getPort(), key, dbIndex, timeoutToUse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rewriteConfig() {
|
||||
connection.invokeStatus().just(Jedis::configRewrite);
|
||||
}
|
||||
|
||||
private boolean isPipelined() {
|
||||
return connection.isPipelined();
|
||||
}
|
||||
|
||||
@@ -307,6 +307,24 @@ class LettuceClusterServerCommands extends LettuceServerCommands implements Redi
|
||||
executeCommandOnSingleNode(RedisServerCommands::configResetstat, node);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceServerCommands#rewriteConfig()
|
||||
*/
|
||||
@Override
|
||||
public void rewriteConfig() {
|
||||
executeCommandOnAllNodes(RedisServerCommands::configRewrite);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisClusterServerCommands#rewriteConfig(org.springframework.data.redis.connection.RedisClusterNode)
|
||||
*/
|
||||
@Override
|
||||
public void rewriteConfig(RedisClusterNode node) {
|
||||
executeCommandOnSingleNode(RedisServerCommands::configRewrite, node);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisClusterServerCommands#time(org.springframework.data.redis.connection.RedisClusterNode)
|
||||
|
||||
@@ -137,11 +137,6 @@ 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) {
|
||||
|
||||
@@ -199,6 +199,15 @@ class LettuceServerCommands implements RedisServerCommands {
|
||||
connection.invokeStatus().just(RedisServerAsyncCommands::configResetstat);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisServerCommands#resetConfigStats()
|
||||
*/
|
||||
@Override
|
||||
public void rewriteConfig() {
|
||||
connection.invokeStatus().just(RedisServerAsyncCommands::configRewrite);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisServerCommands#time(TimeUnit)
|
||||
@@ -304,11 +313,6 @@ 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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user