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>
|
<beanutils>1.9.2</beanutils>
|
||||||
<xstream>1.4.8</xstream>
|
<xstream>1.4.8</xstream>
|
||||||
<pool>2.2</pool>
|
<pool>2.2</pool>
|
||||||
<lettuce>5.0.0.M2</lettuce>
|
<lettuce>5.0.0.RC1</lettuce>
|
||||||
<jedis>2.9.0</jedis>
|
<jedis>2.9.0</jedis>
|
||||||
<multithreadedtc>1.01</multithreadedtc>
|
<multithreadedtc>1.01</multithreadedtc>
|
||||||
</properties>
|
</properties>
|
||||||
|
|||||||
@@ -408,6 +408,16 @@ abstract public class Converters {
|
|||||||
return STRING_LIST_TO_PROPERTIES_CONVERTER;
|
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
|
* @author Christoph Strobl
|
||||||
* @since 1.8
|
* @since 1.8
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import io.lettuce.core.api.sync.RedisServerCommands;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@@ -228,20 +229,18 @@ class LettuceClusterServerCommands extends LettuceServerCommands implements Redi
|
|||||||
@Override
|
@Override
|
||||||
public Properties getConfig(final String pattern) {
|
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();
|
.getResults();
|
||||||
|
|
||||||
List<String> result = new ArrayList<>();
|
Properties properties = new Properties();
|
||||||
for (NodeResult<List<String>> entry : mapResult) {
|
|
||||||
|
for (NodeResult<Map<String, String>> entry : mapResult) {
|
||||||
|
|
||||||
String prefix = entry.getNode().asString();
|
String prefix = entry.getNode().asString();
|
||||||
int i = 0;
|
entry.getValue().forEach((key, value) -> properties.setProperty(prefix + "." + key, value));
|
||||||
for (String value : entry.getValue()) {
|
|
||||||
result.add((i++ % 2 == 0 ? (prefix + ".") : "") + value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Converters.toProperties(result);
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -767,8 +767,7 @@ public class LettuceConnectionFactory
|
|||||||
.map(clientResources -> RedisClusterClient.create(clientResources, initialUris)) //
|
.map(clientResources -> RedisClusterClient.create(clientResources, initialUris)) //
|
||||||
.orElseGet(() -> RedisClusterClient.create(initialUris));
|
.orElseGet(() -> RedisClusterClient.create(initialUris));
|
||||||
|
|
||||||
this.clusterCommandExecutor = new ClusterCommandExecutor(
|
this.clusterCommandExecutor = new ClusterCommandExecutor(new LettuceClusterTopologyProvider(clusterClient),
|
||||||
new LettuceClusterTopologyProvider(clusterClient),
|
|
||||||
new LettuceClusterConnection.LettuceClusterNodeResourceProvider(clusterClient), EXCEPTION_TRANSLATION);
|
new LettuceClusterConnection.LettuceClusterNodeResourceProvider(clusterClient), EXCEPTION_TRANSLATION);
|
||||||
|
|
||||||
clientConfiguration.getClientOptions() //
|
clientConfiguration.getClientOptions() //
|
||||||
@@ -795,6 +794,7 @@ public class LettuceConnectionFactory
|
|||||||
RedisURI redisUri = LettuceConverters.sentinelConfigurationToRedisURI(sentinelConfiguration);
|
RedisURI redisUri = LettuceConverters.sentinelConfigurationToRedisURI(sentinelConfiguration);
|
||||||
|
|
||||||
getRedisPassword().toOptional().ifPresent(redisUri::setPassword);
|
getRedisPassword().toOptional().ifPresent(redisUri::setPassword);
|
||||||
|
redisUri.setTimeout(clientConfiguration.getCommandTimeout());
|
||||||
|
|
||||||
return redisUri;
|
return redisUri;
|
||||||
}
|
}
|
||||||
@@ -808,7 +808,7 @@ public class LettuceConnectionFactory
|
|||||||
builder.withSsl(clientConfiguration.isUseSsl());
|
builder.withSsl(clientConfiguration.isUseSsl());
|
||||||
builder.withVerifyPeer(clientConfiguration.isVerifyPeer());
|
builder.withVerifyPeer(clientConfiguration.isVerifyPeer());
|
||||||
builder.withStartTls(clientConfiguration.isStartTls());
|
builder.withStartTls(clientConfiguration.isStartTls());
|
||||||
builder.withTimeout(clientConfiguration.getCommandTimeout().toMillis(), TimeUnit.MILLISECONDS);
|
builder.withTimeout(clientConfiguration.getCommandTimeout());
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ class LettuceReactiveClusterServerCommands extends LettuceReactiveServerCommands
|
|||||||
|
|
||||||
Assert.hasText(pattern, "Pattern must not be null nor empty!");
|
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) //
|
.map(LettuceConverters::toProperties) //
|
||||||
.next();
|
.next();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class LettuceReactiveServerCommands implements ReactiveServerCommands {
|
|||||||
|
|
||||||
Assert.hasText(pattern, "Pattern must not be null nor empty!");
|
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();
|
.map(LettuceConverters::toProperties).next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -281,12 +281,12 @@ class LettuceServerCommands implements RedisServerCommands {
|
|||||||
try {
|
try {
|
||||||
if (isPipelined()) {
|
if (isPipelined()) {
|
||||||
pipeline(
|
pipeline(
|
||||||
connection.newLettuceResult(getAsyncConnection().configGet(param), Converters.listToPropertiesConverter()));
|
connection.newLettuceResult(getAsyncConnection().configGet(param), Converters.mapToPropertiesConverter()));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (isQueueing()) {
|
if (isQueueing()) {
|
||||||
transaction(
|
transaction(
|
||||||
connection.newLettuceTxResult(getConnection().configGet(param), Converters.listToPropertiesConverter()));
|
connection.newLettuceTxResult(getConnection().configGet(param), Converters.mapToPropertiesConverter()));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return Converters.toProperties(getConnection().configGet(param));
|
return Converters.toProperties(getConnection().configGet(param));
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import io.lettuce.core.resource.ClientResources;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -93,8 +92,7 @@ public class LettuceConnectionFactoryUnitTests {
|
|||||||
Iterable<RedisURI> initialUris = (Iterable<RedisURI>) getField(client, "initialUris");
|
Iterable<RedisURI> initialUris = (Iterable<RedisURI>) getField(client, "initialUris");
|
||||||
|
|
||||||
for (RedisURI uri : initialUris) {
|
for (RedisURI uri : initialUris) {
|
||||||
assertThat(uri.getTimeout(), is(equalTo(connectionFactory.getTimeout())));
|
assertThat(uri.getTimeout(), is(equalTo(Duration.ofMillis(connectionFactory.getTimeout()))));
|
||||||
assertThat(uri.getUnit(), is(equalTo(TimeUnit.MILLISECONDS)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user