[infinispan-commits] Infinispan SVN: r1960 - in trunk/client/hotrod-client/src: main/java/org/infinispan/client/hotrod/impl/transport/tcp and 1 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Fri Jul 2 07:00:47 EDT 2010
Author: mircea.markus
Date: 2010-07-02 07:00:47 -0400 (Fri, 02 Jul 2010)
New Revision: 1960
Added:
trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/DroppedConnectionsTest.java
Modified:
trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java
trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransport.java
trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransportFactory.java
Log:
migrated r959 to trunk
Modified: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java 2010-07-02 10:13:45 UTC (rev 1959)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java 2010-07-02 11:00:47 UTC (rev 1960)
@@ -107,7 +107,7 @@
* <li>minIdle - sets a target value for the minimum number of idle connections (per server) that should always be available.
* If this parameter is set to a positive number and timeBetweenEvictionRunsMillis > 0, each time the idle connection
* eviction thread runs, it will try to create enough idle instances so that there will be minIdle idle instances
- * available for each server. The default setting for this parameter is 5 minutes. </li>
+ * available for each server. The default setting for this parameter is 1. </li>
* </ul>
* </li>
* <li>
Modified: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransport.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransport.java 2010-07-02 10:13:45 UTC (rev 1959)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransport.java 2010-07-02 11:00:47 UTC (rev 1960)
@@ -222,4 +222,8 @@
public boolean isValid() {
return !socket.isClosed();
}
+
+ public long getId() {
+ return id;
+ }
}
Modified: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransportFactory.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransportFactory.java 2010-07-02 10:13:45 UTC (rev 1959)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransportFactory.java 2010-07-02 11:00:47 UTC (rev 1960)
@@ -208,4 +208,8 @@
public RequestBalancingStrategy getBalancer() {
return balancer;
}
+
+ public GenericKeyedObjectPool getConnectionPool() {
+ return connectionPool;
+ }
}
Copied: trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/DroppedConnectionsTest.java (from rev 1959, branches/4.1.x/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/DroppedConnectionsTest.java)
===================================================================
--- trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/DroppedConnectionsTest.java (rev 0)
+++ trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/DroppedConnectionsTest.java 2010-07-02 11:00:47 UTC (rev 1960)
@@ -0,0 +1,75 @@
+package org.infinispan.client.hotrod;
+
+import org.apache.commons.pool.impl.GenericKeyedObjectPool;
+import org.infinispan.client.hotrod.impl.transport.tcp.TcpTransport;
+import org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.server.hotrod.HotRodServer;
+import org.infinispan.test.SingleCacheManagerTest;
+import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+import java.net.InetSocketAddress;
+import java.util.Properties;
+
+import static org.testng.AssertJUnit.assertEquals;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+ at Test (testName = "client.hotrod.DroppedConnectionsTest", groups = "functional")
+public class DroppedConnectionsTest extends SingleCacheManagerTest {
+ private HotRodServer hotRodServer;
+ private RemoteCacheManager remoteCacheManager;
+ private RemoteCache rc;
+ private TcpTransportFactory transportFactory;
+
+ @Override
+ protected EmbeddedCacheManager createCacheManager() throws Exception {
+ cacheManager = TestCacheManagerFactory.createCacheManager(getDefaultStandaloneConfig(true));
+ hotRodServer = TestHelper.startHotRodServer(cacheManager);
+ Properties hrClientConfig = new Properties();
+ hrClientConfig.put("testWhileIdle", "false");
+ hrClientConfig.put("minIdle","2");
+ hrClientConfig.put("maxIdle","2");
+ hrClientConfig.put("maxActive","2");
+ hrClientConfig.put("hotrod-servers", "127.0.0.1:" + hotRodServer.getPort());
+ remoteCacheManager = new RemoteCacheManager(hrClientConfig);
+ rc = remoteCacheManager.getCache();
+ transportFactory = (TcpTransportFactory) TestingUtil.extractField(remoteCacheManager, "transportFactory");
+ return cacheManager;
+ }
+
+ @AfterClass
+ public void shutDownHotrod() {
+ remoteCacheManager.stop();
+ hotRodServer.stop();
+ }
+
+ public void closedConnectionTest() throws Exception {
+ rc.put("k","v"); //make sure a connection is created
+
+ GenericKeyedObjectPool keyedObjectPool = transportFactory.getConnectionPool();
+ InetSocketAddress address = new InetSocketAddress("127.0.0.1", hotRodServer.getPort());
+
+ assertEquals(0, keyedObjectPool.getNumActive(address));
+ assertEquals(1, keyedObjectPool.getNumIdle(address));
+
+ TcpTransport tcpConnection = (TcpTransport) keyedObjectPool.borrowObject(address);
+ keyedObjectPool.returnObject(address, tcpConnection);//now we have a reference to the single connection in pool
+
+ tcpConnection.destroy();
+
+ assertEquals("v", rc.get("k"));
+ assertEquals(0, keyedObjectPool.getNumActive(address));
+ assertEquals(1, keyedObjectPool.getNumIdle(address));
+
+ TcpTransport tcpConnection2 = (TcpTransport) keyedObjectPool.borrowObject(address);
+
+ assert tcpConnection2.getId() != tcpConnection.getId();
+ }
+
+}
More information about the infinispan-commits
mailing list