[jboss-cvs] JBoss Messaging SVN: r4468 - in trunk: src/main/org/jboss/messaging/core/config/impl and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jun 13 16:24:36 EDT 2008


Author: timfox
Date: 2008-06-13 16:24:36 -0400 (Fri, 13 Jun 2008)
New Revision: 4468

Added:
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientPingTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ServerPingTest.java
Removed:
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientKeepAliveTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ServerKeepAliveTest.java
Modified:
   trunk/src/config/jbm-configuration.xml
   trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
   trunk/src/main/org/jboss/messaging/core/ping/impl/PingerImpl.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java
Log:
A few tweaks


Modified: trunk/src/config/jbm-configuration.xml
===================================================================
--- trunk/src/config/jbm-configuration.xml	2008-06-13 20:01:54 UTC (rev 4467)
+++ trunk/src/config/jbm-configuration.xml	2008-06-13 20:24:36 UTC (rev 4468)
@@ -21,8 +21,8 @@
 
       <remoting-host>localhost</remoting-host>
 
-      <!--  timeout in milliseconds -->
-      <remoting-timeout>5000</remoting-timeout>
+      <!--  call timeout in milliseconds -->
+      <remoting-call-timeout>5000</remoting-call-timeout>
 
       <!-- true to disable invm communication when the client and the server are in the same JVM.     -->
       <!-- it is not allowed to disable invm communication when the remoting-transport is set to INVM -->
@@ -44,11 +44,11 @@
 
       <!-- The interval to send a ping message to send to the client/server to make sure it is still alive.-->
       <!-- Set to 0 if you want to disable this functionality-->
-      <remoting-keep-alive-interval>10000</remoting-keep-alive-interval>
+      <remoting-ping-interval>10000</remoting-ping-interval>
 
       <!--How long to wait for a returning pong after sending a ping message to a client/server.-->
       <!-- If no pong is received after this time resources are cleaned up-->
-      <remoting-keep-alive-timeout>5000</remoting-keep-alive-timeout>
+      <remoting-ping-timeout>5000</remoting-ping-timeout>
 
       <remoting-writequeue-block-timeout>10000</remoting-writequeue-block-timeout>
 

Modified: trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java	2008-06-13 20:01:54 UTC (rev 4467)
+++ trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java	2008-06-13 20:24:36 UTC (rev 4468)
@@ -85,7 +85,7 @@
 
       port = getInteger(e, "remoting-bind-address", port);
 
-      int blockingCallTimeout = getInteger(e, "remoting-timeout", ConnectionParamsImpl.DEFAULT_BLOCKING_CALL_TIMEOUT);
+      int blockingCallTimeout = getInteger(e, "remoting-call-timeout", ConnectionParamsImpl.DEFAULT_BLOCKING_CALL_TIMEOUT);
 
       boolean invmDisabled = getBoolean(e, "remoting-disable-invm", ConnectionParamsImpl.DEFAULT_INVM_DISABLED);
 
@@ -95,9 +95,9 @@
 
       int tcpSendBufferSize = getInteger(e, "remoting-tcp-send-buffer-size", ConnectionParamsImpl.DEFAULT_TCP_SEND_BUFFER_SIZE);
 
-      int pingInterval = getInteger(e, "remoting-keep-alive-interval", ConnectionParamsImpl.DEFAULT_PING_INTERVAL);
+      int pingInterval = getInteger(e, "remoting-ping-interval", ConnectionParamsImpl.DEFAULT_PING_INTERVAL);
 
-      int pingTimeout = getInteger(e, "remoting-keep-alive-timeout", ConnectionParamsImpl.DEFAULT_PING_TIMEOUT);
+      int pingTimeout = getInteger(e, "remoting-ping-timeout", ConnectionParamsImpl.DEFAULT_PING_TIMEOUT);
 
       sslEnabled = getBoolean(e, "remoting-enable-ssl", ConnectionParamsImpl.DEFAULT_SSL_ENABLED);
 

Modified: trunk/src/main/org/jboss/messaging/core/ping/impl/PingerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/ping/impl/PingerImpl.java	2008-06-13 20:01:54 UTC (rev 4467)
+++ trunk/src/main/org/jboss/messaging/core/ping/impl/PingerImpl.java	2008-06-13 20:24:36 UTC (rev 4468)
@@ -14,7 +14,7 @@
 import org.jboss.messaging.core.remoting.impl.wireformat.Pong;
 
 /**
- * A PingerImpl.Pings the Client or SErver and waits for the KeepAliveTimeout for a response. If none occurs clean up is
+ * A PingerImpl.Pings the Client or SErver and waits for the PingTimeout for a response. If none occurs clean up is
  * carried out.
  *
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java	2008-06-13 20:01:54 UTC (rev 4467)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java	2008-06-13 20:24:36 UTC (rev 4468)
@@ -124,8 +124,6 @@
          }
       }
       addCodecFilter(filterChain);
-//     addKeepAliveFilter(filterChain, keepAliveFactory, connectionParams.getKeepAliveInterval(),
-//            connectionParams.getKeepAliveTimeout(), this);
       connector.getSessionConfig().setTcpNoDelay(connectionParams.isTcpNoDelay());
       int receiveBufferSize = connectionParams.getTcpReceiveBufferSize();
       if (receiveBufferSize != -1)

Deleted: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientKeepAliveTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientKeepAliveTest.java	2008-06-13 20:01:54 UTC (rev 4467)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientKeepAliveTest.java	2008-06-13 20:24:36 UTC (rev 4468)
@@ -1,273 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.tests.integration.core.remoting.mina;
-
-import junit.framework.TestCase;
-import org.jboss.messaging.core.client.ConnectionParams;
-import org.jboss.messaging.core.client.RemotingSessionListener;
-import org.jboss.messaging.core.client.impl.ConnectionParamsImpl;
-import org.jboss.messaging.core.client.impl.LocationImpl;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
-import org.jboss.messaging.core.exception.MessagingException;
-import org.jboss.messaging.core.remoting.Packet;
-import org.jboss.messaging.core.remoting.PacketHandler;
-import org.jboss.messaging.core.remoting.PacketReturner;
-import org.jboss.messaging.core.remoting.RemotingSession;
-import static org.jboss.messaging.core.remoting.TransportType.TCP;
-import org.jboss.messaging.core.remoting.impl.PacketDispatcherImpl;
-import org.jboss.messaging.core.remoting.impl.mina.MinaConnector;
-import org.jboss.messaging.core.remoting.impl.wireformat.Pong;
-import org.jboss.messaging.core.server.MessagingServer;
-import org.jboss.messaging.core.server.impl.MessagingServerImpl;
-import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
-import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
-
-import java.util.concurrent.CountDownLatch;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * @version <tt>$Revision$</tt>
- */
-public class ClientKeepAliveTest extends TestCase
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private MessagingServer messagingServer;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   // Public --------------------------------------------------------
-
-   @Override
-   protected void setUp() throws Exception
-   {
-      ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration("localhost", TestSupport.PORT);
-      config.getConnectionParams().setPingInterval(TestSupport.PING_INTERVAL);
-      config.getConnectionParams().setPingTimeout(TestSupport.PING_TIMEOUT);
-      messagingServer = new MessagingServerImpl(config);
-      messagingServer.start();
-   }
-
-   @Override
-   protected void tearDown() throws Exception
-   {
-      messagingServer.stop();
-   }
-
-   public void testKeepAliveWithClientOK() throws Exception
-   {
-      final CountDownLatch latch = new CountDownLatch(1);
-
-      RemotingSessionListener listener = new RemotingSessionListener()
-      {
-         public void sessionDestroyed(long sessionID, MessagingException me)
-         {
-            latch.countDown();
-         }
-      };
-      messagingServer.getRemotingService().addRemotingSessionListener(listener);
-      ConnectionParams connectionParams = new ConnectionParamsImpl();
-      connectionParams.setPingInterval(TestSupport.PING_INTERVAL);
-      connectionParams.setPingTimeout(TestSupport.PING_TIMEOUT);
-      MinaConnector connector = new MinaConnector(new LocationImpl(TCP, "localhost", TestSupport.PORT), connectionParams, new PacketDispatcherImpl(null));
-      connector.connect();
-
-      boolean firedKeepAliveNotification = latch.await(TestSupport.PING_INTERVAL
-              + TestSupport.PING_TIMEOUT + 2000, MILLISECONDS);
-      assertFalse(firedKeepAliveNotification);
-
-      messagingServer.getRemotingService().removeRemotingSessionListener(listener);
-      //connector.disconnect();
-
-      // verify(factory);
-   }
-
-   public void testKeepAliveWithClientNotResponding() throws Throwable
-   {
-
-      final long[] clientSessionIDNotResponding = new long[1];
-      final CountDownLatch latch = new CountDownLatch(1);
-
-      RemotingSessionListener listener = new RemotingSessionListener()
-      {
-         public void sessionDestroyed(long sessionID, MessagingException me)
-         {
-            clientSessionIDNotResponding[0] = sessionID;
-            latch.countDown();
-         }
-      };
-      messagingServer.getRemotingService().addRemotingSessionListener(listener);
-      ConnectionParams connectionParams = new ConnectionParamsImpl();
-      connectionParams.setPingInterval(TestSupport.PING_INTERVAL);
-      connectionParams.setPingTimeout(TestSupport.PING_TIMEOUT);
-
-      LocationImpl location = new LocationImpl(TCP, "localhost", TestSupport.PORT);
-      MinaConnector connector = new MinaConnector(location, connectionParams, new PacketDispatcherImpl(null));
-
-      RemotingSession session = connector.connect();
-      connector.getDispatcher().register(new NotRespondingPacketHandler());
-      long clientSessionID = session.getID();
-
-      boolean firedKeepAliveNotification = latch.await(TestSupport.PING_INTERVAL
-              + TestSupport.PING_TIMEOUT + 2000, MILLISECONDS);
-      assertTrue("notification has not been received", firedKeepAliveNotification);
-      assertNotNull(clientSessionIDNotResponding[0]);
-      //assertEquals(clientSessionID, clientSessionIDNotResponding[0]);
-
-      messagingServer.getRemotingService().removeRemotingSessionListener(listener);
-      connector.disconnect();
-   }
-
-   public void testKeepAliveWithClientTooLongToRespond() throws Throwable
-   {
-      PacketHandler tooLongRespondHandler = new PacketHandler()
-      {
-         public long getID()
-         {
-            return 0;
-         }
-
-         public void handle(Packet packet, PacketReturner sender)
-         {
-            try
-            {
-               synchronized (this)
-               {
-                  wait(2 * 3600);
-               }
-            }
-            catch (InterruptedException e)
-            {
-               e.printStackTrace();
-            }
-            try
-            {
-               sender.send(new Pong(randomLong(), false));
-            }
-            catch (Exception e)
-            {
-               e.printStackTrace();
-            }
-         }
-      };
-      try
-      {
-         ConnectionParams connectionParams = new ConnectionParamsImpl();
-         connectionParams.setPingInterval(TestSupport.PING_INTERVAL);
-         connectionParams.setPingTimeout(TestSupport.PING_TIMEOUT);
-         LocationImpl location = new LocationImpl(TCP, "localhost", TestSupport.PORT);
-         MinaConnector connector = new MinaConnector(location, connectionParams,
-                 new PacketDispatcherImpl(null));
-
-         RemotingSession session = connector.connect();
-         connector.getDispatcher().register(tooLongRespondHandler);
-         long clientSessionID = session.getID();
-
-         final AtomicLong clientSessionIDNotResponding = new AtomicLong(-1);
-         final CountDownLatch latch = new CountDownLatch(1);
-
-         RemotingSessionListener listener = new RemotingSessionListener()
-         {
-            public void sessionDestroyed(long sessionID, MessagingException me)
-            {
-               clientSessionIDNotResponding.set(sessionID);
-               latch.countDown();
-            }
-         };
-         messagingServer.getRemotingService().addRemotingSessionListener(listener);
-
-         boolean firedKeepAliveNotification = latch.await(TestSupport.PING_INTERVAL
-                 + TestSupport.PING_TIMEOUT + 2000, MILLISECONDS);
-         assertTrue("notification has not been received", firedKeepAliveNotification);
-         //assertEquals(clientSessionID, clientSessionIDNotResponding.longValue());
-
-         messagingServer.getRemotingService().removeRemotingSessionListener(listener);
-         connector.disconnect();
-
-      }
-      finally
-      {
-         // test is done: wake up the factory
-         synchronized (tooLongRespondHandler)
-         {
-            tooLongRespondHandler.notify();
-         }
-      }
-   }
-
-   public void testKeepAliveWithClientRespondingAndClientNotResponding()
-           throws Throwable
-   {
-      final AtomicLong sessionIDNotResponding = new AtomicLong(-1);
-      final CountDownLatch latch = new CountDownLatch(1);
-
-      RemotingSessionListener listener = new RemotingSessionListener()
-      {
-         public void sessionDestroyed(long sessionID, MessagingException me)
-         {
-            sessionIDNotResponding.set(sessionID);
-            latch.countDown();
-         }
-      };
-      //assign this after we have connected to replace the pong handler
-      PacketHandler notRespondingPacketHandler = new NotRespondingPacketHandler();
-      messagingServer.getRemotingService().addRemotingSessionListener(listener);
-      ConnectionParams connectionParams = new ConnectionParamsImpl();
-      connectionParams.setPingInterval(TestSupport.PING_INTERVAL);
-      connectionParams.setPingTimeout(TestSupport.PING_TIMEOUT);
-      LocationImpl location = new LocationImpl(TCP, "localhost", TestSupport.PORT);
-      MinaConnector connectorNotResponding = new MinaConnector(location, new PacketDispatcherImpl(null));
-      MinaConnector connectorResponding = new MinaConnector(location, new PacketDispatcherImpl(null));
-
-      RemotingSession sessionNotResponding = connectorNotResponding.connect();
-      connectorNotResponding.getDispatcher().register(notRespondingPacketHandler);
-      long clientSessionIDNotResponding = sessionNotResponding.getID();
-
-
-      RemotingSession sessionResponding = connectorResponding.connect();
-      long clientSessionIDResponding = sessionResponding.getID();
-
-      boolean firedKeepAliveNotification = latch.await(TestSupport.PING_INTERVAL
-              + TestSupport.PING_TIMEOUT + 2000, MILLISECONDS);
-      assertTrue("notification has not been received", firedKeepAliveNotification);
-
-      //assertEquals(clientSessionIDNotResponding, sessionIDNotResponding.longValue());
-      assertNotSame(clientSessionIDResponding, sessionIDNotResponding.longValue());
-
-      messagingServer.getRemotingService().removeRemotingSessionListener(listener);
-      connectorNotResponding.disconnect();
-      connectorResponding.disconnect();
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-
-
-   private static class NotRespondingPacketHandler implements PacketHandler
-   {
-      public long getID()
-            {
-               return 0;
-            }
-
-      public void handle(Packet packet, PacketReturner sender)
-            {
-               //dont do anything. i.e no response ping
-            }
-   }
-}
\ No newline at end of file

Added: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientPingTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientPingTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientPingTest.java	2008-06-13 20:24:36 UTC (rev 4468)
@@ -0,0 +1,273 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.tests.integration.core.remoting.mina;
+
+import junit.framework.TestCase;
+import org.jboss.messaging.core.client.ConnectionParams;
+import org.jboss.messaging.core.client.RemotingSessionListener;
+import org.jboss.messaging.core.client.impl.ConnectionParamsImpl;
+import org.jboss.messaging.core.client.impl.LocationImpl;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.remoting.Packet;
+import org.jboss.messaging.core.remoting.PacketHandler;
+import org.jboss.messaging.core.remoting.PacketReturner;
+import org.jboss.messaging.core.remoting.RemotingSession;
+import static org.jboss.messaging.core.remoting.TransportType.TCP;
+import org.jboss.messaging.core.remoting.impl.PacketDispatcherImpl;
+import org.jboss.messaging.core.remoting.impl.mina.MinaConnector;
+import org.jboss.messaging.core.remoting.impl.wireformat.Pong;
+import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.core.server.impl.MessagingServerImpl;
+import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
+import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
+
+import java.util.concurrent.CountDownLatch;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * @version <tt>$Revision$</tt>
+ */
+public class ClientPingTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private MessagingServer messagingServer;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration("localhost", TestSupport.PORT);
+      config.getConnectionParams().setPingInterval(TestSupport.PING_INTERVAL);
+      config.getConnectionParams().setPingTimeout(TestSupport.PING_TIMEOUT);
+      messagingServer = new MessagingServerImpl(config);
+      messagingServer.start();
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      messagingServer.stop();
+   }
+
+   public void testKeepAliveWithClientOK() throws Exception
+   {
+      final CountDownLatch latch = new CountDownLatch(1);
+
+      RemotingSessionListener listener = new RemotingSessionListener()
+      {
+         public void sessionDestroyed(long sessionID, MessagingException me)
+         {
+            latch.countDown();
+         }
+      };
+      messagingServer.getRemotingService().addRemotingSessionListener(listener);
+      ConnectionParams connectionParams = new ConnectionParamsImpl();
+      connectionParams.setPingInterval(TestSupport.PING_INTERVAL);
+      connectionParams.setPingTimeout(TestSupport.PING_TIMEOUT);
+      MinaConnector connector = new MinaConnector(new LocationImpl(TCP, "localhost", TestSupport.PORT), connectionParams, new PacketDispatcherImpl(null));
+      connector.connect();
+
+      boolean firedKeepAliveNotification = latch.await(TestSupport.PING_INTERVAL
+              + TestSupport.PING_TIMEOUT + 2000, MILLISECONDS);
+      assertFalse(firedKeepAliveNotification);
+
+      messagingServer.getRemotingService().removeRemotingSessionListener(listener);
+      //connector.disconnect();
+
+      // verify(factory);
+   }
+
+   public void testKeepAliveWithClientNotResponding() throws Throwable
+   {
+
+      final long[] clientSessionIDNotResponding = new long[1];
+      final CountDownLatch latch = new CountDownLatch(1);
+
+      RemotingSessionListener listener = new RemotingSessionListener()
+      {
+         public void sessionDestroyed(long sessionID, MessagingException me)
+         {
+            clientSessionIDNotResponding[0] = sessionID;
+            latch.countDown();
+         }
+      };
+      messagingServer.getRemotingService().addRemotingSessionListener(listener);
+      ConnectionParams connectionParams = new ConnectionParamsImpl();
+      connectionParams.setPingInterval(TestSupport.PING_INTERVAL);
+      connectionParams.setPingTimeout(TestSupport.PING_TIMEOUT);
+
+      LocationImpl location = new LocationImpl(TCP, "localhost", TestSupport.PORT);
+      MinaConnector connector = new MinaConnector(location, connectionParams, new PacketDispatcherImpl(null));
+
+      RemotingSession session = connector.connect();
+      connector.getDispatcher().register(new NotRespondingPacketHandler());
+      long clientSessionID = session.getID();
+
+      boolean firedKeepAliveNotification = latch.await(TestSupport.PING_INTERVAL
+              + TestSupport.PING_TIMEOUT + 2000, MILLISECONDS);
+      assertTrue("notification has not been received", firedKeepAliveNotification);
+      assertNotNull(clientSessionIDNotResponding[0]);
+      //assertEquals(clientSessionID, clientSessionIDNotResponding[0]);
+
+      messagingServer.getRemotingService().removeRemotingSessionListener(listener);
+      connector.disconnect();
+   }
+
+   public void testKeepAliveWithClientTooLongToRespond() throws Throwable
+   {
+      PacketHandler tooLongRespondHandler = new PacketHandler()
+      {
+         public long getID()
+         {
+            return 0;
+         }
+
+         public void handle(Packet packet, PacketReturner sender)
+         {
+            try
+            {
+               synchronized (this)
+               {
+                  wait(2 * 3600);
+               }
+            }
+            catch (InterruptedException e)
+            {
+               e.printStackTrace();
+            }
+            try
+            {
+               sender.send(new Pong(randomLong(), false));
+            }
+            catch (Exception e)
+            {
+               e.printStackTrace();
+            }
+         }
+      };
+      try
+      {
+         ConnectionParams connectionParams = new ConnectionParamsImpl();
+         connectionParams.setPingInterval(TestSupport.PING_INTERVAL);
+         connectionParams.setPingTimeout(TestSupport.PING_TIMEOUT);
+         LocationImpl location = new LocationImpl(TCP, "localhost", TestSupport.PORT);
+         MinaConnector connector = new MinaConnector(location, connectionParams,
+                 new PacketDispatcherImpl(null));
+
+         RemotingSession session = connector.connect();
+         connector.getDispatcher().register(tooLongRespondHandler);
+         long clientSessionID = session.getID();
+
+         final AtomicLong clientSessionIDNotResponding = new AtomicLong(-1);
+         final CountDownLatch latch = new CountDownLatch(1);
+
+         RemotingSessionListener listener = new RemotingSessionListener()
+         {
+            public void sessionDestroyed(long sessionID, MessagingException me)
+            {
+               clientSessionIDNotResponding.set(sessionID);
+               latch.countDown();
+            }
+         };
+         messagingServer.getRemotingService().addRemotingSessionListener(listener);
+
+         boolean firedKeepAliveNotification = latch.await(TestSupport.PING_INTERVAL
+                 + TestSupport.PING_TIMEOUT + 2000, MILLISECONDS);
+         assertTrue("notification has not been received", firedKeepAliveNotification);
+         //assertEquals(clientSessionID, clientSessionIDNotResponding.longValue());
+
+         messagingServer.getRemotingService().removeRemotingSessionListener(listener);
+         connector.disconnect();
+
+      }
+      finally
+      {
+         // test is done: wake up the factory
+         synchronized (tooLongRespondHandler)
+         {
+            tooLongRespondHandler.notify();
+         }
+      }
+   }
+
+   public void testKeepAliveWithClientRespondingAndClientNotResponding()
+           throws Throwable
+   {
+      final AtomicLong sessionIDNotResponding = new AtomicLong(-1);
+      final CountDownLatch latch = new CountDownLatch(1);
+
+      RemotingSessionListener listener = new RemotingSessionListener()
+      {
+         public void sessionDestroyed(long sessionID, MessagingException me)
+         {
+            sessionIDNotResponding.set(sessionID);
+            latch.countDown();
+         }
+      };
+      //assign this after we have connected to replace the pong handler
+      PacketHandler notRespondingPacketHandler = new NotRespondingPacketHandler();
+      messagingServer.getRemotingService().addRemotingSessionListener(listener);
+      ConnectionParams connectionParams = new ConnectionParamsImpl();
+      connectionParams.setPingInterval(TestSupport.PING_INTERVAL);
+      connectionParams.setPingTimeout(TestSupport.PING_TIMEOUT);
+      LocationImpl location = new LocationImpl(TCP, "localhost", TestSupport.PORT);
+      MinaConnector connectorNotResponding = new MinaConnector(location, new PacketDispatcherImpl(null));
+      MinaConnector connectorResponding = new MinaConnector(location, new PacketDispatcherImpl(null));
+
+      RemotingSession sessionNotResponding = connectorNotResponding.connect();
+      connectorNotResponding.getDispatcher().register(notRespondingPacketHandler);
+      long clientSessionIDNotResponding = sessionNotResponding.getID();
+
+
+      RemotingSession sessionResponding = connectorResponding.connect();
+      long clientSessionIDResponding = sessionResponding.getID();
+
+      boolean firedKeepAliveNotification = latch.await(TestSupport.PING_INTERVAL
+              + TestSupport.PING_TIMEOUT + 2000, MILLISECONDS);
+      assertTrue("notification has not been received", firedKeepAliveNotification);
+
+      //assertEquals(clientSessionIDNotResponding, sessionIDNotResponding.longValue());
+      assertNotSame(clientSessionIDResponding, sessionIDNotResponding.longValue());
+
+      messagingServer.getRemotingService().removeRemotingSessionListener(listener);
+      connectorNotResponding.disconnect();
+      connectorResponding.disconnect();
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+
+   private static class NotRespondingPacketHandler implements PacketHandler
+   {
+      public long getID()
+            {
+               return 0;
+            }
+
+      public void handle(Packet packet, PacketReturner sender)
+            {
+               //dont do anything. i.e no response ping
+            }
+   }
+}
\ No newline at end of file

Deleted: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ServerKeepAliveTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ServerKeepAliveTest.java	2008-06-13 20:01:54 UTC (rev 4467)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ServerKeepAliveTest.java	2008-06-13 20:24:36 UTC (rev 4468)
@@ -1,139 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.tests.integration.core.remoting.mina;
-
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static org.jboss.messaging.core.remoting.impl.wireformat.EmptyPacket.CREATECONNECTION;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicLong;
-
-import junit.framework.TestCase;
-
-import org.jboss.messaging.core.client.RemotingSessionListener;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
-import org.jboss.messaging.core.exception.MessagingException;
-import org.jboss.messaging.core.remoting.Packet;
-import org.jboss.messaging.core.remoting.PacketReturner;
-import org.jboss.messaging.core.remoting.RemotingSession;
-import org.jboss.messaging.core.remoting.impl.PacketDispatcherImpl;
-import org.jboss.messaging.core.remoting.impl.RemotingServiceImpl;
-import org.jboss.messaging.core.remoting.impl.mina.MinaConnector;
-import org.jboss.messaging.core.remoting.impl.wireformat.EmptyPacket;
-import org.jboss.messaging.core.server.impl.ServerPacketHandlerSupport;
-import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * @version <tt>$Revision$</tt>
- */
-public class ServerKeepAliveTest extends TestCase
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private RemotingServiceImpl service;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   // Public --------------------------------------------------------
-
-   @Override
-   protected void setUp() throws Exception
-   {
-   }
-
-   @Override
-   protected void tearDown() throws Exception
-   {
-      service.stop();
-      service = null;
-   }
-
-   public void testKeepAliveWithServerNotResponding() throws Throwable
-   {
-      //set the server timeouts to be twice that of the server to force failure
-      ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration(
-              "localhost", TestSupport.PORT);
-      config.getConnectionParams().setPingInterval(TestSupport.PING_INTERVAL * 2);
-      config.getConnectionParams().setPingTimeout(TestSupport.PING_TIMEOUT * 2);
-      ConfigurationImpl clientConfig = ConfigurationHelper.newTCPConfiguration(
-              "localhost", TestSupport.PORT);
-      clientConfig.getConnectionParams().setPingInterval(TestSupport.PING_INTERVAL);
-      clientConfig.getConnectionParams().setPingTimeout(TestSupport.PING_TIMEOUT);
-      service = new RemotingServiceImpl(config);
-      service.start();
-      service.getDispatcher().register(new DummyServePacketHandler());
-      MinaConnector connector = new MinaConnector(clientConfig.getLocation(), clientConfig.getConnectionParams(), new PacketDispatcherImpl(null));
-
-      final AtomicLong sessionIDNotResponding = new AtomicLong(-1);
-      final CountDownLatch latch = new CountDownLatch(1);
-
-      RemotingSessionListener listener = new RemotingSessionListener()
-      {
-         public void sessionDestroyed(long sessionID, MessagingException me)
-         {
-            sessionIDNotResponding.set(sessionID);
-            latch.countDown();
-         }
-      };
-      connector.addSessionListener(listener);
-
-      RemotingSession session = connector.connect();
-      boolean firedKeepAliveNotification = latch.await(TestSupport.PING_INTERVAL
-              + TestSupport.PING_TIMEOUT + 2000, MILLISECONDS);
-      assertTrue(firedKeepAliveNotification);
-      assertEquals(session.getID(), sessionIDNotResponding.longValue());
-
-      connector.removeSessionListener(listener);
-      connector.disconnect();
-   }
-
-   class DummyServePacketHandler extends ServerPacketHandlerSupport
-   {
-      public long getID()
-      {
-         //0 is reserved for this handler
-         return 0;
-      }
-
-      public Packet doHandle(final Packet packet, final PacketReturner sender) throws Exception
-      {
-         Packet response = null;
-
-         byte type = packet.getType();
-
-         if (type == CREATECONNECTION)
-         {
-            /*CreateConnectionRequest request = (CreateConnectionRequest) packet;
-
-            CreateConnectionResponse createConnectionResponse = server.createConnection(request.getUsername(), request.getPassword(),
-                    request.getRemotingSessionID(),
-                    sender.getRemoteAddress(),
-                    request.getVersion(),
-                    sender);
-            response = createConnectionResponse;*/
-
-         }
-         else if (type == EmptyPacket.PING)
-         {
-            //do nothing
-         }
-
-         return response;
-      }
-   }
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-   // Inner classes -------------------------------------------------
-}
\ No newline at end of file

Copied: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ServerPingTest.java (from rev 4466, trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ServerKeepAliveTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ServerPingTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ServerPingTest.java	2008-06-13 20:24:36 UTC (rev 4468)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.tests.integration.core.remoting.mina;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.jboss.messaging.core.remoting.impl.wireformat.EmptyPacket.CREATECONNECTION;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicLong;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.client.RemotingSessionListener;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.remoting.Packet;
+import org.jboss.messaging.core.remoting.PacketReturner;
+import org.jboss.messaging.core.remoting.RemotingSession;
+import org.jboss.messaging.core.remoting.impl.PacketDispatcherImpl;
+import org.jboss.messaging.core.remoting.impl.RemotingServiceImpl;
+import org.jboss.messaging.core.remoting.impl.mina.MinaConnector;
+import org.jboss.messaging.core.remoting.impl.wireformat.EmptyPacket;
+import org.jboss.messaging.core.server.impl.ServerPacketHandlerSupport;
+import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * @version <tt>$Revision$</tt>
+ */
+public class ServerPingTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private RemotingServiceImpl service;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   @Override
+   protected void setUp() throws Exception
+   {
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      service.stop();
+      service = null;
+   }
+
+   public void testKeepAliveWithServerNotResponding() throws Throwable
+   {
+      //set the server timeouts to be twice that of the server to force failure
+      ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration(
+              "localhost", TestSupport.PORT);
+      config.getConnectionParams().setPingInterval(TestSupport.PING_INTERVAL * 2);
+      config.getConnectionParams().setPingTimeout(TestSupport.PING_TIMEOUT * 2);
+      ConfigurationImpl clientConfig = ConfigurationHelper.newTCPConfiguration(
+              "localhost", TestSupport.PORT);
+      clientConfig.getConnectionParams().setPingInterval(TestSupport.PING_INTERVAL);
+      clientConfig.getConnectionParams().setPingTimeout(TestSupport.PING_TIMEOUT);
+      service = new RemotingServiceImpl(config);
+      service.start();
+      service.getDispatcher().register(new DummyServePacketHandler());
+      MinaConnector connector = new MinaConnector(clientConfig.getLocation(), clientConfig.getConnectionParams(), new PacketDispatcherImpl(null));
+
+      final AtomicLong sessionIDNotResponding = new AtomicLong(-1);
+      final CountDownLatch latch = new CountDownLatch(1);
+
+      RemotingSessionListener listener = new RemotingSessionListener()
+      {
+         public void sessionDestroyed(long sessionID, MessagingException me)
+         {
+            sessionIDNotResponding.set(sessionID);
+            latch.countDown();
+         }
+      };
+      connector.addSessionListener(listener);
+
+      RemotingSession session = connector.connect();
+      boolean firedKeepAliveNotification = latch.await(TestSupport.PING_INTERVAL
+              + TestSupport.PING_TIMEOUT + 2000, MILLISECONDS);
+      assertTrue(firedKeepAliveNotification);
+      assertEquals(session.getID(), sessionIDNotResponding.longValue());
+
+      connector.removeSessionListener(listener);
+      connector.disconnect();
+   }
+
+   class DummyServePacketHandler extends ServerPacketHandlerSupport
+   {
+      public long getID()
+      {
+         //0 is reserved for this handler
+         return 0;
+      }
+
+      public Packet doHandle(final Packet packet, final PacketReturner sender) throws Exception
+      {
+         Packet response = null;
+
+         byte type = packet.getType();
+
+         if (type == CREATECONNECTION)
+         {
+            /*CreateConnectionRequest request = (CreateConnectionRequest) packet;
+
+            CreateConnectionResponse createConnectionResponse = server.createConnection(request.getUsername(), request.getPassword(),
+                    request.getRemotingSessionID(),
+                    sender.getRemoteAddress(),
+                    request.getVersion(),
+                    sender);
+            response = createConnectionResponse;*/
+
+         }
+         else if (type == EmptyPacket.PING)
+         {
+            //do nothing
+         }
+
+         return response;
+      }
+   }
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+   // Inner classes -------------------------------------------------
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list