Skip to content

Add support for CONFIG REWRITE #2012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>2.5.0-SNAPSHOT</version>
<version>2.5.0-1992-SNAPSHOT</version>

<name>Spring Data Redis</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3731,6 +3731,11 @@ public void migrate(byte[] key, RedisNode target, int dbIndex, @Nullable Migrate
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[])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,9 @@ default Long time() {
* @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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,11 @@ public RedisSentinelConnection getSentinelConnection() {
throw new UnsupportedOperationException("Sentinel is currently not supported for JedisClusterConnection.");
}

@Override
public void rewriteConfig() {
serverCommands().rewriteConfig();
}

/**
* {@link Jedis} specific {@link ClusterCommandCallback}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,12 @@ public void migrate(byte[] key, RedisNode target, int dbIndex, @Nullable Migrate
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.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,4 +806,8 @@ private void doWithJedis(Consumer<Jedis> callback) {
}
}

@Override
public void rewriteConfig() {
serverCommands().rewriteConfig();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ public void migrate(byte[] key, RedisNode target, int dbIndex, @Nullable Migrate
target.getPort(), key, dbIndex, timeoutToUse);
}

@Override
public void rewriteConfig() {
connection.invokeStatus().just(Jedis::configRewrite);
}

private boolean isPipelined() {
return connection.isPipelined();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ <T, R> LettuceResult<T, R> newLettuceStatusResult(Future<T> resultHolder) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ public void migrate(byte[] key, RedisNode target, int dbIndex, @Nullable Migrate
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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,11 @@ public void migrate(byte[] key, RedisNode target, int dbIndex, MigrateOption opt
delegate.migrate(key, target, dbIndex, option, timeout);
}

@Override
public void rewriteConfig() {
delegate.rewriteConfig();
}

@Override
public Boolean set(byte[] key, byte[] value, Expiration expiration, SetOption options) {
return delegate.set(key, value, expiration, options);
Expand Down