[jboss-cvs] JBoss Messaging SVN: r4090 - in projects/network-benchmark: src and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 21 07:55:50 EDT 2008


Author: jmesnil
Date: 2008-04-21 07:55:50 -0400 (Mon, 21 Apr 2008)
New Revision: 4090

Added:
   projects/network-benchmark/src/core/
   projects/network-benchmark/src/core/CoreMessagingClientTest.java
   projects/network-benchmark/src/core/CoreMessagingServer.java
Removed:
   projects/network-benchmark/lib/mina-core-2.0.0-M2-SNAPSHOT.jar
   projects/network-benchmark/lib/mina-transport-apr-2.0.0-M2-SNAPSHOT.jar
   projects/network-benchmark/src/network/MINAAPRServer.java
Log:
added missing classes
remove MINAAPRServer

Deleted: projects/network-benchmark/lib/mina-core-2.0.0-M2-SNAPSHOT.jar
===================================================================
(Binary files differ)

Deleted: projects/network-benchmark/lib/mina-transport-apr-2.0.0-M2-SNAPSHOT.jar
===================================================================
(Binary files differ)

Added: projects/network-benchmark/src/core/CoreMessagingClientTest.java
===================================================================
--- projects/network-benchmark/src/core/CoreMessagingClientTest.java	                        (rev 0)
+++ projects/network-benchmark/src/core/CoreMessagingClientTest.java	2008-04-21 11:55:50 UTC (rev 4090)
@@ -0,0 +1,221 @@
+package core;
+
+import static network.ClientSetting.DURATION;
+import static network.ClientSetting.SERVER_HOSTNAME;
+import static network.ClientSetting.WARMUP;
+import static org.jboss.messaging.core.remoting.TransportType.TCP;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+import junit.framework.TestCase;
+
+import network.CommonSetting;
+
+import org.jboss.messaging.core.client.ClientConnection;
+import org.jboss.messaging.core.client.ClientConnectionFactory;
+import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientProducer;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.ConnectionParams;
+import org.jboss.messaging.core.client.FailureListener;
+import org.jboss.messaging.core.client.Location;
+import org.jboss.messaging.core.client.MessageHandler;
+import org.jboss.messaging.core.client.impl.ClientConnectionFactoryImpl;
+import org.jboss.messaging.core.client.impl.ConnectionParamsImpl;
+import org.jboss.messaging.core.client.impl.LocationImpl;
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.message.Message;
+import org.jboss.messaging.core.message.impl.MessageImpl;
+import org.jboss.messaging.jms.client.JBossTextMessage;
+
+public class CoreMessagingClientTest extends TestCase
+{
+
+   // Constants -----------------------------------------------------
+
+   private static final int PORT = 9000;
+
+   private final String QUEUE = "CorePerfTestQueue";
+
+   // Attributes ----------------------------------------------------
+
+   private ClientConnection conn;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public static void main(String[] args)
+   {
+
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      Location location = new LocationImpl(TCP, SERVER_HOSTNAME, PORT);
+      ConnectionParams params = new ConnectionParamsImpl();
+      params.setTcpNoDelay(CommonSetting.ENABLE_TCP_NO_DELAY);
+      if (CommonSetting.TCP_BUFFER_SIZE != -1)
+      {
+         params.setTcpReceiveBufferSize(CommonSetting.TCP_BUFFER_SIZE);
+         params.setTcpSendBufferSize(CommonSetting.TCP_BUFFER_SIZE);
+      }
+      ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, location, params);
+
+      conn = cf.createConnection();
+      conn.setFailureListener(new FailureListener()
+      {
+
+         public void onFailure(MessagingException me)
+         {
+            me.printStackTrace();
+         }
+      });
+
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      conn.close();
+
+      super.tearDown();
+   }
+
+   public void test_AutoAck_Durable_Messages() throws Exception
+   {
+      sendAndReceiveMessages(true, true);
+   }
+
+   public void test_AutoAck_Non_Durable_Messages() throws Exception
+   {
+      sendAndReceiveMessages(true, false);
+   }
+
+   public void test_ClientAck_Durable_Messages() throws Exception
+   {
+      sendAndReceiveMessages(false, true);
+   }
+
+   public void test_ClientAck_Non_Durable_Messages() throws Exception
+   {
+      sendAndReceiveMessages(false, false);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   private void sendAndReceiveMessages(final boolean autoAck, boolean durable)
+         throws Exception
+   {
+      
+      final ClientSession session = createSession(conn, autoAck);
+      ClientConsumer consumer = null;
+      try
+      {
+         session.createQueue(QUEUE, QUEUE, null, false, false);
+
+         ClientProducer producer = session.createProducer(QUEUE);
+         consumer = createConsumer(session);
+
+         Message message = new MessageImpl(JBossTextMessage.TYPE, durable, 0,
+               System.currentTimeMillis(), (byte) 1);
+         message.setPayload("testSendOneMessage".getBytes());
+
+         final AtomicLong receivedCountDuringWarmup = new AtomicLong(0);
+         final AtomicLong receivedCountAfterWarmup = new AtomicLong(0);
+
+         final long start = System.currentTimeMillis();
+
+         consumer.setMessageHandler(new MessageHandler()
+         {
+
+            public void onMessage(Message message)
+            {
+               if (System.currentTimeMillis() - start < WARMUP)
+                  receivedCountDuringWarmup.incrementAndGet();
+               else
+                  receivedCountAfterWarmup.incrementAndGet();
+
+               if (!autoAck)
+               {
+                  try
+                  {
+                     session.acknowledge();
+                  } catch (MessagingException e)
+                  {
+                     e.printStackTrace();
+                  }
+               }
+            }
+
+         });
+
+         conn.start();
+
+         long sentCount = 0;
+         while (System.currentTimeMillis() - start < DURATION)
+         {
+            producer.send(message);
+            sentCount++;
+         }
+
+         while ((receivedCountDuringWarmup.get() + receivedCountAfterWarmup
+               .get()) < sentCount)
+         {
+            Thread.yield();
+         }
+
+         assertEquals(sentCount, receivedCountDuringWarmup.longValue()
+               + receivedCountAfterWarmup.longValue());
+
+         long duration = System.currentTimeMillis() - start - WARMUP;
+         display(sentCount, receivedCountAfterWarmup.longValue(), duration);
+      } finally
+      {
+         if (consumer != null)
+            consumer.close();
+
+         session.deleteQueue(QUEUE);
+      }
+   }
+
+   private ClientSession createSession(ClientConnection connection,
+         boolean autoAck) throws MessagingException
+   {
+      ClientSession session = null;
+      if (autoAck)
+         session = connection.createClientSession(false, true, true, 1, true,
+               false);
+      else
+         session = connection.createClientSession(false, true, true, -1, false,
+               false);
+
+      return session;
+   }
+
+   private ClientConsumer createConsumer(ClientSession session)
+         throws MessagingException
+   {
+      return session.createConsumer(QUEUE, null, false, false, true);
+   }
+
+   private void display(long requestCount, long responseCount, long periodInMs)
+   {
+      String name = getName().replace("test_", "").replace('_', ' ');
+      double rate = 1000 * (double) responseCount / periodInMs;
+      System.out.format(
+            "\n%-32s: %6.0f inv./s (%8d inv. in %5d ms, sent %8d)\n", name,
+            rate, responseCount, periodInMs, requestCount);
+   }
+
+   // Inner classes -------------------------------------------------
+}

Added: projects/network-benchmark/src/core/CoreMessagingServer.java
===================================================================
--- projects/network-benchmark/src/core/CoreMessagingServer.java	                        (rev 0)
+++ projects/network-benchmark/src/core/CoreMessagingServer.java	2008-04-21 11:55:50 UTC (rev 4090)
@@ -0,0 +1,61 @@
+package core;
+
+import static org.jboss.messaging.core.remoting.TransportType.TCP;
+import network.ClientSetting;
+import network.CommonSetting;
+
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.server.impl.MessagingServerImpl;
+
+public class CoreMessagingServer implements Runnable
+{
+   // Constants -----------------------------------------------------
+
+   private static final int PORT = 9000;
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   public void run()
+   {
+      
+      ConfigurationImpl conf = new ConfigurationImpl();
+      conf.setTransport(TCP);
+      conf.setHost(ClientSetting.SERVER_HOSTNAME);
+      conf.setPort(PORT);
+      conf.setTcpNoDelay(CommonSetting.ENABLE_TCP_NO_DELAY);
+      if (CommonSetting.TCP_BUFFER_SIZE != -1)
+      {
+         conf.setTcpReceiveBufferSize(CommonSetting.TCP_BUFFER_SIZE);
+         conf.setTcpSendBufferSize(CommonSetting.TCP_BUFFER_SIZE);
+      }
+      final MessagingServerImpl server = new MessagingServerImpl(conf);
+      try
+      {
+         System.out.println("Started core messaging server on " + conf.getLocation());
+         server.start();
+      } catch (Exception e)
+      {
+         e.printStackTrace();
+      }      
+   }
+   
+   public static void main(String[] args) throws Exception
+   {  
+      Thread thread = new Thread(new CoreMessagingServer());
+      thread.start();
+   }
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+   
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Deleted: projects/network-benchmark/src/network/MINAAPRServer.java
===================================================================
--- projects/network-benchmark/src/network/MINAAPRServer.java	2008-04-21 11:26:54 UTC (rev 4089)
+++ projects/network-benchmark/src/network/MINAAPRServer.java	2008-04-21 11:55:50 UTC (rev 4090)
@@ -1,26 +0,0 @@
-package network;
-
-import static network.CommonSetting.*;
-
-import org.apache.mina.transport.socket.SocketAcceptor;
-import org.apache.mina.transport.socket.apr.AprSocketAcceptor;
-
-public class MINAAPRServer extends MINAServer
-{
-    @Override
-    protected SocketAcceptor newAcceptor()
-    {
-        return new AprSocketAcceptor();
-    }
-
-    @Override
-    protected int getPort()
-    {
-        return MINA_APR_SERVER_PORT;
-    }
-
-    public static void main(String[] args)
-    {
-        new MINAAPRServer().run();
-    }
-}




More information about the jboss-cvs-commits mailing list