Author: jmesnil
Date: 2009-11-19 07:54:45 -0500 (Thu, 19 Nov 2009)
New Revision: 8322
Modified:
trunk/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
trunk/tests/src/org/hornetq/tests/integration/remoting/PingTest.java
Log:
fixed PingTest.testClientFailureNoServerPing
* the server must received at least 1 ping from the client to use the client Connection
TTL value instead of the default server value
Modified: trunk/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
===================================================================
---
trunk/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2009-11-19
11:23:14 UTC (rev 8321)
+++
trunk/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2009-11-19
12:54:45 UTC (rev 8322)
@@ -65,7 +65,7 @@
private static final Logger log = Logger.getLogger(RemotingServiceImpl.class);
- private static final long CONNECTION_TTL_CHECK_INTERVAL = 2000;
+ public static final long CONNECTION_TTL_CHECK_INTERVAL = 2000;
// Attributes ----------------------------------------------------
Modified: trunk/tests/src/org/hornetq/tests/integration/remoting/PingTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/remoting/PingTest.java 2009-11-19
11:23:14 UTC (rev 8321)
+++ trunk/tests/src/org/hornetq/tests/integration/remoting/PingTest.java 2009-11-19
12:54:45 UTC (rev 8322)
@@ -28,7 +28,11 @@
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.CloseListener;
+import org.hornetq.core.remoting.Interceptor;
+import org.hornetq.core.remoting.Packet;
import org.hornetq.core.remoting.RemotingConnection;
+import org.hornetq.core.remoting.impl.wireformat.PacketImpl;
+import org.hornetq.core.remoting.server.impl.RemotingServiceImpl;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
@@ -290,6 +294,22 @@
*/
public void testClientFailureNoServerPing() throws Exception
{
+ // server must received at least one ping from the client to pass
+ // so that the server connection TTL is configured with the client value
+ final CountDownLatch pingOnServerLatch = new CountDownLatch(1);
+ server.getRemotingService().addInterceptor(new Interceptor()
+ {
+
+ public boolean intercept(Packet packet, RemotingConnection connection) throws
HornetQException
+ {
+ if (packet.getType() == PacketImpl.PING)
+ {
+ pingOnServerLatch.countDown();
+ }
+ return true;
+ }
+ });
+
TransportConfiguration transportConfig = new
TransportConfiguration("org.hornetq.integration.transports.netty.NettyConnectorFactory");
ClientSessionFactory csf = new ClientSessionFactoryImpl(transportConfig);
@@ -341,15 +361,19 @@
}
}
+
serverConn.addCloseListener(serverListener);
+ assertTrue("server has not received any ping from the client" ,
pingOnServerLatch.await(2000, TimeUnit.MILLISECONDS));
+ // we let the server receives at least 1 ping (so that it uses the client
ConnectionTTL value)
+
//Setting the handler to null will prevent server sending pings back to client
serverConn.getChannel(0, -1).setHandler(null);
assertTrue(clientLatch.await(4 * CLIENT_FAILURE_CHECK_PERIOD,
TimeUnit.MILLISECONDS));
//Server connection will be closed too, when client closes client side connection
after failure is detected
- assertTrue(serverLatch.await(8 * CLIENT_FAILURE_CHECK_PERIOD,
TimeUnit.MILLISECONDS));
+ assertTrue(serverLatch.await(2 * RemotingServiceImpl.CONNECTION_TTL_CHECK_INTERVAL,
TimeUnit.MILLISECONDS));
long start = System.currentTimeMillis();
while (true)