Applied many patches
Merge branch 'trunk' of https://git-wip-us.apache.org/repos/asf/mina into trunk
diff --git a/benchmarks/common/pom.xml b/benchmarks/common/pom.xml
new file mode 100644
index 0000000..1640c01
--- /dev/null
+++ b/benchmarks/common/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.mina</groupId>
+ <artifactId>mina-benchmarks</artifactId>
+ <version>3.0.0-M3-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>mina-benchmarks-common</artifactId>
+ <name>Apache MINA Benchmarks against JDK and MINA tests</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java b/benchmarks/common/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
similarity index 92%
rename from benchmarks/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
rename to benchmarks/common/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
index b55f367..5c2e85e 100644
--- a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
+++ b/benchmarks/common/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
@@ -29,7 +29,6 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import org.apache.mina.core.BenchmarkFactory.Type;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -63,9 +62,9 @@
this.timeout = timeout;
}
- public abstract Type getClientType();
+ public abstract BenchmarkClient getClient();
- public abstract Type getServerType();
+ public abstract BenchmarkServer getServer();
@Parameters(name = "{0} messages of size {1}")
public static Collection<Object[]> getParameters() {
@@ -94,9 +93,9 @@
@Before
public void init() throws IOException {
port = getNextAvailable();
- server = BenchmarkServerFactory.INSTANCE.get(getServerType());
+ server = getServer();
server.start(port);
- client = BenchmarkClientFactory.INSTANCE.get(getClientType());
+ client = getClient();
data = new byte[messageSize + 4];
data[0] = (byte) (messageSize >>> 24 & 255);
data[1] = (byte) (messageSize >>> 16 & 255);
@@ -119,7 +118,7 @@
CountDownLatch counter = new CountDownLatch(numberOfMessages);
CounterFilter.messageSent.set(0);
- boolean result = false;
+ boolean result = true;
System.out.println("-------------- Sending " + data.length + " bytes");
client.start(port, counter, data);
@@ -139,9 +138,10 @@
warmedUpSent += nbSent;
}
- System.out.println("Nb messages sent per second : " + nbSent);
+ System.out.print("Nb messages sent per second : " + nbSent + "\r");
}
+ System.out.println();
if (nbSeconds < 120) {
System.out.println("Average : " + (warmedUpSent / (nbSeconds - 5)) + ", for " + globalSent
+ " messages sent in " + nbSeconds + "s");
diff --git a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkClient.java b/benchmarks/common/src/test/java/org/apache/mina/core/BenchmarkClient.java
similarity index 100%
rename from benchmarks/src/test/java/org/apache/mina/core/BenchmarkClient.java
rename to benchmarks/common/src/test/java/org/apache/mina/core/BenchmarkClient.java
diff --git a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkServer.java b/benchmarks/common/src/test/java/org/apache/mina/core/BenchmarkServer.java
similarity index 100%
rename from benchmarks/src/test/java/org/apache/mina/core/BenchmarkServer.java
rename to benchmarks/common/src/test/java/org/apache/mina/core/BenchmarkServer.java
diff --git a/benchmarks/src/test/java/org/apache/mina/core/BioClientVsBioServerUdpBenchmarkBinaryTest.java b/benchmarks/common/src/test/java/org/apache/mina/core/BioClientVsBioServerUdpBenchmarkBinaryTest.java
similarity index 87%
rename from benchmarks/src/test/java/org/apache/mina/core/BioClientVsBioServerUdpBenchmarkBinaryTest.java
rename to benchmarks/common/src/test/java/org/apache/mina/core/BioClientVsBioServerUdpBenchmarkBinaryTest.java
index f0260eb..815983d 100644
--- a/benchmarks/src/test/java/org/apache/mina/core/BioClientVsBioServerUdpBenchmarkBinaryTest.java
+++ b/benchmarks/common/src/test/java/org/apache/mina/core/BioClientVsBioServerUdpBenchmarkBinaryTest.java
@@ -22,7 +22,8 @@
import java.util.Arrays;
import java.util.Collection;
-import org.apache.mina.core.BenchmarkFactory.Type;
+import org.apache.mina.core.bio.udp.BioUdpBenchmarkClient;
+import org.apache.mina.core.bio.udp.BioUdpBenchmarkServer;
import org.junit.runners.Parameterized.Parameters;
/**
@@ -42,16 +43,16 @@
* {@inheritDoc}
*/
@Override
- public Type getClientType() {
- return Type.Bio_udp;
+ public BenchmarkClient getClient() {
+ return new BioUdpBenchmarkClient();
}
/**
* {@inheritDoc}
*/
@Override
- public Type getServerType() {
- return Type.Bio_udp;
+ public BenchmarkServer getServer() {
+ return new BioUdpBenchmarkServer();
}
@Parameters(name = "{0} messages of size {1}")
diff --git a/benchmarks/src/test/java/org/apache/mina/core/BioClientVsMina3ServerUdpBenchmarkBinaryTest.java b/benchmarks/common/src/test/java/org/apache/mina/core/BioClientVsMina3ServerUdpBenchmarkBinaryTest.java
similarity index 87%
rename from benchmarks/src/test/java/org/apache/mina/core/BioClientVsMina3ServerUdpBenchmarkBinaryTest.java
rename to benchmarks/common/src/test/java/org/apache/mina/core/BioClientVsMina3ServerUdpBenchmarkBinaryTest.java
index 25d1980..f2f292b 100644
--- a/benchmarks/src/test/java/org/apache/mina/core/BioClientVsMina3ServerUdpBenchmarkBinaryTest.java
+++ b/benchmarks/common/src/test/java/org/apache/mina/core/BioClientVsMina3ServerUdpBenchmarkBinaryTest.java
@@ -22,7 +22,8 @@
import java.util.Arrays;
import java.util.Collection;
-import org.apache.mina.core.BenchmarkFactory.Type;
+import org.apache.mina.core.bio.udp.BioUdpBenchmarkClient;
+import org.apache.mina.core.nio.udp.Mina3UdpBenchmarkServer;
import org.junit.runners.Parameterized.Parameters;
/**
@@ -42,16 +43,16 @@
* {@inheritDoc}
*/
@Override
- public Type getClientType() {
- return Type.Bio_udp;
+ public BenchmarkClient getClient() {
+ return new BioUdpBenchmarkClient();
}
/**
* {@inheritDoc}
*/
@Override
- public Type getServerType() {
- return Type.Mina3_udp;
+ public BenchmarkServer getServer() {
+ return new Mina3UdpBenchmarkServer();
}
@Parameters(name = "{0} messages of size {1}")
diff --git a/benchmarks/src/test/java/org/apache/mina/core/CounterFilter.java b/benchmarks/common/src/test/java/org/apache/mina/core/CounterFilter.java
similarity index 100%
rename from benchmarks/src/test/java/org/apache/mina/core/CounterFilter.java
rename to benchmarks/common/src/test/java/org/apache/mina/core/CounterFilter.java
diff --git a/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerTcpBenchmarkBinaryTest.java b/benchmarks/common/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
similarity index 88%
rename from benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
rename to benchmarks/common/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
index 9135af6..600b5ae 100644
--- a/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
+++ b/benchmarks/common/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
@@ -22,7 +22,8 @@
import java.util.Arrays;
import java.util.Collection;
-import org.apache.mina.core.BenchmarkFactory.Type;
+import org.apache.mina.core.nio.tcp.Mina3TcpBenchmarkClient;
+import org.apache.mina.core.nio.tcp.Mina3TcpBenchmarkServer;
import org.junit.runners.Parameterized.Parameters;
/**
@@ -42,16 +43,16 @@
* {@inheritDoc}
*/
@Override
- public Type getClientType() {
- return Type.Mina3_tcp;
+ public BenchmarkClient getClient() {
+ return new Mina3TcpBenchmarkClient();
}
/**
* {@inheritDoc}
*/
@Override
- public Type getServerType() {
- return Type.Mina3_tcp;
+ public BenchmarkServer getServer() {
+ return new Mina3TcpBenchmarkServer();
}
@Parameters(name = "{0} messages of size {1}")
diff --git a/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerUdpBenchmarkBinaryTest.java b/benchmarks/common/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
similarity index 87%
rename from benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
rename to benchmarks/common/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
index 96d726e..7ea251b 100644
--- a/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
+++ b/benchmarks/common/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
@@ -22,7 +22,8 @@
import java.util.Arrays;
import java.util.Collection;
-import org.apache.mina.core.BenchmarkFactory.Type;
+import org.apache.mina.core.nio.udp.Mina3UdpBenchmarkClient;
+import org.apache.mina.core.nio.udp.Mina3UdpBenchmarkServer;
import org.junit.runners.Parameterized.Parameters;
/**
@@ -42,16 +43,16 @@
* {@inheritDoc}
*/
@Override
- public Type getClientType() {
- return Type.Mina3_udp;
+ public BenchmarkClient getClient() {
+ return new Mina3UdpBenchmarkClient();
}
/**
* {@inheritDoc}
*/
@Override
- public Type getServerType() {
- return Type.Mina3_udp;
+ public BenchmarkServer getServer() {
+ return new Mina3UdpBenchmarkServer();
}
@Parameters(name = "{0} messages of size {1}")
diff --git a/benchmarks/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkClient.java b/benchmarks/common/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkClient.java
similarity index 100%
rename from benchmarks/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkClient.java
rename to benchmarks/common/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkClient.java
diff --git a/benchmarks/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkServer.java b/benchmarks/common/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkServer.java
similarity index 98%
rename from benchmarks/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkServer.java
rename to benchmarks/common/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkServer.java
index 3090565..fd9af8d 100644
--- a/benchmarks/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkServer.java
+++ b/benchmarks/common/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkServer.java
@@ -28,6 +28,7 @@
import org.apache.mina.api.IoService;
import org.apache.mina.api.IoSession;
import org.apache.mina.core.BenchmarkServer;
+import org.apache.mina.core.CounterFilter;
import org.apache.mina.core.nio.udp.Mina3UdpBenchmarkServer;
import org.apache.mina.session.AttributeKey;
import org.apache.mina.transport.bio.BioUdpServer;
@@ -141,7 +142,7 @@
@Override
public void messageSent(IoSession session, Object message) {
- //System.out.println("Server message sent :" + message);
+ CounterFilter.messageSent.getAndIncrement();
}
@Override
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkClient.java b/benchmarks/common/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkClient.java
similarity index 100%
rename from benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkClient.java
rename to benchmarks/common/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkClient.java
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkServer.java b/benchmarks/common/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkServer.java
similarity index 100%
rename from benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkServer.java
rename to benchmarks/common/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkServer.java
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkClient.java b/benchmarks/common/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkClient.java
similarity index 100%
rename from benchmarks/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkClient.java
rename to benchmarks/common/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkClient.java
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkServer.java b/benchmarks/common/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkServer.java
similarity index 98%
rename from benchmarks/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkServer.java
rename to benchmarks/common/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkServer.java
index 48b84b8..a9bf2a9 100644
--- a/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkServer.java
+++ b/benchmarks/common/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkServer.java
@@ -28,6 +28,7 @@
import org.apache.mina.api.IoService;
import org.apache.mina.api.IoSession;
import org.apache.mina.core.BenchmarkServer;
+import org.apache.mina.core.CounterFilter;
import org.apache.mina.session.AttributeKey;
import org.apache.mina.transport.nio.NioUdpServer;
import org.apache.mina.transport.udp.DefaultUdpSessionConfig;
@@ -141,7 +142,7 @@
@Override
public void messageSent(IoSession session, Object message) {
- //System.out.println("Server message sent :" + message);
+ CounterFilter.messageSent.getAndIncrement();
}
@Override
diff --git a/benchmarks/src/test/resources/log4j.properties b/benchmarks/common/src/test/resources/log4j.properties
similarity index 100%
rename from benchmarks/src/test/resources/log4j.properties
rename to benchmarks/common/src/test/resources/log4j.properties
diff --git a/benchmarks2/pom.xml b/benchmarks/netty3/pom.xml
similarity index 62%
copy from benchmarks2/pom.xml
copy to benchmarks/netty3/pom.xml
index 2b8acd4..39abc14 100644
--- a/benchmarks2/pom.xml
+++ b/benchmarks/netty3/pom.xml
@@ -23,49 +23,27 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.mina</groupId>
- <artifactId>mina-parent</artifactId>
+ <artifactId>mina-benchmarks</artifactId>
<version>3.0.0-M3-SNAPSHOT</version>
</parent>
- <artifactId>mina-benchmarks2</artifactId>
- <groupId>org.apache.mina</groupId>
- <name>Apache MINA Benchmarks tests for Netty4</name>
-
- <properties>
- <!-- defined in order to run against a different MINA version -->
- <mina.version>${project.version}</mina.version>
- <netty.version>4.0.4.Final</netty.version>
- </properties>
+ <artifactId>mina-benchmarks-netty3</artifactId>
+ <name>Apache MINA Benchmarks against Netty3 tests</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>mina-core</artifactId>
+ <artifactId>mina-benchmarks-common</artifactId>
<scope>test</scope>
+ <type>test-jar</type>
</dependency>
<dependency>
<groupId>io.netty</groupId>
- <artifactId>netty-all</artifactId>
- <version>${netty.version}</version>
+ <artifactId>netty</artifactId>
+ <version>${netty3.version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skip>${benchmarks.skip}</skip>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
diff --git a/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java b/benchmarks/netty3/src/test/java/org/apache/mina/core/Mina3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
similarity index 87%
rename from benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
rename to benchmarks/netty3/src/test/java/org/apache/mina/core/Mina3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
index 7ce1769..077f695 100644
--- a/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
+++ b/benchmarks/netty3/src/test/java/org/apache/mina/core/Mina3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
@@ -22,7 +22,8 @@
import java.util.Arrays;
import java.util.Collection;
-import org.apache.mina.core.BenchmarkFactory.Type;
+import org.apache.mina.core.nio.tcp.Mina3TcpBenchmarkClient;
+import org.apache.mina.core.nio.tcp.Netty3TcpBenchmarkServer;
import org.junit.runners.Parameterized.Parameters;
/**
@@ -42,16 +43,16 @@
* {@inheritDoc}
*/
@Override
- public Type getClientType() {
- return Type.Mina3_tcp;
+ public BenchmarkClient getClient() {
+ return new Mina3TcpBenchmarkClient();
}
/**
* {@inheritDoc}
*/
@Override
- public Type getServerType() {
- return Type.Netty3_tcp;
+ public BenchmarkServer getServer() {
+ return new Netty3TcpBenchmarkServer();
}
@Parameters()
diff --git a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerTcpBenchmarkBinaryTest.java b/benchmarks/netty3/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
similarity index 87%
rename from benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
rename to benchmarks/netty3/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
index b93b799..4c30661 100644
--- a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
+++ b/benchmarks/netty3/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
@@ -22,7 +22,8 @@
import java.util.Arrays;
import java.util.Collection;
-import org.apache.mina.core.BenchmarkFactory.Type;
+import org.apache.mina.core.nio.tcp.Mina3TcpBenchmarkServer;
+import org.apache.mina.core.nio.tcp.Netty3TcpBenchmarkClient;
import org.junit.runners.Parameterized.Parameters;
/**
@@ -41,15 +42,15 @@
/** {@inheritDoc}
*/
@Override
- public Type getClientType() {
- return Type.Netty3_tcp;
+ public BenchmarkClient getClient() {
+ return new Netty3TcpBenchmarkClient();
}
/** {@inheritDoc}
*/
@Override
- public Type getServerType() {
- return Type.Mina3_tcp;
+ public BenchmarkServer getServer() {
+ return new Mina3TcpBenchmarkServer();
}
//TODO: analyze with Netty is so slow on large message: last test lower to 100 messages
diff --git a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerUdpBenchmarkBinaryTest.java b/benchmarks/netty3/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
similarity index 87%
rename from benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
rename to benchmarks/netty3/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
index 13b74ab..5a6e08d 100644
--- a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
+++ b/benchmarks/netty3/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
@@ -22,7 +22,8 @@
import java.util.Arrays;
import java.util.Collection;
-import org.apache.mina.core.BenchmarkFactory.Type;
+import org.apache.mina.core.nio.udp.Mina3UdpBenchmarkServer;
+import org.apache.mina.core.nio.udp.Netty3UdpBenchmarkClient;
import org.junit.runners.Parameterized.Parameters;
/**
@@ -41,15 +42,15 @@
/** {@inheritDoc}
*/
@Override
- public Type getClientType() {
- return Type.Netty3_udp;
+ public BenchmarkClient getClient() {
+ return new Netty3UdpBenchmarkClient();
}
/** {@inheritDoc}
*/
@Override
- public Type getServerType() {
- return Type.Mina3_udp;
+ public BenchmarkServer getServer() {
+ return new Mina3UdpBenchmarkServer();
}
@Parameters(name = "{0} messages of size {1}")
diff --git a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java b/benchmarks/netty3/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
similarity index 87%
rename from benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
rename to benchmarks/netty3/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
index 0ba293c..a0bccd6 100644
--- a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
+++ b/benchmarks/netty3/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
@@ -22,7 +22,8 @@
import java.util.Arrays;
import java.util.Collection;
-import org.apache.mina.core.BenchmarkFactory.Type;
+import org.apache.mina.core.nio.tcp.Netty3TcpBenchmarkClient;
+import org.apache.mina.core.nio.tcp.Netty3TcpBenchmarkServer;
import org.junit.runners.Parameterized.Parameters;
/**
@@ -41,15 +42,15 @@
/** {@inheritDoc}
*/
@Override
- public Type getClientType() {
- return Type.Netty3_tcp;
+ public BenchmarkClient getClient() {
+ return new Netty3TcpBenchmarkClient();
}
/** {@inheritDoc}
*/
@Override
- public Type getServerType() {
- return Type.Netty3_tcp;
+ public BenchmarkServer getServer() {
+ return new Netty3TcpBenchmarkServer();
}
//TODO: analyze with Netty is so slow on large message: last test lower to 100 messages
diff --git a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerUdpBenchmarkBinaryTest.java b/benchmarks/netty3/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerUdpBenchmarkBinaryTest.java
similarity index 87%
rename from benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerUdpBenchmarkBinaryTest.java
rename to benchmarks/netty3/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerUdpBenchmarkBinaryTest.java
index 5b0c74b..76d9bf8 100644
--- a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerUdpBenchmarkBinaryTest.java
+++ b/benchmarks/netty3/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerUdpBenchmarkBinaryTest.java
@@ -22,7 +22,8 @@
import java.util.Arrays;
import java.util.Collection;
-import org.apache.mina.core.BenchmarkFactory.Type;
+import org.apache.mina.core.nio.udp.Netty3UdpBenchmarkClient;
+import org.apache.mina.core.nio.udp.Netty3UdpBenchmarkServer;
import org.junit.runners.Parameterized.Parameters;
/**
@@ -41,15 +42,15 @@
/** {@inheritDoc}
*/
@Override
- public Type getClientType() {
- return Type.Netty3_udp;
+ public BenchmarkClient getClient() {
+ return new Netty3UdpBenchmarkClient();
}
/** {@inheritDoc}
*/
@Override
- public Type getServerType() {
- return Type.Netty3_udp;
+ public BenchmarkServer getServer() {
+ return new Netty3UdpBenchmarkServer();
}
@Parameters(name = "{0} messages of size {1}")
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkClient.java b/benchmarks/netty3/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkClient.java
similarity index 100%
rename from benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkClient.java
rename to benchmarks/netty3/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkClient.java
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkServer.java b/benchmarks/netty3/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkServer.java
similarity index 100%
rename from benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkServer.java
rename to benchmarks/netty3/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkServer.java
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkClient.java b/benchmarks/netty3/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkClient.java
similarity index 100%
rename from benchmarks/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkClient.java
rename to benchmarks/netty3/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkClient.java
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkServer.java b/benchmarks/netty3/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkServer.java
similarity index 95%
rename from benchmarks/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkServer.java
rename to benchmarks/netty3/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkServer.java
index 155da87..fa2d5c8 100644
--- a/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkServer.java
+++ b/benchmarks/netty3/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkServer.java
@@ -26,6 +26,7 @@
import java.util.Map;
import org.apache.mina.core.BenchmarkServer;
+import org.apache.mina.core.CounterFilter;
import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
@@ -39,6 +40,7 @@
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
+import org.jboss.netty.channel.WriteCompletionEvent;
import org.jboss.netty.channel.group.ChannelGroup;
import org.jboss.netty.channel.group.DefaultChannelGroup;
import org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory;
@@ -165,6 +167,11 @@
}
@Override
+ public void writeComplete(ChannelHandlerContext ctx, WriteCompletionEvent e) throws Exception {
+ CounterFilter.messageSent.getAndIncrement();
+ }
+
+ @Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
allChannels.remove(ctx.getChannel());
}
diff --git a/benchmarks2/pom.xml b/benchmarks/netty4/pom.xml
similarity index 63%
rename from benchmarks2/pom.xml
rename to benchmarks/netty4/pom.xml
index 2b8acd4..ef3b511 100644
--- a/benchmarks2/pom.xml
+++ b/benchmarks/netty4/pom.xml
@@ -23,49 +23,27 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.mina</groupId>
- <artifactId>mina-parent</artifactId>
+ <artifactId>mina-benchmarks</artifactId>
<version>3.0.0-M3-SNAPSHOT</version>
</parent>
- <artifactId>mina-benchmarks2</artifactId>
- <groupId>org.apache.mina</groupId>
- <name>Apache MINA Benchmarks tests for Netty4</name>
-
- <properties>
- <!-- defined in order to run against a different MINA version -->
- <mina.version>${project.version}</mina.version>
- <netty.version>4.0.4.Final</netty.version>
- </properties>
+ <artifactId>mina-benchmarks-netty4</artifactId>
+ <name>Apache MINA Benchmarks against Netty4 tests</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>mina-core</artifactId>
+ <artifactId>mina-benchmarks-common</artifactId>
<scope>test</scope>
+ <type>test-jar</type>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
- <version>${netty.version}</version>
+ <version>${netty4.version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skip>${benchmarks.skip}</skip>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
diff --git a/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4BenchmarkServer.java b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4BenchmarkServer.java
new file mode 100644
index 0000000..2b4b92e
--- /dev/null
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4BenchmarkServer.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.mina.core;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.util.AttributeKey;
+
+/**
+ * A Netty 4 Server.
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public abstract class Netty4BenchmarkServer implements BenchmarkServer {
+
+ protected static final AttributeKey<State> STATE_ATTRIBUTE = new AttributeKey<State>("state");
+
+ protected static final AttributeKey<Integer> LENGTH_ATTRIBUTE = new AttributeKey<Integer>("length");
+
+ protected static enum State {
+ WAIT_FOR_FIRST_BYTE_LENGTH, WAIT_FOR_SECOND_BYTE_LENGTH, WAIT_FOR_THIRD_BYTE_LENGTH, WAIT_FOR_FOURTH_BYTE_LENGTH, READING
+ }
+
+ protected static final ByteBuf ACK = Unpooled.buffer(1);
+
+ static {
+ ACK.writeByte(0);
+ }
+
+}
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerTcpBenchmarkBinaryTest.java b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerTcpBenchmarkBinaryTest.java
similarity index 88%
rename from benchmarks2/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerTcpBenchmarkBinaryTest.java
rename to benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerTcpBenchmarkBinaryTest.java
index e51f82c..80058e0 100644
--- a/benchmarks2/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerTcpBenchmarkBinaryTest.java
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerTcpBenchmarkBinaryTest.java
@@ -22,7 +22,8 @@
import java.util.Arrays;
import java.util.Collection;
-import org.apache.mina.core.BenchmarkFactory.Type;
+import org.apache.mina.core.nio.tcp.Mina3TcpBenchmarkServer;
+import org.apache.mina.core.nio.tcp.Netty4TcpBenchmarkClient;
import org.junit.runners.Parameterized.Parameters;
/**
@@ -43,15 +44,15 @@
/** {@inheritDoc}
*/
@Override
- public Type getClientType() {
- return Type.Netty4_tcp;
+ public BenchmarkClient getClient() {
+ return new Netty4TcpBenchmarkClient();
}
/** {@inheritDoc}
*/
@Override
- public Type getServerType() {
- return Type.Mina3_tcp;
+ public BenchmarkServer getServer() {
+ return new Mina3TcpBenchmarkServer();
}
//TODO: analyze with Netty is so slow on large message: last test lower to 100 messages
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerUdpBenchmarkBinaryTest.java b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerUdpBenchmarkBinaryTest.java
similarity index 87%
rename from benchmarks2/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerUdpBenchmarkBinaryTest.java
rename to benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerUdpBenchmarkBinaryTest.java
index d1a5217..c545447 100644
--- a/benchmarks2/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerUdpBenchmarkBinaryTest.java
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerUdpBenchmarkBinaryTest.java
@@ -22,7 +22,8 @@
import java.util.Arrays;
import java.util.Collection;
-import org.apache.mina.core.BenchmarkFactory.Type;
+import org.apache.mina.core.nio.udp.Mina3UdpBenchmarkServer;
+import org.apache.mina.core.nio.udp.Netty4UdpBenchmarkClient;
import org.junit.runners.Parameterized.Parameters;
/**
@@ -43,15 +44,15 @@
/** {@inheritDoc}
*/
@Override
- public Type getClientType() {
- return Type.Netty4_udp;
+ public BenchmarkClient getClient() {
+ return new Netty4UdpBenchmarkClient();
}
/** {@inheritDoc}
*/
@Override
- public Type getServerType() {
- return Type.Mina3_udp;
+ public BenchmarkServer getServer() {
+ return new Mina3UdpBenchmarkServer();
}
@Parameters(name = "{0} messages of size {1}")
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerTcpBenchmarkBinaryTest.java b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerTcpBenchmarkBinaryTest.java
similarity index 88%
rename from benchmarks2/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerTcpBenchmarkBinaryTest.java
rename to benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerTcpBenchmarkBinaryTest.java
index 03db99e..b109eec 100644
--- a/benchmarks2/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerTcpBenchmarkBinaryTest.java
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerTcpBenchmarkBinaryTest.java
@@ -22,7 +22,8 @@
import java.util.Arrays;
import java.util.Collection;
-import org.apache.mina.core.BenchmarkFactory.Type;
+import org.apache.mina.core.nio.tcp.Netty4TcpBenchmarkClient;
+import org.apache.mina.core.nio.tcp.Netty4TcpBenchmarkServer;
import org.junit.runners.Parameterized.Parameters;
/**
@@ -43,15 +44,15 @@
/** {@inheritDoc}
*/
@Override
- public Type getClientType() {
- return Type.Netty4_tcp;
+ public BenchmarkClient getClient() {
+ return new Netty4TcpBenchmarkClient();
}
/** {@inheritDoc}
*/
@Override
- public Type getServerType() {
- return Type.Netty4_tcp;
+ public BenchmarkServer getServer() {
+ return new Netty4TcpBenchmarkServer();
}
//TODO: analyze with Netty is so slow on large message: last test lower to 100 messages
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerUdpBenchmarkBinaryTest.java b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerUdpBenchmarkBinaryTest.java
similarity index 87%
rename from benchmarks2/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerUdpBenchmarkBinaryTest.java
rename to benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerUdpBenchmarkBinaryTest.java
index 7654549..daa87a7 100644
--- a/benchmarks2/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerUdpBenchmarkBinaryTest.java
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerUdpBenchmarkBinaryTest.java
@@ -22,7 +22,8 @@
import java.util.Arrays;
import java.util.Collection;
-import org.apache.mina.core.BenchmarkFactory.Type;
+import org.apache.mina.core.nio.udp.Netty4UdpBenchmarkClient;
+import org.apache.mina.core.nio.udp.Netty4UdpBenchmarkServer;
import org.junit.runners.Parameterized.Parameters;
/**
@@ -43,15 +44,15 @@
/** {@inheritDoc}
*/
@Override
- public Type getClientType() {
- return Type.Netty4_udp;
+ public BenchmarkClient getClient() {
+ return new Netty4UdpBenchmarkClient();
}
/** {@inheritDoc}
*/
@Override
- public Type getServerType() {
- return Type.Netty4_udp;
+ public BenchmarkServer getServer() {
+ return new Netty4UdpBenchmarkServer();
}
@Parameters(name = "{0} messages of size {1}")
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/nio/tcp/Netty4TcpBenchmarkClient.java b/benchmarks/netty4/src/test/java/org/apache/mina/core/nio/tcp/Netty4TcpBenchmarkClient.java
similarity index 100%
rename from benchmarks2/src/test/java/org/apache/mina/core/nio/tcp/Netty4TcpBenchmarkClient.java
rename to benchmarks/netty4/src/test/java/org/apache/mina/core/nio/tcp/Netty4TcpBenchmarkClient.java
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/nio/tcp/Netty4TcpBenchmarkServer.java b/benchmarks/netty4/src/test/java/org/apache/mina/core/nio/tcp/Netty4TcpBenchmarkServer.java
similarity index 88%
rename from benchmarks2/src/test/java/org/apache/mina/core/nio/tcp/Netty4TcpBenchmarkServer.java
rename to benchmarks/netty4/src/test/java/org/apache/mina/core/nio/tcp/Netty4TcpBenchmarkServer.java
index 13a8a78..c7f3f84 100644
--- a/benchmarks2/src/test/java/org/apache/mina/core/nio/tcp/Netty4TcpBenchmarkServer.java
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/nio/tcp/Netty4TcpBenchmarkServer.java
@@ -21,7 +21,6 @@
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
@@ -31,31 +30,16 @@
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.util.Attribute;
-import io.netty.util.AttributeKey;
import java.io.IOException;
-import org.apache.mina.core.BenchmarkServer;
+import org.apache.mina.core.Netty4BenchmarkServer;
/**
- * A Netty 3 TCP Server.
+ * A Netty 4 TCP Server.
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
-public class Netty4TcpBenchmarkServer implements BenchmarkServer {
-
- private static enum State {
- WAIT_FOR_FIRST_BYTE_LENGTH, WAIT_FOR_SECOND_BYTE_LENGTH, WAIT_FOR_THIRD_BYTE_LENGTH, WAIT_FOR_FOURTH_BYTE_LENGTH, READING
- }
-
- private static final ByteBuf ACK = Unpooled.buffer(1);
-
- static {
- ACK.writeByte(0);
- }
-
- private static final AttributeKey<State> STATE_ATTRIBUTE = new AttributeKey<State>("state");
-
- private static final AttributeKey<Integer> LENGTH_ATTRIBUTE = new AttributeKey<Integer>("length");
+public class Netty4TcpBenchmarkServer extends Netty4BenchmarkServer {
private ServerBootstrap bootstrap = null;
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkClient.java b/benchmarks/netty4/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkClient.java
similarity index 98%
rename from benchmarks2/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkClient.java
rename to benchmarks/netty4/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkClient.java
index 267dffb..cc2ae09 100644
--- a/benchmarks2/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkClient.java
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkClient.java
@@ -37,7 +37,7 @@
import org.apache.mina.core.BenchmarkClient;
/**
- * A Netty 3 based UDP client
+ * A Netty 4 based UDP client
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
public class Netty4UdpBenchmarkClient implements BenchmarkClient {
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkServer.java b/benchmarks/netty4/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkServer.java
similarity index 88%
rename from benchmarks2/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkServer.java
rename to benchmarks/netty4/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkServer.java
index be1c625..c21ba76 100644
--- a/benchmarks2/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkServer.java
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkServer.java
@@ -20,9 +20,7 @@
package org.apache.mina.core.nio.udp;
import io.netty.bootstrap.Bootstrap;
-import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
@@ -32,31 +30,17 @@
import io.netty.channel.socket.DatagramPacket;
import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.util.Attribute;
-import io.netty.util.AttributeKey;
import java.io.IOException;
-import org.apache.mina.core.BenchmarkServer;
+
+import org.apache.mina.core.Netty4BenchmarkServer;
/**
- * A Netty 3 based UDP server
+ * A Netty 4 based UDP server
*
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
-public class Netty4UdpBenchmarkServer implements BenchmarkServer {
-
- private static enum State {
- WAIT_FOR_FIRST_BYTE_LENGTH, WAIT_FOR_SECOND_BYTE_LENGTH, WAIT_FOR_THIRD_BYTE_LENGTH, WAIT_FOR_FOURTH_BYTE_LENGTH, READING
- }
-
- private static final ByteBuf ACK = Unpooled.buffer(1);
-
- private static final AttributeKey<State> STATE_ATTRIBUTE = new AttributeKey<State>("state");
-
- private static final AttributeKey<Integer> LENGTH_ATTRIBUTE = new AttributeKey<Integer>("length");
-
- static {
- ACK.writeByte(0);
- }
+public class Netty4UdpBenchmarkServer extends Netty4BenchmarkServer {
private Bootstrap bootstrap;
diff --git a/benchmarks/pom.xml b/benchmarks/pom.xml
index ccbc515..2992e72 100644
--- a/benchmarks/pom.xml
+++ b/benchmarks/pom.xml
@@ -28,15 +28,22 @@
</parent>
<artifactId>mina-benchmarks</artifactId>
- <groupId>org.apache.mina</groupId>
<name>Apache MINA Benchmarks tests</name>
+ <packaging>pom</packaging>
<properties>
<!-- defined in order to run against a different MINA version -->
<mina.version>${project.version}</mina.version>
<netty3.version>3.6.6.Final</netty3.version>
+ <netty4.version>4.0.4.Final</netty4.version>
</properties>
+ <modules>
+ <module>common</module>
+ <module>netty3</module>
+ <module>netty4</module>
+ </modules>
+
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
@@ -45,13 +52,6 @@
</dependency>
<dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty</artifactId>
- <version>${netty3.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>test</scope>
diff --git a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkClientFactory.java b/benchmarks/src/test/java/org/apache/mina/core/BenchmarkClientFactory.java
deleted file mode 100644
index 1bfc492..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkClientFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.mina.core;
-
-import org.apache.mina.core.bio.udp.BioUdpBenchmarkClient;
-import org.apache.mina.core.nio.tcp.Mina3TcpBenchmarkClient;
-import org.apache.mina.core.nio.tcp.Netty3TcpBenchmarkClient;
-import org.apache.mina.core.nio.udp.Mina3UdpBenchmarkClient;
-import org.apache.mina.core.nio.udp.Netty3UdpBenchmarkClient;
-
-/**
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class BenchmarkClientFactory implements BenchmarkFactory<BenchmarkClient> {
-
- public static final BenchmarkClientFactory INSTANCE = new BenchmarkClientFactory();
-
- public BenchmarkClient get(Type type) {
- switch (type) {
- case Mina3_tcp:
- return new Mina3TcpBenchmarkClient();
- case Mina3_udp:
- return new Mina3UdpBenchmarkClient();
- case Netty3_tcp:
- return new Netty3TcpBenchmarkClient();
- case Netty3_udp:
- return new Netty3UdpBenchmarkClient();
- case Bio_tcp:
- //return new BioTcpBenchmarkClient();
- case Bio_udp:
- return new BioUdpBenchmarkClient();
- default:
- throw new IllegalArgumentException("Invalid type " + type);
- }
- }
-}
diff --git a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkFactory.java b/benchmarks/src/test/java/org/apache/mina/core/BenchmarkFactory.java
deleted file mode 100644
index 7ade3b6..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkFactory.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.mina.core;
-
-/**
- * Common interface for client and server factories
- *
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public interface BenchmarkFactory<T> {
- /**
- * The different types of providers
- */
- public enum Type {
- Mina3_tcp, Mina3_udp, Netty3_tcp, Netty3_udp, Netty4_tcp, Netty4_udp, Bio_tcp, Bio_udp
- }
-
- /**
- * Allocate a provider.
- *
- * @param type the provider type
- * @return the allocated provider
- */
- public T get(Type type);
-}
diff --git a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkServerFactory.java b/benchmarks/src/test/java/org/apache/mina/core/BenchmarkServerFactory.java
deleted file mode 100644
index 21eeb0f..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkServerFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.mina.core;
-
-import org.apache.mina.core.bio.udp.BioUdpBenchmarkServer;
-import org.apache.mina.core.nio.tcp.Mina3TcpBenchmarkServer;
-import org.apache.mina.core.nio.tcp.Netty3TcpBenchmarkServer;
-import org.apache.mina.core.nio.udp.Mina3UdpBenchmarkServer;
-import org.apache.mina.core.nio.udp.Netty3UdpBenchmarkServer;
-
-/**
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class BenchmarkServerFactory implements BenchmarkFactory<BenchmarkServer> {
-
- public static final BenchmarkServerFactory INSTANCE = new BenchmarkServerFactory();
-
- /**
- * {@inheritedDoc}
- */
- public BenchmarkServer get(org.apache.mina.core.BenchmarkFactory.Type type) {
- switch (type) {
- case Mina3_tcp:
- return new Mina3TcpBenchmarkServer();
- case Mina3_udp:
- return new Mina3UdpBenchmarkServer();
- case Netty3_tcp:
- return new Netty3TcpBenchmarkServer();
- case Netty3_udp:
- return new Netty3UdpBenchmarkServer();
- case Bio_udp:
- return new BioUdpBenchmarkServer();
- case Bio_tcp:
- //return new BioUdpBenchmarkClient();
- default:
- throw new IllegalArgumentException("Invalid type " + type);
- }
- }
-}
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java b/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
deleted file mode 100644
index 7b9c8ff..0000000
--- a/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.mina.core;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.NoSuchElementException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.mina.core.BenchmarkFactory.Type;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-@RunWith(Parameterized.class)
-public abstract class BenchmarkBinaryTest {
- private int numberOfMessages;
-
- private int port;
-
- private BenchmarkServer server;
-
- private BenchmarkClient client;
-
- private int messageSize;
-
- private int timeout;
-
- private byte[] data;
-
- public BenchmarkBinaryTest(int numberOfMessages, int messageSize, int timeout) {
- this.numberOfMessages = numberOfMessages;
- this.messageSize = messageSize;
- this.timeout = timeout;
- }
-
- public abstract Type getClientType();
-
- public abstract Type getServerType();
-
- @Parameters(name = "{0} messages of size {1}")
- public static Collection<Object[]> getParameters() {
- Object[][] parameters = new Object[][] { { 100000, 10, 2 * 60 }, { 100000, 1 * 1024, 2 * 60 },
- { 100000, 10 * 1024, 2 * 60 }, { 100, 64 * 1024 * 1024, 10 * 60 } };
- return Arrays.asList(parameters);
- }
-
- public static int getNextAvailable() {
- ServerSocket serverSocket = null;
-
- try {
- // Here, we simply return an available port found by the system
- serverSocket = new ServerSocket(0);
- int port = serverSocket.getLocalPort();
-
- // Don't forget to close the socket...
- serverSocket.close();
-
- return port;
- } catch (IOException ioe) {
- throw new NoSuchElementException(ioe.getMessage());
- }
- }
-
- @Before
- public void init() throws IOException {
- port = getNextAvailable();
- server = BenchmarkServerFactory.INSTANCE.get(getServerType());
- server.start(port);
- client = BenchmarkClientFactory.INSTANCE.get(getClientType());
- data = new byte[messageSize + 4];
- data[0] = (byte) (messageSize >>> 24 & 255);
- data[1] = (byte) (messageSize >>> 16 & 255);
- data[2] = (byte) (messageSize >>> 8 & 255);
- data[3] = (byte) (messageSize & 255);
- }
-
- @After
- public void shutdown() throws IOException {
- client.stop();
- server.stop();
- }
-
- /**
- * Send "numberOfMessages" messages to a server. Currently, 1 million, with two different
- * size, 10Ko and 64Ko.
- */
- @Test
- public void benchmark() throws IOException, InterruptedException {
- CountDownLatch counter = new CountDownLatch(numberOfMessages);
-
- client.start(port, counter, data);
- boolean result = counter.await(timeout, TimeUnit.SECONDS);
- assertTrue("Still " + counter.getCount() + " messages to send on a total of " + numberOfMessages, result);
- }
-}
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkClient.java b/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkClient.java
deleted file mode 100644
index 393eea6..0000000
--- a/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkClient.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.mina.core;
-
-import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
-
-/**
- * An interface for a server
- *
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public interface BenchmarkClient {
- /** Starts the client */
- public void start(int port, CountDownLatch counter, byte[] data) throws IOException;
-
- /** Stops the client */
- public void stop() throws IOException;
-}
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkClientFactory.java b/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkClientFactory.java
deleted file mode 100644
index ecf00f7..0000000
--- a/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkClientFactory.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.mina.core;
-
-import org.apache.mina.core.nio.tcp.Netty4TcpBenchmarkClient;
-import org.apache.mina.core.nio.udp.Netty4UdpBenchmarkClient;
-
-/**
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class BenchmarkClientFactory implements BenchmarkFactory<BenchmarkClient> {
-
- public static final BenchmarkClientFactory INSTANCE = new BenchmarkClientFactory();
-
- public BenchmarkClient get(Type type) {
- switch (type) {
- case Netty4_tcp:
- return new Netty4TcpBenchmarkClient();
- case Netty4_udp:
- return new Netty4UdpBenchmarkClient();
- default:
- throw new IllegalArgumentException("Invalid type " + type);
- }
- }
-}
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkFactory.java b/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkFactory.java
deleted file mode 100644
index 1db23ad..0000000
--- a/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkFactory.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.mina.core;
-
-/**
- * Common interface for client and server factories
- *
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public interface BenchmarkFactory<T> {
- /**
- * The different types of providers
- */
- public enum Type {
- Mina3_udp, Mina3_tcp, Netty4_tcp, Netty4_udp
- }
-
- /**
- * Allocate a provider.
- *
- * @param type the provider type
- * @return the allocated provider
- */
- public T get(Type type);
-}
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkServer.java b/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkServer.java
deleted file mode 100644
index d4652e3..0000000
--- a/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkServer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.mina.core;
-
-import java.io.IOException;
-
-/**
- * An interface for a server
- *
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public interface BenchmarkServer {
- /** Starts the server */
- public void start(int port) throws IOException;
-
- /** Stops the server */
- public void stop() throws IOException;
-}
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkServerFactory.java b/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkServerFactory.java
deleted file mode 100644
index 686c30f..0000000
--- a/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkServerFactory.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.mina.core;
-
-import org.apache.mina.core.nio.tcp.Mina3TcpBenchmarkServer;
-import org.apache.mina.core.nio.tcp.Netty4TcpBenchmarkServer;
-import org.apache.mina.core.nio.udp.Mina3UdpBenchmarkServer;
-import org.apache.mina.core.nio.udp.Netty4UdpBenchmarkServer;
-
-/**
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class BenchmarkServerFactory implements BenchmarkFactory<BenchmarkServer> {
-
- public static final BenchmarkServerFactory INSTANCE = new BenchmarkServerFactory();
-
- /**
- * {@inheritedDoc}
- */
- public BenchmarkServer get(org.apache.mina.core.BenchmarkFactory.Type type) {
- switch (type) {
- case Mina3_tcp:
- return new Mina3TcpBenchmarkServer();
- case Mina3_udp:
- return new Mina3UdpBenchmarkServer();
- case Netty4_tcp:
- return new Netty4TcpBenchmarkServer();
- case Netty4_udp:
- return new Netty4UdpBenchmarkServer();
- default:
- throw new IllegalArgumentException("Invalid type " + type);
- }
- }
-}
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkServer.java b/benchmarks2/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkServer.java
deleted file mode 100644
index 7ace829..0000000
--- a/benchmarks2/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkServer.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.mina.core.nio.tcp;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-
-import org.apache.mina.api.IdleStatus;
-import org.apache.mina.api.IoHandler;
-import org.apache.mina.api.IoService;
-import org.apache.mina.api.IoSession;
-import org.apache.mina.core.BenchmarkServer;
-import org.apache.mina.session.AttributeKey;
-import org.apache.mina.transport.nio.NioTcpServer;
-
-/**
- * A MINA 3 TCP Server.
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class Mina3TcpBenchmarkServer implements BenchmarkServer {
-
- private static enum State {
- WAIT_FOR_FIRST_BYTE_LENGTH, WAIT_FOR_SECOND_BYTE_LENGTH, WAIT_FOR_THIRD_BYTE_LENGTH, WAIT_FOR_FOURTH_BYTE_LENGTH, READING
- }
-
- private static final ByteBuffer ACK = ByteBuffer.allocate(1);
-
- static {
- ACK.put((byte) 0);
- ACK.rewind();
- }
-
- private static final AttributeKey<State> STATE_ATTRIBUTE = new AttributeKey<State>(State.class,
- Mina3TcpBenchmarkServer.class.getName() + ".state");
-
- private static final AttributeKey<Integer> LENGTH_ATTRIBUTE = new AttributeKey<Integer>(Integer.class,
- Mina3TcpBenchmarkServer.class.getName() + ".length");
-
- private NioTcpServer tcpServer;
-
- /**
- * {@inheritDoc}
- */
- public void start(int port) throws IOException {
- tcpServer = new NioTcpServer();
- tcpServer.getSessionConfig().setReadBufferSize(128 * 1024);
- tcpServer.getSessionConfig().setTcpNoDelay(true);
- tcpServer.setIoHandler(new IoHandler() {
- public void sessionOpened(IoSession session) {
- session.setAttribute(STATE_ATTRIBUTE, State.WAIT_FOR_FIRST_BYTE_LENGTH);
- }
-
- public void messageReceived(IoSession session, Object message) {
- if (message instanceof ByteBuffer) {
- ByteBuffer buffer = (ByteBuffer) message;
-
- State state = session.getAttribute(STATE_ATTRIBUTE);
- int length = 0;
-
- if (session.getAttribute(LENGTH_ATTRIBUTE) != null) {
- length = session.getAttribute(LENGTH_ATTRIBUTE);
- }
-
- while (buffer.remaining() > 0) {
- switch (state) {
- case WAIT_FOR_FIRST_BYTE_LENGTH:
- length = (buffer.get() & 255) << 24;
- state = State.WAIT_FOR_SECOND_BYTE_LENGTH;
- break;
- case WAIT_FOR_SECOND_BYTE_LENGTH:
- length += (buffer.get() & 255) << 16;
- state = State.WAIT_FOR_THIRD_BYTE_LENGTH;
- break;
- case WAIT_FOR_THIRD_BYTE_LENGTH:
- length += (buffer.get() & 255) << 8;
- state = State.WAIT_FOR_FOURTH_BYTE_LENGTH;
- break;
- case WAIT_FOR_FOURTH_BYTE_LENGTH:
- length += (buffer.get() & 255);
- state = State.READING;
- if ((length == 0) && (buffer.remaining() == 0)) {
- session.write(ACK.slice());
- state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
- }
- break;
- case READING:
- int remaining = buffer.remaining();
- if (length > remaining) {
- length -= remaining;
- buffer.position(buffer.position() + remaining);
- } else {
- buffer.position(buffer.position() + length);
- session.write(ACK.slice());
- state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
- length = 0;
- }
- }
- }
- session.setAttribute(LENGTH_ATTRIBUTE, length);
- session.setAttribute(STATE_ATTRIBUTE, state);
- }
- }
-
- public void exceptionCaught(IoSession session, Exception cause) {
- cause.printStackTrace();
- }
-
- @Override
- public void sessionClosed(IoSession session) {
- }
-
- @Override
- public void sessionIdle(IoSession session, IdleStatus status) {
- }
-
- @Override
- public void messageSent(IoSession session, Object message) {
- }
-
- @Override
- public void serviceActivated(IoService service) {
- }
-
- @Override
- public void serviceInactivated(IoService service) {
- }
- });
-
- tcpServer.bind(new InetSocketAddress(port));
- }
-
- /**
- * {@inheritedDoc}
- */
- public void stop() throws IOException {
- tcpServer.unbind();
- }
-}
diff --git a/benchmarks2/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkServer.java b/benchmarks2/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkServer.java
deleted file mode 100644
index 48b84b8..0000000
--- a/benchmarks2/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkServer.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.mina.core.nio.udp;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-
-import org.apache.mina.api.IdleStatus;
-import org.apache.mina.api.IoHandler;
-import org.apache.mina.api.IoService;
-import org.apache.mina.api.IoSession;
-import org.apache.mina.core.BenchmarkServer;
-import org.apache.mina.session.AttributeKey;
-import org.apache.mina.transport.nio.NioUdpServer;
-import org.apache.mina.transport.udp.DefaultUdpSessionConfig;
-import org.apache.mina.transport.udp.UdpSessionConfig;
-
-/**
- * A MINA 3 based UDP server
- *
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class Mina3UdpBenchmarkServer implements BenchmarkServer {
-
- private static enum State {
- WAIT_FOR_FIRST_BYTE_LENGTH, WAIT_FOR_SECOND_BYTE_LENGTH, WAIT_FOR_THIRD_BYTE_LENGTH, WAIT_FOR_FOURTH_BYTE_LENGTH, READING
- }
-
- private static final ByteBuffer ACK = ByteBuffer.allocate(1);
-
- static {
- ACK.put((byte) 0);
- ACK.rewind();
- }
-
- private static final AttributeKey<State> STATE_ATTRIBUTE = new AttributeKey<State>(State.class,
- Mina3UdpBenchmarkServer.class.getName() + ".state");
-
- private static final AttributeKey<Integer> LENGTH_ATTRIBUTE = new AttributeKey<Integer>(Integer.class,
- Mina3UdpBenchmarkServer.class.getName() + ".length");
-
- private NioUdpServer udpServer;
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void start(int port) throws IOException {
- UdpSessionConfig config = new DefaultUdpSessionConfig();
- config.setReadBufferSize(65536);
- udpServer = new NioUdpServer(config);
- udpServer.setIoHandler(new IoHandler() {
- @Override
- public void sessionOpened(IoSession session) {
- session.setAttribute(STATE_ATTRIBUTE, State.WAIT_FOR_FIRST_BYTE_LENGTH);
- }
-
- @Override
- public void messageReceived(IoSession session, Object message) {
- //System.out.println("Server Message received : " + message);
- if (message instanceof ByteBuffer) {
- ByteBuffer buffer = (ByteBuffer) message;
-
- State state = session.getAttribute(STATE_ATTRIBUTE);
- int length = 0;
-
- if (session.getAttribute(LENGTH_ATTRIBUTE) != null) {
- length = session.getAttribute(LENGTH_ATTRIBUTE);
- }
-
- while (buffer.remaining() > 0) {
- switch (state) {
- case WAIT_FOR_FIRST_BYTE_LENGTH:
- length = (buffer.get() & 255) << 24;
- state = State.WAIT_FOR_SECOND_BYTE_LENGTH;
- break;
- case WAIT_FOR_SECOND_BYTE_LENGTH:
- length += (buffer.get() & 255) << 16;
- state = State.WAIT_FOR_THIRD_BYTE_LENGTH;
- break;
- case WAIT_FOR_THIRD_BYTE_LENGTH:
- length += (buffer.get() & 255) << 8;
- state = State.WAIT_FOR_FOURTH_BYTE_LENGTH;
- break;
- case WAIT_FOR_FOURTH_BYTE_LENGTH:
- length += (buffer.get() & 255);
- state = State.READING;
- if ((length == 0) && (buffer.remaining() == 0)) {
- session.write(ACK.slice());
- state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
- }
- break;
- case READING:
- int remaining = buffer.remaining();
- if (length > remaining) {
- length -= remaining;
- buffer.position(buffer.position() + remaining);
- } else {
- buffer.position(buffer.position() + length);
- session.write(ACK.slice());
- state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
- length = 0;
- }
- }
- }
- session.setAttribute(LENGTH_ATTRIBUTE, length);
- session.setAttribute(STATE_ATTRIBUTE, state);
- }
- }
-
- @Override
- public void exceptionCaught(IoSession session, Exception cause) {
- cause.printStackTrace();
- }
-
- @Override
- public void sessionClosed(IoSession session) {
- }
-
- @Override
- public void sessionIdle(IoSession session, IdleStatus status) {
- }
-
- @Override
- public void messageSent(IoSession session, Object message) {
- //System.out.println("Server message sent :" + message);
- }
-
- @Override
- public void serviceActivated(IoService service) {
- }
-
- @Override
- public void serviceInactivated(IoService service) {
- }
- });
-
- udpServer.bind(new InetSocketAddress(port));
- }
-
- /**
- * {@inheritedDoc}
- */
- @Override
- public void stop() throws IOException {
- udpServer.unbind();
- }
-}
diff --git a/benchmarks2/src/test/resources/log4j.properties b/benchmarks2/src/test/resources/log4j.properties
deleted file mode 100644
index 696da6e..0000000
--- a/benchmarks2/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#############################################################################
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-#############################################################################
-log4j.rootCategory=DEBUG, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n
-
-
diff --git a/monitoring/pom.xml b/monitoring/pom.xml
index 92fc945..bc37a30 100644
--- a/monitoring/pom.xml
+++ b/monitoring/pom.xml
@@ -57,12 +57,6 @@
<scope>test</scope>
<version>1.7.5</version>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.7.5</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/pom.xml b/pom.xml
index 5bdaefd..a962419 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,7 +90,7 @@
<properties>
<!-- Dependencies versions ========================================== -->
<version.junit>4.11</version.junit>
- <version.log4j>2.0-beta9</version.log4j>
+ <version.log4j>2.0-rc1</version.log4j>
<version.mockito-core>1.9.5</version.mockito-core>
<version.slf4j.api>1.7.5</version.slf4j.api>
@@ -115,10 +115,9 @@
<module>coap</module>
<module>thrift</module>
<module>protobuf</module>
- <module>benchmarks</module>
- <module>benchmarks2</module>
<module>avro</module>
<module>monitoring</module>
+ <module>benchmarks</module>
</modules>
<dependencyManagement>
@@ -156,6 +155,14 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mina-benchmarks-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>