mina-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeffma...@apache.org
Subject [3/4] Refactor benchmark tests in single multi module to be more DRY oriented
Date Fri, 16 May 2014 09:09:27 GMT
http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/netty3/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkServer.java
----------------------------------------------------------------------
diff --git a/benchmarks/netty3/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
new file mode 100644
index 0000000..653bb76
--- /dev/null
+++ b/benchmarks/netty3/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkServer.java
@@ -0,0 +1,194 @@
+/*
+ *  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.util.HashMap;
+import java.util.Map;
+
+import org.apache.mina.core.BenchmarkServer;
+import org.apache.mina.core.CounterFilter;
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.jboss.netty.channel.ChannelFactory;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.channel.ChannelStateEvent;
+import org.jboss.netty.channel.Channels;
+import org.jboss.netty.channel.ChildChannelStateEvent;
+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.NioServerSocketChannelFactory;
+
+/**
+ * A Netty 3 TCP Server.
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Netty3TcpBenchmarkServer 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 ChannelBuffer ACK = ChannelBuffers.buffer(1);
+
+    static {
+        ACK.writeByte(0);
+    }
+
+    private static final String STATE_ATTRIBUTE = Netty3TcpBenchmarkServer.class.getName() + ".state";
+
+    private static final String LENGTH_ATTRIBUTE = Netty3TcpBenchmarkServer.class.getName() + ".length";
+
+    private ChannelFactory factory;
+
+    private ChannelGroup allChannels = new DefaultChannelGroup();
+
+    /**
+     * Allocate a map as attachment for storing attributes.
+     * 
+     * @param ctx the channel context
+     * @return the map from the attachment
+     */
+    protected static Map<String, Object> getAttributesMap(ChannelHandlerContext ctx) {
+        Map<String, Object> map = (Map<String, Object>) ctx.getAttachment();
+        if (map == null) {
+            map = new HashMap<String, Object>();
+            ctx.setAttachment(map);
+        }
+        return map;
+    }
+
+    private static void setAttribute(ChannelHandlerContext ctx, String name, Object value) {
+        getAttributesMap(ctx).put(name, value);
+    }
+
+    private static Object getAttribute(ChannelHandlerContext ctx, String name) {
+        return getAttributesMap(ctx).get(name);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void start(int port) throws IOException {
+        factory = new NioServerSocketChannelFactory();
+        ServerBootstrap bootstrap = new ServerBootstrap(factory);
+        bootstrap.setOption("receiveBufferSize", 128 * 1024);
+        bootstrap.setOption("tcpNoDelay", true);
+        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
+            public ChannelPipeline getPipeline() throws Exception {
+                return Channels.pipeline(new SimpleChannelUpstreamHandler() {
+                    @Override
+                    public void childChannelOpen(ChannelHandlerContext ctx, ChildChannelStateEvent e) throws Exception {
+                        System.out.println("childChannelOpen");
+                        setAttribute(ctx, STATE_ATTRIBUTE, State.WAIT_FOR_FIRST_BYTE_LENGTH);
+                    }
+
+                    @Override
+                    public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
+                        System.out.println("channelOpen");
+                        setAttribute(ctx, STATE_ATTRIBUTE, State.WAIT_FOR_FIRST_BYTE_LENGTH);
+                        allChannels.add(ctx.getChannel());
+                    }
+
+                    public void writeComplete(ChannelHandlerContext ctx, WriteCompletionEvent e) throws Exception {
+                        CounterFilter.messageSent.getAndIncrement();
+                    }
+
+                    @Override
+                    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
+                        if (e.getMessage() instanceof ChannelBuffer) {
+                            ChannelBuffer buffer = (ChannelBuffer) e.getMessage();
+
+                            State state = (State) getAttribute(ctx, STATE_ATTRIBUTE);
+                            int length = 0;
+                            if (getAttributesMap(ctx).containsKey(LENGTH_ATTRIBUTE)) {
+                                length = (Integer) getAttribute(ctx, LENGTH_ATTRIBUTE);
+                            }
+                            while (buffer.readableBytes() > 0) {
+                                switch (state) {
+                                case WAIT_FOR_FIRST_BYTE_LENGTH:
+                                    length = (buffer.readByte() & 255) << 24;
+                                    state = State.WAIT_FOR_SECOND_BYTE_LENGTH;
+                                    break;
+                                case WAIT_FOR_SECOND_BYTE_LENGTH:
+                                    length += (buffer.readByte() & 255) << 16;
+                                    state = State.WAIT_FOR_THIRD_BYTE_LENGTH;
+                                    break;
+                                case WAIT_FOR_THIRD_BYTE_LENGTH:
+                                    length += (buffer.readByte() & 255) << 8;
+                                    state = State.WAIT_FOR_FOURTH_BYTE_LENGTH;
+                                    break;
+                                case WAIT_FOR_FOURTH_BYTE_LENGTH:
+                                    length += (buffer.readByte() & 255);
+                                    state = State.READING;
+                                    if ((length == 0) && (buffer.readableBytes() == 0)) {
+                                        ctx.getChannel().write(ACK.slice());
+                                        state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
+                                    }
+                                    break;
+                                case READING:
+                                    int remaining = buffer.readableBytes();
+                                    if (length > remaining) {
+                                        length -= remaining;
+                                        buffer.skipBytes(remaining);
+                                    } else {
+                                        buffer.skipBytes(length);
+                                        ctx.getChannel().write(ACK.slice());
+                                        state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
+                                        length = 0;
+                                    }
+                                }
+                            }
+                            setAttribute(ctx, STATE_ATTRIBUTE, state);
+                            setAttribute(ctx, LENGTH_ATTRIBUTE, length);
+                        }
+                    }
+
+                    @Override
+                    public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
+                        allChannels.remove(ctx.getChannel());
+                    }
+
+                    @Override
+                    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
+                        e.getCause().printStackTrace();
+                    }
+                });
+            }
+        });
+        allChannels.add(bootstrap.bind(new InetSocketAddress(port)));
+    }
+
+    /**
+     * {@inheritedDoc}
+     */
+    public void stop() throws IOException {
+        allChannels.disconnect().awaitUninterruptibly();
+        factory.releaseExternalResources();
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/netty3/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkClient.java
----------------------------------------------------------------------
diff --git a/benchmarks/netty3/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
new file mode 100644
index 0000000..ebc92e8
--- /dev/null
+++ b/benchmarks/netty3/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkClient.java
@@ -0,0 +1,106 @@
+/*
+ *  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.util.concurrent.CountDownLatch;
+
+import org.apache.mina.core.BenchmarkClient;
+import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.jboss.netty.channel.ChannelFactory;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.channel.ChannelStateEvent;
+import org.jboss.netty.channel.Channels;
+import org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory;
+import org.jboss.netty.channel.MessageEvent;
+import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
+import org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory;
+
+/**
+ * A Netty 3 based UDP client
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Netty3UdpBenchmarkClient implements BenchmarkClient {
+
+    private ChannelFactory factory;
+
+    /**
+     * 
+     */
+    public Netty3UdpBenchmarkClient() {
+    }
+
+    /**
+     * {@inheritedDoc}
+     */
+    public void start(final int port, final CountDownLatch counter, final byte[] data) throws IOException {
+        factory = new NioDatagramChannelFactory();
+        ConnectionlessBootstrap bootstrap = new ConnectionlessBootstrap(factory);
+        bootstrap.setOption("sendBufferSize", 65536);
+        bootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(9000));
+        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
+            public ChannelPipeline getPipeline() throws Exception {
+                return Channels.pipeline(new SimpleChannelUpstreamHandler() {
+                    private void sendMessage(ChannelHandlerContext ctx, byte[] data) {
+                        ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(data);
+                        ctx.getChannel().write(buffer);
+                    }
+
+                    @Override
+                    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
+                        if (e.getMessage() instanceof ChannelBuffer) {
+                            ChannelBuffer buffer = (ChannelBuffer) e.getMessage();
+                            for (int i = 0; i < buffer.readableBytes(); ++i) {
+                                counter.countDown();
+                                if (counter.getCount() > 0) {
+                                    sendMessage(ctx, data);
+                                } else {
+                                    ctx.getChannel().close();
+                                }
+                            }
+                        } else {
+                            throw new IllegalArgumentException(e.getMessage().getClass().getName());
+                        }
+                    }
+
+                    @Override
+                    public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
+                        sendMessage(ctx, data);
+                    }
+
+                });
+            }
+        });
+        bootstrap.connect(new InetSocketAddress(port));
+    }
+
+    /**
+     * {@inheritedDoc}
+     */
+    public void stop() throws IOException {
+        factory.shutdown();
+        factory.releaseExternalResources();
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/netty3/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkServer.java
----------------------------------------------------------------------
diff --git a/benchmarks/netty3/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
new file mode 100644
index 0000000..fa2d5c8
--- /dev/null
+++ b/benchmarks/netty3/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkServer.java
@@ -0,0 +1,197 @@
+/*
+ *  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.net.SocketAddress;
+import java.util.HashMap;
+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;
+import org.jboss.netty.channel.ChannelFactory;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.channel.ChannelStateEvent;
+import org.jboss.netty.channel.Channels;
+import org.jboss.netty.channel.ChildChannelStateEvent;
+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;
+
+/**
+ * A Netty 3 based UDP server
+ * 
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Netty3UdpBenchmarkServer 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 ChannelBuffer ACK = ChannelBuffers.buffer(1);
+
+    static {
+        ACK.writeByte(0);
+    }
+
+    private static final String STATE_ATTRIBUTE = Netty3UdpBenchmarkServer.class.getName() + ".state";
+
+    private static final String LENGTH_ATTRIBUTE = Netty3UdpBenchmarkServer.class.getName() + ".length";
+
+    private ChannelFactory factory;
+
+    private ChannelGroup allChannels = new DefaultChannelGroup();
+
+    /**
+     * Allocate a map as attachment for storing attributes.
+     * 
+     * @param ctx the channel context
+     * @return the map from the attachment
+     */
+    protected static Map<String, Object> getAttributesMap(ChannelHandlerContext ctx) {
+        Map<String, Object> map = (Map<String, Object>) ctx.getAttachment();
+        if (map == null) {
+            map = new HashMap<String, Object>();
+            ctx.setAttachment(map);
+        }
+        return map;
+    }
+
+    private static void setAttribute(ChannelHandlerContext ctx, String name, Object value) {
+        getAttributesMap(ctx).put(name, value);
+    }
+
+    private static Object getAttribute(ChannelHandlerContext ctx, String name) {
+        return getAttributesMap(ctx).get(name);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void start(int port) throws IOException {
+        factory = new NioDatagramChannelFactory();
+        ConnectionlessBootstrap bootstrap = new ConnectionlessBootstrap(factory);
+        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
+            public ChannelPipeline getPipeline() throws Exception {
+                return Channels.pipeline(new SimpleChannelUpstreamHandler() {
+                    @Override
+                    public void childChannelOpen(ChannelHandlerContext ctx, ChildChannelStateEvent e) throws Exception {
+                        System.out.println("childChannelOpen");
+                        setAttribute(ctx, STATE_ATTRIBUTE, State.WAIT_FOR_FIRST_BYTE_LENGTH);
+                    }
+
+                    @Override
+                    public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
+                        System.out.println("channelOpen");
+                        setAttribute(ctx, STATE_ATTRIBUTE, State.WAIT_FOR_FIRST_BYTE_LENGTH);
+                        allChannels.add(ctx.getChannel());
+                    }
+
+                    @Override
+                    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
+                        if (e.getMessage() instanceof ChannelBuffer) {
+                            ChannelBuffer buffer = (ChannelBuffer) e.getMessage();
+
+                            State state = (State) getAttribute(ctx, STATE_ATTRIBUTE);
+                            int length = 0;
+                            if (getAttributesMap(ctx).containsKey(LENGTH_ATTRIBUTE)) {
+                                length = (Integer) getAttribute(ctx, LENGTH_ATTRIBUTE);
+                            }
+                            while (buffer.readableBytes() > 0) {
+                                switch (state) {
+                                case WAIT_FOR_FIRST_BYTE_LENGTH:
+                                    length = (buffer.readByte() & 255) << 24;
+                                    state = State.WAIT_FOR_SECOND_BYTE_LENGTH;
+                                    break;
+                                case WAIT_FOR_SECOND_BYTE_LENGTH:
+                                    length += (buffer.readByte() & 255) << 16;
+                                    state = State.WAIT_FOR_THIRD_BYTE_LENGTH;
+                                    break;
+                                case WAIT_FOR_THIRD_BYTE_LENGTH:
+                                    length += (buffer.readByte() & 255) << 8;
+                                    state = State.WAIT_FOR_FOURTH_BYTE_LENGTH;
+                                    break;
+                                case WAIT_FOR_FOURTH_BYTE_LENGTH:
+                                    length += (buffer.readByte() & 255);
+                                    state = State.READING;
+                                    if ((length == 0) && (buffer.readableBytes() == 0)) {
+                                        ctx.getChannel().write(ACK.slice());
+                                        state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
+                                    }
+                                    break;
+                                case READING:
+                                    int remaining = buffer.readableBytes();
+                                    if (length > remaining) {
+                                        length -= remaining;
+                                        buffer.skipBytes(remaining);
+                                    } else {
+                                        buffer.skipBytes(length);
+                                        SocketAddress remoteAddress = e.getRemoteAddress();
+                                        ctx.getChannel().write(ACK.slice(), remoteAddress);
+                                        state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
+                                        length = 0;
+                                    }
+                                }
+                            }
+                            setAttribute(ctx, STATE_ATTRIBUTE, state);
+                            setAttribute(ctx, LENGTH_ATTRIBUTE, length);
+                        }
+                    }
+
+                    @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());
+                    }
+
+                    @Override
+                    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
+                        e.getCause().printStackTrace();
+                    }
+                });
+            }
+        });
+        allChannels.add(bootstrap.bind(new InetSocketAddress(port)));
+    }
+
+    /**
+     * {@inheritedDoc}
+     */
+    public void stop() throws IOException {
+        allChannels.disconnect().awaitUninterruptibly();
+        factory.shutdown();
+        factory.releaseExternalResources();
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/netty4/pom.xml
----------------------------------------------------------------------
diff --git a/benchmarks/netty4/pom.xml b/benchmarks/netty4/pom.xml
new file mode 100644
index 0000000..ef3b511
--- /dev/null
+++ b/benchmarks/netty4/pom.xml
@@ -0,0 +1,49 @@
+<?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-netty4</artifactId>
+  <name>Apache MINA Benchmarks against Netty4 tests</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>mina-benchmarks-common</artifactId>
+      <scope>test</scope>
+      <type>test-jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>io.netty</groupId>
+      <artifactId>netty-all</artifactId>
+      <version>${netty4.version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4BenchmarkServer.java
----------------------------------------------------------------------
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);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerTcpBenchmarkBinaryTest.java
----------------------------------------------------------------------
diff --git a/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerTcpBenchmarkBinaryTest.java b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerTcpBenchmarkBinaryTest.java
new file mode 100644
index 0000000..80058e0
--- /dev/null
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerTcpBenchmarkBinaryTest.java
@@ -0,0 +1,75 @@
+/*
+ *  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.util.Arrays;
+import java.util.Collection;
+
+import org.apache.mina.core.nio.tcp.Mina3TcpBenchmarkServer;
+import org.apache.mina.core.nio.tcp.Netty4TcpBenchmarkClient;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * A TCP  Netty4 client vs Mina 3 server benchmark
+ * 
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Netty4ClientVsMina3ServerTcpBenchmarkBinaryTest extends BenchmarkBinaryTest {
+
+    /**
+     * @param numberOfMessages
+     * @param messageSize
+     */
+    public Netty4ClientVsMina3ServerTcpBenchmarkBinaryTest(int numberOfMessages, int messageSize, int timeout) {
+        super(numberOfMessages, messageSize, timeout);
+    }
+
+    /** {@inheritDoc}
+     */
+    @Override
+    public BenchmarkClient getClient() {
+        return new Netty4TcpBenchmarkClient();
+    }
+
+    /** {@inheritDoc}
+     */
+    @Override
+    public BenchmarkServer getServer() {
+        return new Mina3TcpBenchmarkServer();
+    }
+
+    //TODO: analyze with Netty is so slow on large message: last test lower to 100 messages
+    @Parameters(name = "{0} messages of size {1}")
+    public static Collection<Object[]> getParameters() {
+        Object[][] parameters = new Object[][] { 
+                { 1000000, 10, 2 * 60 }, 
+                { 1000000, 1 * 1024, 2 * 60 },
+                { 1000000, 10 * 1024, 2 * 60 }, 
+                { 1000000, 20 * 1024, 2 * 60 }, 
+                { 500000, 50 * 1024, 2 * 60 },
+                { 200000, 100 * 1024, 2 * 60 }, 
+                { 100000, 200 * 1024, 2 * 60 }, 
+                { 50000, 500 * 1024, 2 * 60 },
+                { 20000, 1024 * 1024, 2 * 60 }, 
+                { 2000, 10 * 1024 * 1024, 2 * 60 }, 
+                { 500, 64 * 1024 * 1024, 2 * 60 } };
+        return Arrays.asList(parameters);
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerUdpBenchmarkBinaryTest.java
----------------------------------------------------------------------
diff --git a/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerUdpBenchmarkBinaryTest.java b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerUdpBenchmarkBinaryTest.java
new file mode 100644
index 0000000..c545447
--- /dev/null
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsMina3ServerUdpBenchmarkBinaryTest.java
@@ -0,0 +1,69 @@
+/*
+ *  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.util.Arrays;
+import java.util.Collection;
+
+import org.apache.mina.core.nio.udp.Mina3UdpBenchmarkServer;
+import org.apache.mina.core.nio.udp.Netty4UdpBenchmarkClient;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * An UDP  Netty4 client vs Mina 3 server benchmark
+ * 
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Netty4ClientVsMina3ServerUdpBenchmarkBinaryTest extends BenchmarkBinaryTest {
+
+    /**
+     * @param numberOfMessages
+     * @param messageSize
+     */
+    public Netty4ClientVsMina3ServerUdpBenchmarkBinaryTest(int numberOfMessages, int messageSize, int timeout) {
+        super(numberOfMessages, messageSize, timeout);
+    }
+
+    /** {@inheritDoc}
+     */
+    @Override
+    public BenchmarkClient getClient() {
+        return new Netty4UdpBenchmarkClient();
+    }
+
+    /** {@inheritDoc}
+     */
+    @Override
+    public BenchmarkServer getServer() {
+        return new Mina3UdpBenchmarkServer();
+    }
+
+    @Parameters(name = "{0} messages of size {1}")
+    public static Collection<Object[]> getParameters() {
+        // Note : depending on your OS, the maximum PDU you can send can vary. See sysctl net.inet.udp.maxdgram
+        Object[][] parameters = new Object[][] { 
+                { 1000000, 10, 2 * 60 }, 
+                { 1000000, 1 * 1024, 2 * 60 },
+                { 1000000, 2 * 1024, 2 * 60 }, 
+                { 1000000, 4 * 1024, 2 * 60 }, 
+                { 500000, 8 * 1024, 2 * 60 } }; // No need to test any further, the maximum size for an UDP message is 64Kb
+        return Arrays.asList(parameters);
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerTcpBenchmarkBinaryTest.java
----------------------------------------------------------------------
diff --git a/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerTcpBenchmarkBinaryTest.java b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerTcpBenchmarkBinaryTest.java
new file mode 100644
index 0000000..b109eec
--- /dev/null
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerTcpBenchmarkBinaryTest.java
@@ -0,0 +1,75 @@
+/*
+ *  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.util.Arrays;
+import java.util.Collection;
+
+import org.apache.mina.core.nio.tcp.Netty4TcpBenchmarkClient;
+import org.apache.mina.core.nio.tcp.Netty4TcpBenchmarkServer;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * A TCP  Netty4 client vs Netty 4 server benchmark
+ * 
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Netty4ClientVsNetty4ServerTcpBenchmarkBinaryTest extends BenchmarkBinaryTest {
+
+    /**
+     * @param numberOfMessages
+     * @param messageSize
+     */
+    public Netty4ClientVsNetty4ServerTcpBenchmarkBinaryTest(int numberOfMessages, int messageSize, int timeout) {
+        super(numberOfMessages, messageSize, timeout);
+    }
+
+    /** {@inheritDoc}
+     */
+    @Override
+    public BenchmarkClient getClient() {
+        return new Netty4TcpBenchmarkClient();
+    }
+
+    /** {@inheritDoc}
+     */
+    @Override
+    public BenchmarkServer getServer() {
+        return new Netty4TcpBenchmarkServer();
+    }
+
+    //TODO: analyze with Netty is so slow on large message: last test lower to 100 messages
+    @Parameters(name = "{0} messages of size {1}")
+    public static Collection<Object[]> getParameters() {
+        Object[][] parameters = new Object[][] { 
+                { 1000000, 10, 2 * 60 }, 
+                { 1000000, 1 * 1024, 2 * 60 },
+                { 1000000, 10 * 1024, 2 * 60 }, 
+                { 1000000, 20 * 1024, 2 * 60 }, 
+                { 500000, 50 * 1024, 2 * 60 },
+                { 200000, 100 * 1024, 2 * 60 }, 
+                { 100000, 200 * 1024, 2 * 60 }, 
+                { 50000, 500 * 1024, 2 * 60 },
+                { 20000, 1024 * 1024, 2 * 60 }, 
+                { 2000, 10 * 1024 * 1024, 2 * 60 }, 
+                { 500, 64 * 1024 * 1024, 2 * 60 } };
+        return Arrays.asList(parameters);
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerUdpBenchmarkBinaryTest.java
----------------------------------------------------------------------
diff --git a/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerUdpBenchmarkBinaryTest.java b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerUdpBenchmarkBinaryTest.java
new file mode 100644
index 0000000..daa87a7
--- /dev/null
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/Netty4ClientVsNetty4ServerUdpBenchmarkBinaryTest.java
@@ -0,0 +1,69 @@
+/*
+ *  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.util.Arrays;
+import java.util.Collection;
+
+import org.apache.mina.core.nio.udp.Netty4UdpBenchmarkClient;
+import org.apache.mina.core.nio.udp.Netty4UdpBenchmarkServer;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * An UDP  Netty4 client vs Netty 4 server benchmark
+ * 
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Netty4ClientVsNetty4ServerUdpBenchmarkBinaryTest extends BenchmarkBinaryTest {
+
+    /**
+     * @param numberOfMessages
+     * @param messageSize
+     */
+    public Netty4ClientVsNetty4ServerUdpBenchmarkBinaryTest(int numberOfMessages, int messageSize, int timeout) {
+        super(numberOfMessages, messageSize, timeout);
+    }
+
+    /** {@inheritDoc}
+     */
+    @Override
+    public BenchmarkClient getClient() {
+        return new Netty4UdpBenchmarkClient();
+    }
+
+    /** {@inheritDoc}
+     */
+    @Override
+    public BenchmarkServer getServer() {
+        return new Netty4UdpBenchmarkServer();
+    }
+
+    @Parameters(name = "{0} messages of size {1}")
+    public static Collection<Object[]> getParameters() {
+        // Note : depending on your OS, the maximum PDU you can send can vary. See sysctl net.inet.udp.maxdgram
+        Object[][] parameters = new Object[][] { 
+                { 1000000, 10, 2 * 60 }, 
+                { 1000000, 1 * 1024, 2 * 60 },
+                { 1000000, 2 * 1024, 2 * 60 }, 
+                { 1000000, 4 * 1024, 2 * 60 }, 
+                { 500000, 8 * 1024, 2 * 60 } }; // No need to test any further, the maximum size for an UDP message is 64Kb
+        return Arrays.asList(parameters);
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/netty4/src/test/java/org/apache/mina/core/nio/tcp/Netty4TcpBenchmarkClient.java
----------------------------------------------------------------------
diff --git a/benchmarks/netty4/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
new file mode 100644
index 0000000..fcc8782
--- /dev/null
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/nio/tcp/Netty4TcpBenchmarkClient.java
@@ -0,0 +1,109 @@
+/*
+ *  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 io.netty.bootstrap.Bootstrap;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.mina.core.BenchmarkClient;
+
+/**
+ * A Netty 3 TCP CLient.
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Netty4TcpBenchmarkClient implements BenchmarkClient {
+
+    private EventLoopGroup group = new NioEventLoopGroup();
+  
+    /**
+     * 
+     */
+    public Netty4TcpBenchmarkClient() {
+    }
+
+    /**
+     * {@inheritedDoc}
+     */
+    public void start(final int port, final CountDownLatch counter, final byte[] data) throws IOException {
+        Bootstrap bootstrap = new Bootstrap();
+        bootstrap.group(group);
+        bootstrap.option(ChannelOption.SO_SNDBUF, 64 * 1024);
+        bootstrap.option(ChannelOption.TCP_NODELAY, true);
+        bootstrap.channel(NioSocketChannel.class);
+        bootstrap.handler(new ChannelInitializer<SocketChannel>() {
+
+            @Override
+            protected void initChannel(SocketChannel ch) throws Exception {
+                ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
+                    private void sendMessage(ChannelHandlerContext ctx, byte[] data) {
+                        ByteBuf buf = ctx.alloc().buffer(data.length);
+                        buf.writeBytes(data);
+                        ctx.writeAndFlush(buf);
+                    }
+
+                    @Override
+                    public void channelRead(ChannelHandlerContext ctx, Object message) throws Exception {
+                        ByteBuf buf = (ByteBuf)message;
+                        for(int i=0; i < buf.readableBytes();i++) {
+                            counter.countDown();
+                            if (counter.getCount() > 0) {
+                                sendMessage(ctx, data);
+                            } else {
+                                ctx.channel().close();
+                            }
+                        }
+                        buf.release();
+                    }
+
+                    @Override
+                    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+                      sendMessage(ctx, data);
+                    }
+                });
+            }
+
+            @Override
+            public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
+                cause.printStackTrace();
+                ctx.close();
+            }
+        });
+        bootstrap.connect(new InetSocketAddress(port));
+    }
+
+    /**
+     * {@inheritedDoc}
+     */
+    public void stop() throws IOException {
+        group.shutdownGracefully();
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/netty4/src/test/java/org/apache/mina/core/nio/tcp/Netty4TcpBenchmarkServer.java
----------------------------------------------------------------------
diff --git a/benchmarks/netty4/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
new file mode 100644
index 0000000..c7f3f84
--- /dev/null
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/nio/tcp/Netty4TcpBenchmarkServer.java
@@ -0,0 +1,155 @@
+/*
+ *  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 io.netty.bootstrap.ServerBootstrap;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import io.netty.util.Attribute;
+
+import java.io.IOException;
+
+import org.apache.mina.core.Netty4BenchmarkServer;
+
+/**
+ * A Netty 4 TCP Server.
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Netty4TcpBenchmarkServer extends Netty4BenchmarkServer {
+
+    private ServerBootstrap bootstrap = null;
+
+    private class TestServerHandler extends ChannelInboundHandlerAdapter  {
+        public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
+            System.out.println("childChannelOpen");
+            ctx.attr(STATE_ATTRIBUTE).set(State.WAIT_FOR_FIRST_BYTE_LENGTH);
+        }
+
+        @Override
+        public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
+        }
+
+        @Override
+        public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+            cause.printStackTrace();
+        }
+
+        @Override
+        public void channelRead(ChannelHandlerContext ctx, Object message) throws Exception {
+            ByteBuf buffer = (ByteBuf)message;
+            State state = ctx.attr(STATE_ATTRIBUTE).get();
+            int length = 0;
+            Attribute<Integer> lengthAttribute = ctx.attr(LENGTH_ATTRIBUTE);
+
+            if (lengthAttribute.get() != null) {
+                length = lengthAttribute.get();
+            }
+
+            while (buffer.readableBytes() > 0) {
+                switch (state) {
+                case WAIT_FOR_FIRST_BYTE_LENGTH:
+                    length = (buffer.readByte() & 255) << 24;
+                    state = State.WAIT_FOR_SECOND_BYTE_LENGTH;
+                    break;
+
+                case WAIT_FOR_SECOND_BYTE_LENGTH:
+                    length += (buffer.readByte() & 255) << 16;
+                    state = State.WAIT_FOR_THIRD_BYTE_LENGTH;
+                    break;
+
+                case WAIT_FOR_THIRD_BYTE_LENGTH:
+                    length += (buffer.readByte() & 255) << 8;
+                    state = State.WAIT_FOR_FOURTH_BYTE_LENGTH;
+                    break;
+
+                case WAIT_FOR_FOURTH_BYTE_LENGTH:
+                    length += (buffer.readByte() & 255);
+                    state = State.READING;
+
+                    if ((length == 0) && (buffer.readableBytes() == 0)) {
+                        ctx.writeAndFlush(ACK.retain(1).resetReaderIndex());
+                        state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
+                    }
+
+                    break;
+
+                case READING:
+                    int remaining = buffer.readableBytes();
+
+                    if (length > remaining) {
+                        length -= remaining;
+                        buffer.skipBytes(remaining);
+                    } else {
+                        buffer.skipBytes(length);
+                        ctx.writeAndFlush(ACK.retain(1).resetReaderIndex());
+                        state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
+                        length = 0;
+                    }
+                }
+            }
+
+            ctx.attr(STATE_ATTRIBUTE).set(state);
+            ctx.attr(LENGTH_ATTRIBUTE).set(length);
+            buffer.release();
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     * @throws  
+     */
+    public void start(int port) throws IOException {
+        try {
+            bootstrap = new ServerBootstrap();
+            bootstrap.option(ChannelOption.SO_RCVBUF, 128 * 1024);
+            bootstrap.option(ChannelOption.TCP_NODELAY, true);
+            bootstrap.group(new NioEventLoopGroup(), new NioEventLoopGroup());
+            bootstrap.channel(NioServerSocketChannel.class);
+            bootstrap.localAddress(port);
+            bootstrap.childHandler(new ChannelInitializer<SocketChannel>() {
+                @Override
+                public void initChannel(SocketChannel channel) throws Exception {
+                    channel.pipeline().addLast(new TestServerHandler());
+                };
+            });
+            ChannelFuture bindFuture = bootstrap.bind();
+            //bindFuture.sync();
+            //Channel channel = bindFuture.channel();
+            //ChannelFuture closeFuture = channel.closeFuture();
+            //closeFuture.sync();
+        } finally {
+        }
+    }
+
+    /**
+     * {@inheritedDoc}
+     */
+    public void stop() throws IOException {
+        bootstrap.childGroup().shutdownGracefully();
+        bootstrap.group().shutdownGracefully();
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/netty4/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkClient.java
----------------------------------------------------------------------
diff --git a/benchmarks/netty4/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
new file mode 100644
index 0000000..cc2ae09
--- /dev/null
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkClient.java
@@ -0,0 +1,100 @@
+/*
+ *  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 io.netty.bootstrap.Bootstrap;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.SimpleChannelInboundHandler;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.DatagramChannel;
+import io.netty.channel.socket.DatagramPacket;
+import io.netty.channel.socket.nio.NioDatagramChannel;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.mina.core.BenchmarkClient;
+
+/**
+ * A Netty 4 based UDP client
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Netty4UdpBenchmarkClient implements BenchmarkClient {
+
+    private Bootstrap bootstrap;
+
+    /**
+     * 
+     */
+    public Netty4UdpBenchmarkClient() {
+    }
+
+    /**
+     * {@inheritedDoc}
+     */
+    public void start(final int port, final CountDownLatch counter, final byte[] data) throws IOException {
+        bootstrap = new Bootstrap();
+        bootstrap.option(ChannelOption.SO_SNDBUF, 65536);
+        bootstrap.group(new NioEventLoopGroup());
+        bootstrap.channel(NioDatagramChannel.class);
+        bootstrap.handler(new ChannelInitializer<DatagramChannel>() {
+
+            @Override
+            protected void initChannel(DatagramChannel ch) throws Exception {
+                ch.pipeline().addLast(new SimpleChannelInboundHandler<DatagramPacket>() {
+                    private void sendMessage(ChannelHandlerContext ctx, byte[] data, InetSocketAddress address) {
+                        ByteBuf buf = ctx.alloc().buffer(data.length);
+                        buf.writeBytes(data);
+                        ctx.writeAndFlush(new DatagramPacket(buf, address));
+                    }
+                  
+                    @Override
+                    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+                        sendMessage(ctx, data, new InetSocketAddress("localhost", port));
+                    }
+
+                    @Override
+                    protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket message) throws Exception {
+                        for(int i=0; i < message.content().readableBytes();i++) {
+                            counter.countDown();
+                            if (counter.getCount() > 0) {
+                                sendMessage(ctx, data, message.sender());
+                            } else {
+                                ctx.channel().close();
+                            }
+                        }
+                    }
+                });
+            }
+        });
+        bootstrap.bind(port+1);
+    }
+
+    /**
+     * {@inheritedDoc}
+     */
+    public void stop() throws IOException {
+        bootstrap.group().shutdownGracefully();
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/netty4/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkServer.java
----------------------------------------------------------------------
diff --git a/benchmarks/netty4/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
new file mode 100644
index 0000000..c21ba76
--- /dev/null
+++ b/benchmarks/netty4/src/test/java/org/apache/mina/core/nio/udp/Netty4UdpBenchmarkServer.java
@@ -0,0 +1,133 @@
+/*
+ *  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 io.netty.bootstrap.Bootstrap;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.SimpleChannelInboundHandler;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.DatagramChannel;
+import io.netty.channel.socket.DatagramPacket;
+import io.netty.channel.socket.nio.NioDatagramChannel;
+import io.netty.util.Attribute;
+
+import java.io.IOException;
+
+import org.apache.mina.core.Netty4BenchmarkServer;
+
+/**
+ * A Netty 4 based UDP server
+ * 
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Netty4UdpBenchmarkServer extends Netty4BenchmarkServer {
+
+    private Bootstrap bootstrap;
+
+    /**
+     * {@inheritDoc}
+     */
+    public void start(int port) throws IOException {
+        bootstrap = new Bootstrap();
+        bootstrap.group(new NioEventLoopGroup());
+        bootstrap.channel(NioDatagramChannel.class);
+        bootstrap.option(ChannelOption.SO_RCVBUF, 65536);
+        bootstrap.handler(new ChannelInitializer<DatagramChannel>() {
+
+            @Override
+            protected void initChannel(DatagramChannel ch) throws Exception {
+                ch.pipeline().addLast(new SimpleChannelInboundHandler<DatagramPacket>() {
+                    @Override
+                    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+                        ctx.attr(STATE_ATTRIBUTE).set(State.WAIT_FOR_FIRST_BYTE_LENGTH);
+                    }
+
+                    @Override
+                    protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket message) throws Exception {
+                        ByteBuf buffer = message.content();
+                        State state = ctx.attr(STATE_ATTRIBUTE).get();
+                        int length = 0;
+                        Attribute<Integer> lengthAttribute = ctx.attr(LENGTH_ATTRIBUTE);
+
+                        if (lengthAttribute.get() != null) {
+                            length = lengthAttribute.get();
+                        }
+
+                        while (buffer.readableBytes() > 0) {
+                            switch (state) {
+                                case WAIT_FOR_FIRST_BYTE_LENGTH:
+                                    length = (buffer.readByte() & 255) << 24;
+                                    state = State.WAIT_FOR_SECOND_BYTE_LENGTH;
+                                    break;
+
+                                case WAIT_FOR_SECOND_BYTE_LENGTH:
+                                    length += (buffer.readByte() & 255) << 16;
+                                    state = State.WAIT_FOR_THIRD_BYTE_LENGTH;
+                                    break;
+
+                                case WAIT_FOR_THIRD_BYTE_LENGTH:
+                                    length += (buffer.readByte() & 255) << 8;
+                                    state = State.WAIT_FOR_FOURTH_BYTE_LENGTH;
+                                    break;
+
+                                case WAIT_FOR_FOURTH_BYTE_LENGTH:
+                                    length += (buffer.readByte() & 255);
+                                    state = State.READING;
+
+                                    if ((length == 0) && (buffer.readableBytes() == 0)) {
+                                        ctx.writeAndFlush(new DatagramPacket(ACK.retain(1).resetReaderIndex(), message.sender()));
+                                        state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
+                                    }
+                                    break;
+
+                                case READING:
+                                    int remaining = buffer.readableBytes();
+
+                                    if (length > remaining) {
+                                        length -= remaining;
+                                        buffer.skipBytes(remaining);
+                                    } else {
+                                        buffer.skipBytes(length);
+                                        ctx.writeAndFlush(new DatagramPacket(ACK.retain(1).resetReaderIndex(), message.sender()));
+                                        state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
+                                        length = 0;
+                                    }
+                            }
+                        }
+
+                        ctx.attr(STATE_ATTRIBUTE).set(state);
+                        ctx.attr(LENGTH_ATTRIBUTE).set(length);
+                   }
+                });
+            }
+        });
+        bootstrap.bind(port);
+    }
+
+    /**
+     * {@inheritedDoc}
+     */
+    public void stop() throws IOException {
+        bootstrap.group().shutdownGracefully();
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/pom.xml
----------------------------------------------------------------------
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>

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java b/benchmarks/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
deleted file mode 100644
index 5c2e85e..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
+++ /dev/null
@@ -1,154 +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.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;
-
-/**
- * Binary benchmark
- * @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 BenchmarkClient getClient();
-
-    public abstract BenchmarkServer getServer();
-
-    @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 = getServer();
-        server.start(port);
-        client = getClient();
-        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);
-        CounterFilter.messageSent.set(0);
-
-        boolean result = true;
-
-        System.out.println("-------------- Sending " + data.length + " bytes");
-        client.start(port, counter, data);
-        long globalSent = 0;
-        long warmedUpSent = 0;
-        int nbSeconds = 0;
-
-        while ((counter.getCount() > 0) && (nbSeconds < 120)) {
-            result = counter.await(1, TimeUnit.SECONDS);
-
-            long nbSent = CounterFilter.messageSent.getAndSet(0);
-            nbSeconds++;
-
-            globalSent += nbSent;
-
-            if (nbSeconds > 5) {
-                warmedUpSent += 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");
-        } else {
-            System.out.println("Wasn't able to send all the messages : sent " + globalSent);
-        }
-
-        assertTrue("Still " + counter.getCount() + " messages to send of a total of " + numberOfMessages, result);
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/BenchmarkClient.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkClient.java b/benchmarks/src/test/java/org/apache/mina/core/BenchmarkClient.java
deleted file mode 100644
index 393eea6..0000000
--- a/benchmarks/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;
-}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/BenchmarkServer.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/BenchmarkServer.java b/benchmarks/src/test/java/org/apache/mina/core/BenchmarkServer.java
deleted file mode 100644
index d4652e3..0000000
--- a/benchmarks/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;
-}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/BioClientVsBioServerUdpBenchmarkBinaryTest.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/BioClientVsBioServerUdpBenchmarkBinaryTest.java b/benchmarks/src/test/java/org/apache/mina/core/BioClientVsBioServerUdpBenchmarkBinaryTest.java
deleted file mode 100644
index 815983d..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/BioClientVsBioServerUdpBenchmarkBinaryTest.java
+++ /dev/null
@@ -1,69 +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.util.Arrays;
-import java.util.Collection;
-
-import org.apache.mina.core.bio.udp.BioUdpBenchmarkClient;
-import org.apache.mina.core.bio.udp.BioUdpBenchmarkServer;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class BioClientVsBioServerUdpBenchmarkBinaryTest extends BenchmarkBinaryTest {
-
-    /**
-     * @param numberOfMessages
-     * @param messageSize
-     */
-    public BioClientVsBioServerUdpBenchmarkBinaryTest(int numberOfMessages, int messageSize, int timeout) {
-        super(numberOfMessages, messageSize, timeout);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public BenchmarkClient getClient() {
-        return new BioUdpBenchmarkClient();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public BenchmarkServer getServer() {
-        return new BioUdpBenchmarkServer();
-    }
-
-    @Parameters(name = "{0} messages of size {1}")
-    public static Collection<Object[]> getParameters() {
-        // Note : depending on your OS, the maximum PDU you can send can vary. See sysctl net.inet.udp.maxdgram
-        Object[][] parameters = new Object[][] { 
-                { 1000000, 10, 2 * 60 }, 
-                { 1000000, 1 * 1024, 2 * 60 },
-                { 1000000, 2 * 1024, 2 * 60 }, 
-                { 1000000, 4 * 1024, 2 * 60 }, 
-                { 500000, 8 * 1024, 2 * 60 } }; // No need to test any further, the maximum size for an UDP message is 64Kb
-        return Arrays.asList(parameters);
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/BioClientVsMina3ServerUdpBenchmarkBinaryTest.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/BioClientVsMina3ServerUdpBenchmarkBinaryTest.java b/benchmarks/src/test/java/org/apache/mina/core/BioClientVsMina3ServerUdpBenchmarkBinaryTest.java
deleted file mode 100644
index f2f292b..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/BioClientVsMina3ServerUdpBenchmarkBinaryTest.java
+++ /dev/null
@@ -1,69 +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.util.Arrays;
-import java.util.Collection;
-
-import org.apache.mina.core.bio.udp.BioUdpBenchmarkClient;
-import org.apache.mina.core.nio.udp.Mina3UdpBenchmarkServer;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class BioClientVsMina3ServerUdpBenchmarkBinaryTest extends BenchmarkBinaryTest {
-
-    /**
-     * @param numberOfMessages
-     * @param messageSize
-     */
-    public BioClientVsMina3ServerUdpBenchmarkBinaryTest(int numberOfMessages, int messageSize, int timeout) {
-        super(numberOfMessages, messageSize, timeout);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public BenchmarkClient getClient() {
-        return new BioUdpBenchmarkClient();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public BenchmarkServer getServer() {
-        return new Mina3UdpBenchmarkServer();
-    }
-
-    @Parameters(name = "{0} messages of size {1}")
-    public static Collection<Object[]> getParameters() {
-        // Note : depending on your OS, the maximum PDU you can send can vary. See sysctl net.inet.udp.maxdgram
-        Object[][] parameters = new Object[][] { 
-                { 1000000, 10, 2 * 60 }, 
-                { 1000000, 1 * 1024, 2 * 60 },
-                { 1000000, 2 * 1024, 2 * 60 }, 
-                { 1000000, 4 * 1024, 2 * 60 }, 
-                { 500000, 8 * 1024, 2 * 60 } }; // No need to test any further, the maximum size for an UDP message is 64Kb
-        return Arrays.asList(parameters);
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/CounterFilter.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/CounterFilter.java b/benchmarks/src/test/java/org/apache/mina/core/CounterFilter.java
deleted file mode 100644
index f501141..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/CounterFilter.java
+++ /dev/null
@@ -1,31 +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.util.concurrent.atomic.AtomicLong;
-
-/**
- * A counter used for the benchmarks
- *
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class CounterFilter {
-    public static AtomicLong messageSent = new AtomicLong(0);
-}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerTcpBenchmarkBinaryTest.java b/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
deleted file mode 100644
index 600b5ae..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
+++ /dev/null
@@ -1,74 +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.util.Arrays;
-import java.util.Collection;
-
-import org.apache.mina.core.nio.tcp.Mina3TcpBenchmarkClient;
-import org.apache.mina.core.nio.tcp.Mina3TcpBenchmarkServer;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class Mina3ClientVsMina3ServerTcpBenchmarkBinaryTest extends BenchmarkBinaryTest {
-
-    /**
-     * @param numberOfMessages
-     * @param messageSize
-     */
-    public Mina3ClientVsMina3ServerTcpBenchmarkBinaryTest(int numberOfMessages, int messageSize, int timeout) {
-        super(numberOfMessages, messageSize, timeout);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public BenchmarkClient getClient() {
-        return new Mina3TcpBenchmarkClient();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public BenchmarkServer getServer() {
-        return new Mina3TcpBenchmarkServer();
-    }
-
-    @Parameters(name = "{0} messages of size {1}")
-    public static Collection<Object[]> getParameters() {
-        Object[][] parameters = new Object[][] { 
-                { 1000000, 10, 2 * 60 }, 
-                { 1000000, 1 * 1024, 2 * 60 },
-                { 1000000, 10 * 1024, 2 * 60 }, 
-                { 1000000, 20 * 1024, 2 * 60 }, 
-                { 500000, 50 * 1024, 2 * 60 },
-                { 200000, 100 * 1024, 2 * 60 }, 
-                { 100000, 200 * 1024, 2 * 60 }, 
-                { 50000, 500 * 1024, 2 * 60 },
-                { 20000, 1024 * 1024, 2 * 60 }, 
-                { 2000, 10 * 1024 * 1024, 2 * 60 }, 
-                { 500, 64 * 1024 * 1024, 2 * 60 } };
-        return Arrays.asList(parameters);
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerUdpBenchmarkBinaryTest.java b/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
deleted file mode 100644
index 7ea251b..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
+++ /dev/null
@@ -1,69 +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.util.Arrays;
-import java.util.Collection;
-
-import org.apache.mina.core.nio.udp.Mina3UdpBenchmarkClient;
-import org.apache.mina.core.nio.udp.Mina3UdpBenchmarkServer;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class Mina3ClientVsMina3ServerUdpBenchmarkBinaryTest extends BenchmarkBinaryTest {
-
-    /**
-     * @param numberOfMessages
-     * @param messageSize
-     */
-    public Mina3ClientVsMina3ServerUdpBenchmarkBinaryTest(int numberOfMessages, int messageSize, int timeout) {
-        super(numberOfMessages, messageSize, timeout);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public BenchmarkClient getClient() {
-        return new Mina3UdpBenchmarkClient();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public BenchmarkServer getServer() {
-        return new Mina3UdpBenchmarkServer();
-    }
-
-    @Parameters(name = "{0} messages of size {1}")
-    public static Collection<Object[]> getParameters() {
-        // Note : depending on your OS, the maximum PDU you can send can vary. See sysctl net.inet.udp.maxdgram
-        Object[][] parameters = new Object[][] { 
-                { 1000000, 10, 2 * 60 },
-                { 1000000, 1 * 1024, 2 * 60 },
-                { 1000000, 2 * 1024, 2 * 60 }, 
-                { 1000000, 4 * 1024, 2 * 60 }, 
-                { 500000, 8 * 1024, 2 * 60 }}; // No need to test any further, the maximum size for an UDP message is 64Kb
-        return Arrays.asList(parameters);
-    }
-}


Mime
View raw message