DATAREDIS-665 - Upgrade to Lettuce 5.0 RC1.

Adapt to changes in Lettuce API.
This commit is contained in:
Mark Paluch
2017-07-20 15:51:04 +02:00
parent 54ba6e3494
commit b0d139af2e
8 changed files with 26 additions and 19 deletions

View File

@@ -408,6 +408,16 @@ abstract public class Converters {
return STRING_LIST_TO_PROPERTIES_CONVERTER;
}
/**
* Returns a converter to convert from {@link Map} to {@link Properties}.
*
* @return the converter.
* @since 2.0
*/
public static Converter<Map<?, ?>, Properties> mapToPropertiesConverter() {
return MAP_TO_PROPERTIES;
}
/**
* @author Christoph Strobl
* @since 1.8

View File

@@ -20,6 +20,7 @@ import io.lettuce.core.api.sync.RedisServerCommands;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
@@ -228,20 +229,18 @@ class LettuceClusterServerCommands extends LettuceServerCommands implements Redi
@Override
public Properties getConfig(final String pattern) {
List<NodeResult<List<String>>> mapResult = executeCommandOnAllNodes(client -> client.configGet(pattern))
List<NodeResult<Map<String, String>>> mapResult = executeCommandOnAllNodes(client -> client.configGet(pattern))
.getResults();
List<String> result = new ArrayList<>();
for (NodeResult<List<String>> entry : mapResult) {
Properties properties = new Properties();
for (NodeResult<Map<String, String>> entry : mapResult) {
String prefix = entry.getNode().asString();
int i = 0;
for (String value : entry.getValue()) {
result.add((i++ % 2 == 0 ? (prefix + ".") : "") + value);
}
entry.getValue().forEach((key, value) -> properties.setProperty(prefix + "." + key, value));
}
return Converters.toProperties(result);
return properties;
}
/*

View File

@@ -767,8 +767,7 @@ public class LettuceConnectionFactory
.map(clientResources -> RedisClusterClient.create(clientResources, initialUris)) //
.orElseGet(() -> RedisClusterClient.create(initialUris));
this.clusterCommandExecutor = new ClusterCommandExecutor(
new LettuceClusterTopologyProvider(clusterClient),
this.clusterCommandExecutor = new ClusterCommandExecutor(new LettuceClusterTopologyProvider(clusterClient),
new LettuceClusterConnection.LettuceClusterNodeResourceProvider(clusterClient), EXCEPTION_TRANSLATION);
clientConfiguration.getClientOptions() //
@@ -795,6 +794,7 @@ public class LettuceConnectionFactory
RedisURI redisUri = LettuceConverters.sentinelConfigurationToRedisURI(sentinelConfiguration);
getRedisPassword().toOptional().ifPresent(redisUri::setPassword);
redisUri.setTimeout(clientConfiguration.getCommandTimeout());
return redisUri;
}
@@ -808,7 +808,7 @@ public class LettuceConnectionFactory
builder.withSsl(clientConfiguration.isUseSsl());
builder.withVerifyPeer(clientConfiguration.isVerifyPeer());
builder.withStartTls(clientConfiguration.isStartTls());
builder.withTimeout(clientConfiguration.getCommandTimeout().toMillis(), TimeUnit.MILLISECONDS);
builder.withTimeout(clientConfiguration.getCommandTimeout());
return builder.build();
}

View File

@@ -205,7 +205,7 @@ class LettuceReactiveClusterServerCommands extends LettuceReactiveServerCommands
Assert.hasText(pattern, "Pattern must not be null nor empty!");
return connection.execute(node, c -> c.configGet(pattern).collectList()) //
return connection.execute(node, c -> c.configGet(pattern)) //
.map(LettuceConverters::toProperties) //
.next();
}

View File

@@ -149,7 +149,7 @@ class LettuceReactiveServerCommands implements ReactiveServerCommands {
Assert.hasText(pattern, "Pattern must not be null nor empty!");
return connection.execute(c -> c.configGet(pattern).collectList()) //
return connection.execute(c -> c.configGet(pattern)) //
.map(LettuceConverters::toProperties).next();
}

View File

@@ -281,12 +281,12 @@ class LettuceServerCommands implements RedisServerCommands {
try {
if (isPipelined()) {
pipeline(
connection.newLettuceResult(getAsyncConnection().configGet(param), Converters.listToPropertiesConverter()));
connection.newLettuceResult(getAsyncConnection().configGet(param), Converters.mapToPropertiesConverter()));
return null;
}
if (isQueueing()) {
transaction(
connection.newLettuceTxResult(getConnection().configGet(param), Converters.listToPropertiesConverter()));
connection.newLettuceTxResult(getConnection().configGet(param), Converters.mapToPropertiesConverter()));
return null;
}
return Converters.toProperties(getConnection().configGet(param));