DATAREDIS-348 - Polishing.
Fixed connection problems leaving sockets open. Added missing JUnit rules for Sentinels. Added missing author information update, license header and Javadoc. Upgraded test script to use Redis 3.0.2. Upgrade test script to shut down Redis in case of test errors. Added Redis 3.0 to TestProfileValueSource. Enabled ZRANGEBYLEX tests for lettuce. Original pull request: #144. Related pull request: #104.
This commit is contained in:
committed by
Oliver Gierke
parent
7426b27688
commit
444b290863
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.data.redis.connection.lettuce;
|
||||
import com.lambdaworks.redis.RedisAsyncConnection;
|
||||
import com.lambdaworks.redis.RedisClient;
|
||||
import com.lambdaworks.redis.RedisConnection;
|
||||
import com.lambdaworks.redis.RedisURI;
|
||||
import com.lambdaworks.redis.codec.RedisCodec;
|
||||
import com.lambdaworks.redis.pubsub.RedisPubSubConnection;
|
||||
|
||||
@@ -25,7 +26,9 @@ import com.lambdaworks.redis.pubsub.RedisPubSubConnection;
|
||||
* Extension of {@link RedisClient} that calls auth on all new connections using the supplied credentials
|
||||
*
|
||||
* @author Jennifer Hickey
|
||||
* @deprecated Use password in RedisURI
|
||||
* @author Mar Paluch
|
||||
* @author Christoph Strobl
|
||||
* @deprecated since 1.6 - Please use {@link RedisURI#setPassword(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public class AuthenticatingRedisClient extends RedisClient {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,6 @@ package org.springframework.data.redis.connection.lettuce;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.lambdaworks.redis.RedisURI;
|
||||
import org.apache.commons.pool2.BasePooledObjectFactory;
|
||||
import org.apache.commons.pool2.PooledObject;
|
||||
import org.apache.commons.pool2.impl.DefaultPooledObject;
|
||||
@@ -30,6 +29,7 @@ import org.springframework.util.Assert;
|
||||
|
||||
import com.lambdaworks.redis.RedisAsyncConnection;
|
||||
import com.lambdaworks.redis.RedisClient;
|
||||
import com.lambdaworks.redis.RedisURI;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link LettucePool}.
|
||||
@@ -72,6 +72,7 @@ public class DefaultLettucePool implements LettucePool, InitializingBean {
|
||||
* based on sentinels.
|
||||
*
|
||||
* @param sentinelConfiguration The Sentinel configuration
|
||||
* @since 1.6
|
||||
*/
|
||||
public DefaultLettucePool(RedisSentinelConfiguration sentinelConfiguration) {
|
||||
this.sentinelConfiguration = sentinelConfiguration;
|
||||
@@ -92,7 +93,7 @@ public class DefaultLettucePool implements LettucePool, InitializingBean {
|
||||
|
||||
/**
|
||||
* @return true when {@link RedisSentinelConfiguration} is present.
|
||||
* @since 1.5
|
||||
* @since 1.6
|
||||
*/
|
||||
public boolean isRedisSentinelAware() {
|
||||
return sentinelConfiguration != null;
|
||||
@@ -106,12 +107,11 @@ public class DefaultLettucePool implements LettucePool, InitializingBean {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return a RedisURI pointing either to a single Redis host or containing a set of sentinels.
|
||||
*/
|
||||
private RedisURI getRedisURI() {
|
||||
|
||||
if(isRedisSentinelAware()) {
|
||||
if (isRedisSentinelAware()) {
|
||||
return LettuceConverters.sentinelConfigurationToRedisURI(sentinelConfiguration);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class DefaultLettucePool implements LettucePool, InitializingBean {
|
||||
|
||||
private RedisURI createSimpleHostRedisURI() {
|
||||
RedisURI.Builder builder = RedisURI.Builder.redis(hostName, port);
|
||||
if(password != null) {
|
||||
if (password != null) {
|
||||
builder.withPassword(password);
|
||||
}
|
||||
builder.withTimeout(timeout, TimeUnit.MILLISECONDS);
|
||||
@@ -162,7 +162,6 @@ public class DefaultLettucePool implements LettucePool, InitializingBean {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The Redis client
|
||||
*/
|
||||
public RedisClient getClient() {
|
||||
|
||||
@@ -3568,6 +3568,10 @@ public class LettuceConnection extends AbstractRedisConnection {
|
||||
return RedisURI.Builder.redis(node.getHost(), node.getPort()).build();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.AbstractRedisConnection#getSentinelConnection(org.springframework.data.redis.connection.RedisNode)
|
||||
*/
|
||||
@Override
|
||||
protected RedisSentinelConnection getSentinelConnection(RedisNode sentinel) {
|
||||
RedisSentinelAsyncConnection<String, String> connection = client.connectSentinelAsync(getRedisURI(sentinel));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2014 the original author or authors.
|
||||
* Copyright 2011-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,9 +18,6 @@ package org.springframework.data.redis.connection.lettuce;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.lambdaworks.redis.LettuceFutures;
|
||||
import com.lambdaworks.redis.RedisFuture;
|
||||
import com.lambdaworks.redis.RedisURI;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
@@ -36,9 +33,12 @@ import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConnection;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.lambdaworks.redis.LettuceFutures;
|
||||
import com.lambdaworks.redis.RedisAsyncConnection;
|
||||
import com.lambdaworks.redis.RedisClient;
|
||||
import com.lambdaworks.redis.RedisException;
|
||||
import com.lambdaworks.redis.RedisFuture;
|
||||
import com.lambdaworks.redis.RedisURI;
|
||||
|
||||
/**
|
||||
* Connection factory creating <a href="http://github.com/mp911de/lettuce">Lettuce</a>-based connections.
|
||||
@@ -55,6 +55,7 @@ import com.lambdaworks.redis.RedisException;
|
||||
* @author Costin Leau
|
||||
* @author Jennifer Hickey
|
||||
* @author Thomas Darimont
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class LettuceConnectionFactory implements InitializingBean, DisposableBean, RedisConnectionFactory {
|
||||
|
||||
@@ -98,7 +99,7 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea
|
||||
* Constructs a new {@link LettuceConnectionFactory} instance using the given {@link RedisSentinelConfiguration}
|
||||
*
|
||||
* @param sentinelConfiguration
|
||||
* @since 1.5
|
||||
* @since 1.6
|
||||
*/
|
||||
public LettuceConnectionFactory(RedisSentinelConfiguration sentinelConfiguration) {
|
||||
this.sentinelConfiguration = sentinelConfiguration;
|
||||
@@ -156,11 +157,11 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea
|
||||
try {
|
||||
RedisFuture<String> ping = connection.ping();
|
||||
LettuceFutures.awaitAll(timeout, TimeUnit.MILLISECONDS, ping);
|
||||
if(PING_REPLY.equalsIgnoreCase(ping.get())) {
|
||||
if (PING_REPLY.equalsIgnoreCase(ping.get())) {
|
||||
valid = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.debug("Validation failed", e);
|
||||
log.debug("Validation failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +314,9 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea
|
||||
|
||||
/**
|
||||
* Returns the shutdown timeout for shutting down the RedisClient (in milliseconds).
|
||||
*
|
||||
* @return shutdown timeout
|
||||
* @since 1.6
|
||||
*/
|
||||
public long getShutdownTimeout() {
|
||||
return shutdownTimeout;
|
||||
@@ -321,7 +324,9 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea
|
||||
|
||||
/**
|
||||
* Sets the shutdown timeout for shutting down the RedisClient (in milliseconds).
|
||||
*
|
||||
* @param shutdownTimeout the shutdown timeout
|
||||
* @since 1.6
|
||||
*/
|
||||
public void setShutdownTimeout(long shutdownTimeout) {
|
||||
this.shutdownTimeout = shutdownTimeout;
|
||||
@@ -379,7 +384,7 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea
|
||||
|
||||
private RedisClient createRedisClient() {
|
||||
|
||||
if(isRedisSentinelAware()) {
|
||||
if (isRedisSentinelAware()) {
|
||||
RedisURI redisURI = getSentinelRedisURI();
|
||||
return new RedisClient(redisURI);
|
||||
}
|
||||
@@ -389,7 +394,7 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea
|
||||
}
|
||||
|
||||
RedisURI.Builder builder = RedisURI.Builder.redis(hostName, port);
|
||||
if(password != null) {
|
||||
if (password != null) {
|
||||
builder.withPassword(password);
|
||||
}
|
||||
builder.withTimeout(timeout, TimeUnit.MILLISECONDS);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
Reference in New Issue
Block a user