diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/DefaultLettucePool.java b/src/main/java/org/springframework/data/redis/connection/lettuce/DefaultLettucePool.java new file mode 100644 index 000000000..40852605a --- /dev/null +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/DefaultLettucePool.java @@ -0,0 +1,224 @@ +/* + * Copyright 2013 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.data.redis.connection.lettuce; + +import java.util.concurrent.TimeUnit; + +import org.apache.commons.pool.BasePoolableObjectFactory; +import org.apache.commons.pool.impl.GenericObjectPool; +import org.apache.commons.pool.impl.GenericObjectPool.Config; +import org.springframework.data.redis.connection.PoolException; + +import com.lambdaworks.redis.RedisAsyncConnection; +import com.lambdaworks.redis.RedisClient; + +/** + * Default implementation of {@link LettucePool} + * + * @author Jennifer Hickey + * + */ +public class DefaultLettucePool implements LettucePool { + private final GenericObjectPool internalPool; + private static final int DEFAULT_TIMEOUT = (int) TimeUnit.MILLISECONDS.convert(60, TimeUnit.SECONDS); + private RedisClient client; + + /** + * Uses the {@link Config} and {@link RedisClient} defaults for configuring + * the connection pool + * + * @param hostName + * The Redis host + * @param port + * The Redis port + */ + public DefaultLettucePool(String hostName, int port) { + this(hostName, port, 0, DEFAULT_TIMEOUT, new Config()); + } + + /** + * Uses the {@link RedisClient} defaults for configuring the connection pool + * + * @param hostName + * The Redis host + * @param port + * The Redis port + * @param poolConfig + * The pool {@link Config} + */ + public DefaultLettucePool(String hostName, int port, Config poolConfig) { + this(hostName, port, 0, DEFAULT_TIMEOUT, poolConfig); + } + + /** + * + * Uses the {@link Config} defaults for configuring the connection pool + * + * @param client + * The {@link RedisClient} for connecting to Redis + * + */ + public DefaultLettucePool(RedisClient client) { + this.client = client; + this.internalPool = new GenericObjectPool(new LettuceFactory(client, 0), new Config()); + } + + /** + * + * @param client + * The {@link RedisClient} for connecting to Redis + * + * @param poolConfig + * The pool {@link Config} + * @param dbIndex + * The index of the database all connections should use. The + * database will be selected when connections are activated. + */ + public DefaultLettucePool(RedisClient client, Config poolConfig, int dbIndex) { + this.client = client; + this.internalPool = new GenericObjectPool(new LettuceFactory(client, dbIndex), poolConfig); + } + + /** + * Uses the {@link Config} defaults for configuring the connection pool + * + * @param hostName + * The Redis host + * @param port + * The Redis port + * @param dbIndex + * The index of the database all connections should use. The + * database will be selected when connections are activated. + * @param password + * The password used for authenticating with the Redis server or + * null if no password required + * @param timeout + * The socket timeout or 0 to use the default socket timeout + */ + public DefaultLettucePool(String hostName, int port, int dbIndex, int timeout) { + this(hostName, port, dbIndex, timeout, new Config()); + } + + /** + * + * @param hostName + * The Redis host + * @param port + * The Redis port + * @param dbIndex + * The index of the database all connections should use. The + * database will be selected when connections are activated. + * @param password + * The password used for authenticating with the Redis server or + * null if no password required + * @param timeout + * The socket timeout or 0 to use the default socket timeout + * @param poolConfig + * The pool {@link COnfig} + */ + public DefaultLettucePool(String hostName, int port, int dbIndex, int timeout, Config poolConfig) { + this.client = new RedisClient(hostName, port); + client.setDefaultTimeout(timeout, TimeUnit.MILLISECONDS); + this.internalPool = new GenericObjectPool(new LettuceFactory(client, dbIndex), poolConfig); + } + + public RedisClient getClient() { + return client; + } + + @SuppressWarnings("unchecked") + public RedisAsyncConnection getResource() { + try { + return (RedisAsyncConnection) internalPool.borrowObject(); + } catch (Exception e) { + throw new PoolException("Could not get a resource from the pool", e); + } + } + + public void returnBrokenResource(final RedisAsyncConnection resource) { + try { + internalPool.invalidateObject(resource); + } catch (Exception e) { + throw new PoolException("Could not invalidate the broken resource", e); + } + } + + public void returnResource(final RedisAsyncConnection resource) { + try { + internalPool.returnObject(resource); + } catch (Exception e) { + throw new PoolException("Could not return the resource to the pool", e); + } + } + + public void destroy() { + try { + internalPool.close(); + } catch (Exception e) { + throw new PoolException("Could not destroy the pool", e); + } + } + + private static class LettuceFactory extends BasePoolableObjectFactory { + + private final RedisClient client; + + private int dbIndex; + + public LettuceFactory(RedisClient client, int dbIndex) { + super(); + this.client = client; + this.dbIndex = dbIndex; + } + + public Object makeObject() throws Exception { + return client.connectAsync(LettuceUtils.CODEC); + } + + @SuppressWarnings("rawtypes") + @Override + public void activateObject(Object obj) throws Exception { + if (obj instanceof RedisAsyncConnection) { + ((RedisAsyncConnection) obj).select(dbIndex); + } + } + + @SuppressWarnings("rawtypes") + public void destroyObject(final Object obj) throws Exception { + if (obj instanceof RedisAsyncConnection) { + try { + ((RedisAsyncConnection) obj).close(); + } catch (Exception e) { + // Errors may happen if returning a broken resource + } + } + } + + @SuppressWarnings("rawtypes") + public boolean validateObject(final Object obj) { + if (obj instanceof RedisAsyncConnection) { + try { + ((RedisAsyncConnection) obj).ping(); + return true; + } catch (Exception e) { + return false; + } + } else { + return false; + } + } + } +} diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java index 0a47192aa..3de5ec8ea 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java @@ -36,7 +36,6 @@ import org.springframework.data.redis.RedisConnectionFailureException; import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.connection.DataType; import org.springframework.data.redis.connection.MessageListener; -import org.springframework.data.redis.connection.Pool; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisPipelineException; import org.springframework.data.redis.connection.RedisSubscribedConnectionException; @@ -82,26 +81,57 @@ public class LettuceConnection implements RedisConnection { private List> ppline; private RedisClient client; private volatile LettuceSubscription subscription; - private Pool> pool; + private LettucePool pool; /** flag indicating whether the connection needs to be dropped or not */ private boolean broken = false; + /** + * Instantiates a new lettuce connection. + * + * @param dedicatedConnection + * A dedicated native connection. Can be used for any operation. + * @param timeout + * The connection timeout (in milliseconds) + * @param client + * The {@link RedisClient} to use when making pub/sub connections + */ public LettuceConnection(com.lambdaworks.redis.RedisAsyncConnection dedicatedConnection, long timeout, RedisClient client) { this(null, dedicatedConnection, timeout, client, null); } + /** + * Instantiates a new lettuce connection. + * + * @param dedicatedConnection + * A dedicated native connection. Can be used for any operation. + * @param timeout + * The connection timeout (in milliseconds) + * @param client + * The {@link RedisClient} to use when making pub/sub connections + * @param pool + * An optional connection pool, from which the dedicated + * connection came. If pool is set, the dedicated connection will + * be returned to the pool on close + */ public LettuceConnection(com.lambdaworks.redis.RedisAsyncConnection dedicatedConnection, long timeout, - RedisClient client, Pool> pool) { + RedisClient client, LettucePool pool) { this(null, dedicatedConnection, timeout, client, pool); } /** * Instantiates a new lettuce connection. * - * @param connection underlying Lettuce async connection - * @param timeout the connection timeout (in milliseconds) - * @param client The Lettuce client + * @param sharedConnection + * A native connection that is shared with other + * {@link LettuceConnection}s. Should not be used for + * transactions or blocking operations + * @param dedicatedConnection + * A dedicated native connection. Can be used for any operation. + * @param timeout + * The connection timeout (in milliseconds) + * @param client + * The {@link RedisClient} to use when making pub/sub connections */ public LettuceConnection(com.lambdaworks.redis.RedisAsyncConnection sharedConnection, com.lambdaworks.redis.RedisAsyncConnection dedicatedConnection, long timeout, @@ -112,15 +142,24 @@ public class LettuceConnection implements RedisConnection { /** * Instantiates a new lettuce connection. * - * @param connection The underlying Lettuce async connection - * @param timeout The connection timeout (in milliseconds) - * @param client The Lettuce client - * @param closeNativeConnection True if native connection should be called on {@link #close()}. This should - * be set to false if the native connection is shared. + * @param sharedConnection + * A native connection that is shared with other + * {@link LettuceConnection}s. Should not be used for + * transactions or blocking operations + * @param dedicatedConnection + * A dedicated native connection. Can be used for any operation. + * @param timeout + * The connection timeout (in milliseconds) + * @param client + * The {@link RedisClient} to use when making pub/sub connections + * @param pool + * An optional connection pool, from which the dedicated + * connection came. If pool is set, the dedicated connection will + * be returned to the pool on close */ public LettuceConnection(com.lambdaworks.redis.RedisAsyncConnection sharedConnection, com.lambdaworks.redis.RedisAsyncConnection dedicatedConnection, long timeout, - RedisClient client, Pool> pool) { + RedisClient client, LettucePool pool) { Assert.notNull(dedicatedConnection, "a valid dedicated connection is required"); this.asyncSharedConn = sharedConnection; this.asyncDedicatedConn = dedicatedConnection; diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactory.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactory.java index e3b1b8b91..70f3a850e 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactory.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactory.java @@ -66,7 +66,7 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea private boolean validateConnection = false; private boolean shareNativeConnection = true; private RedisAsyncConnection connection; - private Pool> pool; + private LettucePool pool; private int dbIndex = 0; /** Synchronization monitor for the shared Connection */ private final Object connectionMonitor = new Object(); @@ -87,15 +87,12 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea this.port = port; } - public LettuceConnectionFactory(String host, int port, Pool> pool) { - this.hostName = host; - this.port = port; + public LettuceConnectionFactory(LettucePool pool) { this.pool = pool; } public void afterPropertiesSet() { - client = new RedisClient(hostName, port); - client.setDefaultTimeout(timeout, TimeUnit.MILLISECONDS); + this.client = createRedisClient(); resetConnection(); if (shareNativeConnection) { initConnection(); @@ -312,4 +309,13 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea getHostName() + ":" + getPort(), e); } } + + private RedisClient createRedisClient() { + if(pool != null) { + return pool.getClient(); + } + RedisClient client = new RedisClient(hostName, port); + client.setDefaultTimeout(timeout, TimeUnit.MILLISECONDS); + return client; + } } \ No newline at end of file diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettucePool.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettucePool.java index 08dc131f9..6f4006322 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettucePool.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettucePool.java @@ -13,206 +13,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.data.redis.connection.lettuce; -import java.util.concurrent.TimeUnit; - -import org.apache.commons.pool.BasePoolableObjectFactory; -import org.apache.commons.pool.impl.GenericObjectPool; -import org.apache.commons.pool.impl.GenericObjectPool.Config; import org.springframework.data.redis.connection.Pool; -import org.springframework.data.redis.connection.PoolException; import com.lambdaworks.redis.RedisAsyncConnection; import com.lambdaworks.redis.RedisClient; /** - * Lettuce implementation of {@link Pool} - * + * + * Pool of Lettuce {@link RedisAsyncConnection}s + * * @author Jennifer Hickey - * + * */ -public class LettucePool implements Pool> { - private final GenericObjectPool internalPool; - private static final int DEFAULT_TIMEOUT = (int) TimeUnit.MILLISECONDS.convert(60, TimeUnit.SECONDS); - - /** - * Uses the {@link Config} and {@link RedisClient} defaults for configuring - * the connection pool - * - * @param hostName - * The Redis host - * @param port - * The Redis port - */ - public LettucePool(String hostName, int port) { - this(hostName, port, 0, DEFAULT_TIMEOUT, new Config()); - } - - /** - * Uses the {@link RedisClient} defaults for configuring the connection pool - * - * @param hostName - * The Redis host - * @param port - * The Redis port - * @param poolConfig - * The pool {@link Config} - */ - public LettucePool(String hostName, int port, Config poolConfig) { - this(hostName, port, 0, DEFAULT_TIMEOUT, poolConfig); - } +public interface LettucePool extends Pool> { /** * - * Uses the {@link Config} defaults for configuring the connection pool - * - * @param client - * The {@link RedisClient} for connecting to Redis - * + * @return The {@link RedisClient} used to create pooled connections */ - public LettucePool(RedisClient client) { - this.internalPool = new GenericObjectPool(new LettuceFactory(client, 0), new Config()); - } + RedisClient getClient(); - /** - * - * @param client - * The {@link RedisClient} for connecting to Redis - * - * @param poolConfig - * The pool {@link Config} - * @param dbIndex - * The index of the database all connections should use. The - * database will be selected when connections are activated. - */ - public LettucePool(RedisClient client, Config poolConfig, int dbIndex) { - this.internalPool = new GenericObjectPool(new LettuceFactory(client, dbIndex), poolConfig); - } - - /** - * Uses the {@link Config} defaults for configuring the connection pool - * - * @param hostName - * The Redis host - * @param port - * The Redis port - * @param dbIndex - * The index of the database all connections should use. The - * database will be selected when connections are activated. - * @param password - * The password used for authenticating with the Redis server or - * null if no password required - * @param timeout - * The socket timeout or 0 to use the default socket timeout - */ - public LettucePool(String hostName, int port, int dbIndex, int timeout) { - this(hostName, port, dbIndex, timeout, new Config()); - } - - /** - * - * @param hostName - * The Redis host - * @param port - * The Redis port - * @param dbIndex - * The index of the database all connections should use. The - * database will be selected when connections are activated. - * @param password - * The password used for authenticating with the Redis server or - * null if no password required - * @param timeout - * The socket timeout or 0 to use the default socket timeout - * @param poolConfig - * The pool {@link COnfig} - */ - public LettucePool(String hostName, int port, int dbIndex, int timeout, Config poolConfig) { - RedisClient client = new RedisClient(hostName, port); - client.setDefaultTimeout(timeout, TimeUnit.MILLISECONDS); - this.internalPool = new GenericObjectPool(new LettuceFactory(client, dbIndex), poolConfig); - } - - @SuppressWarnings("unchecked") - public RedisAsyncConnection getResource() { - try { - return (RedisAsyncConnection) internalPool.borrowObject(); - } catch (Exception e) { - throw new PoolException("Could not get a resource from the pool", e); - } - } - - public void returnBrokenResource(final RedisAsyncConnection resource) { - try { - internalPool.invalidateObject(resource); - } catch (Exception e) { - throw new PoolException("Could not invalidate the broken resource", e); - } - } - - public void returnResource(final RedisAsyncConnection resource) { - try { - internalPool.returnObject(resource); - } catch (Exception e) { - throw new PoolException("Could not return the resource to the pool", e); - } - } - - public void destroy() { - try { - internalPool.close(); - } catch (Exception e) { - throw new PoolException("Could not destroy the pool", e); - } - } - - private static class LettuceFactory extends BasePoolableObjectFactory { - - private final RedisClient client; - - private int dbIndex; - - public LettuceFactory(RedisClient client, int dbIndex) { - super(); - this.client = client; - this.dbIndex = dbIndex; - } - - public Object makeObject() throws Exception { - return client.connectAsync(LettuceUtils.CODEC); - } - - @SuppressWarnings("rawtypes") - @Override - public void activateObject(Object obj) throws Exception { - if (obj instanceof RedisAsyncConnection) { - ((RedisAsyncConnection) obj).select(dbIndex); - } - } - - @SuppressWarnings("rawtypes") - public void destroyObject(final Object obj) throws Exception { - if (obj instanceof RedisAsyncConnection) { - try { - ((RedisAsyncConnection) obj).close(); - } catch (Exception e) { - // Errors may happen if returning a broken resource - } - } - } - - @SuppressWarnings("rawtypes") - public boolean validateObject(final Object obj) { - if (obj instanceof RedisAsyncConnection) { - try { - ((RedisAsyncConnection) obj).ping(); - return true; - } catch (Exception e) { - return false; - } - } else { - return false; - } - } - } } diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettucePoolTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/DefaultLettucePoolTests.java similarity index 81% rename from src/test/java/org/springframework/data/redis/connection/lettuce/LettucePoolTests.java rename to src/test/java/org/springframework/data/redis/connection/lettuce/DefaultLettucePoolTests.java index b7d94b5c9..3fd541856 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettucePoolTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/DefaultLettucePoolTests.java @@ -32,16 +32,16 @@ import com.lambdaworks.redis.RedisClient; import com.lambdaworks.redis.RedisException; /** - * Unit test of {@link LettucePool} - * + * Unit test of {@link DefaultLettucePool} + * * @author Jennifer Hickey - * + * */ -public class LettucePoolTests { +public class DefaultLettucePoolTests { private RedisClient client; - private LettucePool pool; + private DefaultLettucePool pool; @Before public void setUp() { @@ -57,7 +57,7 @@ public class LettucePoolTests { @Test public void testGetResource() { - this.pool = new LettucePool(client); + this.pool = new DefaultLettucePool(client); RedisAsyncConnection client = pool.getResource(); assertNotNull(client); client.ping(); @@ -68,7 +68,7 @@ public class LettucePoolTests { Config poolConfig = new Config(); poolConfig.maxActive = 1; poolConfig.maxWait = 1; - this.pool = new LettucePool(client, poolConfig, 0); + this.pool = new DefaultLettucePool(client, poolConfig, 0); RedisAsyncConnection client = pool.getResource(); assertNotNull(client); try { @@ -82,14 +82,14 @@ public class LettucePoolTests { public void testGetResourceValidate() { PoolConfig poolConfig = new PoolConfig(); poolConfig.setTestOnBorrow(true); - this.pool = new LettucePool(client, poolConfig, 0); + this.pool = new DefaultLettucePool(client, poolConfig, 0); RedisAsyncConnection client = pool.getResource(); assertNotNull(client); } @Test(expected = PoolException.class) public void testGetResourceCreationUnsuccessful() { - this.pool = new LettucePool(new RedisClient(SettingsUtils.getHost(), 3333)); + this.pool = new DefaultLettucePool(new RedisClient(SettingsUtils.getHost(), 3333)); pool.getResource(); } @@ -98,7 +98,7 @@ public class LettucePoolTests { Config poolConfig = new Config(); poolConfig.maxActive = 1; poolConfig.maxWait = 1; - this.pool = new LettucePool(client); + this.pool = new DefaultLettucePool(client); RedisAsyncConnection client = pool.getResource(); assertNotNull(client); pool.returnResource(client); @@ -110,7 +110,7 @@ public class LettucePoolTests { Config poolConfig = new Config(); poolConfig.maxActive = 1; poolConfig.maxWait = 1; - this.pool = new LettucePool(client, poolConfig, 0); + this.pool = new DefaultLettucePool(client, poolConfig, 0); RedisAsyncConnection client = pool.getResource(); assertNotNull(client); pool.returnBrokenResource(client); @@ -125,19 +125,19 @@ public class LettucePoolTests { @Test public void testCreateWithHostAndPort() { - this.pool = new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort()); + this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort()); assertNotNull(pool.getResource()); } @Test public void testCreateWithDbIndex() { - this.pool = new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), 1, 65000); + this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), 1, 65000); assertNotNull(pool.getResource()); } @Test(expected = PoolException.class) public void testCreateWithDbIndexInvalid() { - this.pool = new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), 17, 65000); + this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), 17, 65000); pool.getResource(); } } diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactoryTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactoryTests.java index 433ee0d61..62c2b4bf0 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactoryTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactoryTests.java @@ -221,8 +221,7 @@ public class LettuceConnectionFactoryTests { Config poolConfig = new Config(); poolConfig.maxActive = 1; poolConfig.maxWait = 1; - LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), - SettingsUtils.getPort(), new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), + LettuceConnectionFactory factory2 = new LettuceConnectionFactory(new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), poolConfig)); factory2.afterPropertiesSet(); factory2.createLettuceConnector(false); @@ -239,8 +238,7 @@ public class LettuceConnectionFactoryTests { @Test public void testLotsOfConnections() throws InterruptedException { // Running a netstat here should show only the 8 conns from the pool (plus 2 from setUp and 1 from factory2 afterPropertiesSet for shared conn) - final LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), - SettingsUtils.getPort(), new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort())); + final LettuceConnectionFactory factory2 = new LettuceConnectionFactory(new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort())); factory2.afterPropertiesSet(); for(int i=1;i< 1000;i++) { Thread th = new Thread(new Runnable() { diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionIntegrationTests.java index a9635ca3a..60378e489 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionIntegrationTests.java @@ -127,8 +127,8 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra @Test public void testClosePooledConnectionWithShared() { - LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort(), - new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort())); + LettuceConnectionFactory factory2 = new LettuceConnectionFactory(new DefaultLettucePool(SettingsUtils.getHost(), + SettingsUtils.getPort())); factory2.afterPropertiesSet(); RedisConnection connection = factory2.getConnection(); // Use the connection to make sure the channel is initialized, else nothing happens on close @@ -144,8 +144,8 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra @Test public void testClosePooledConnectionNotShared() { - LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort(), - new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort())); + LettuceConnectionFactory factory2 = new LettuceConnectionFactory(new DefaultLettucePool(SettingsUtils.getHost(), + SettingsUtils.getPort())); factory2.setShareNativeConnection(false); factory2.afterPropertiesSet(); RedisConnection connection = factory2.getConnection(); @@ -178,8 +178,8 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra @SuppressWarnings("rawtypes") @Test public void testCloseReturnBrokenResourceToPool() { - LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort(), - new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort())); + LettuceConnectionFactory factory2 = new LettuceConnectionFactory(new DefaultLettucePool(SettingsUtils.getHost(), + SettingsUtils.getPort())); factory2.setShareNativeConnection(false); factory2.afterPropertiesSet(); RedisConnection connection = factory2.getConnection(); @@ -202,8 +202,8 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra @Test public void testSelectNotShared() { - LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort(), - new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort())); + LettuceConnectionFactory factory2 = new LettuceConnectionFactory(new DefaultLettucePool(SettingsUtils.getHost(), + SettingsUtils.getPort())); factory2.setShareNativeConnection(false); factory2.afterPropertiesSet(); RedisConnection connection = factory2.getConnection();