DATAREDIS-665 - Upgrade to Lettuce 5.0 RC1.
Adapt to changes in Lettuce API.
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -21,7 +21,7 @@
|
||||
<beanutils>1.9.2</beanutils>
|
||||
<xstream>1.4.8</xstream>
|
||||
<pool>2.2</pool>
|
||||
<lettuce>5.0.0.M2</lettuce>
|
||||
<lettuce>5.0.0.RC1</lettuce>
|
||||
<jedis>2.9.0</jedis>
|
||||
<multithreadedtc>1.01</multithreadedtc>
|
||||
</properties>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -34,7 +34,6 @@ import io.lettuce.core.resource.ClientResources;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -93,8 +92,7 @@ public class LettuceConnectionFactoryUnitTests {
|
||||
Iterable<RedisURI> initialUris = (Iterable<RedisURI>) getField(client, "initialUris");
|
||||
|
||||
for (RedisURI uri : initialUris) {
|
||||
assertThat(uri.getTimeout(), is(equalTo(connectionFactory.getTimeout())));
|
||||
assertThat(uri.getUnit(), is(equalTo(TimeUnit.MILLISECONDS)));
|
||||
assertThat(uri.getTimeout(), is(equalTo(Duration.ofMillis(connectionFactory.getTimeout()))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user