You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by je...@apache.org on 2014/05/16 11:09:26 UTC
[2/4] Refactor benchmark tests in single multi module to be more DRY
oriented
http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java b/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
deleted file mode 100644
index 077f695..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/Mina3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
+++ /dev/null
@@ -1,66 +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.Netty3TcpBenchmarkServer;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class Mina3ClientVsNetty3ServerTcpBenchmarkBinaryTest extends BenchmarkBinaryTest {
-
- /**
- * @param numberOfMessages
- * @param messageSize
- */
- public Mina3ClientVsNetty3ServerTcpBenchmarkBinaryTest(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 Netty3TcpBenchmarkServer();
- }
-
- @Parameters()
- 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/Netty3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerTcpBenchmarkBinaryTest.java b/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
deleted file mode 100644
index 4c30661..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerTcpBenchmarkBinaryTest.java
+++ /dev/null
@@ -1,65 +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.Mina3TcpBenchmarkServer;
-import org.apache.mina.core.nio.tcp.Netty3TcpBenchmarkClient;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class Netty3ClientVsMina3ServerTcpBenchmarkBinaryTest extends BenchmarkBinaryTest {
-
- /**
- * @param numberOfMessages
- * @param messageSize
- */
- public Netty3ClientVsMina3ServerTcpBenchmarkBinaryTest(int numberOfMessages, int messageSize, int timeout) {
- super(numberOfMessages, messageSize, timeout);
- }
-
- /** {@inheritDoc}
- */
- @Override
- public BenchmarkClient getClient() {
- return new Netty3TcpBenchmarkClient();
- }
-
- /** {@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/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerUdpBenchmarkBinaryTest.java b/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
deleted file mode 100644
index 5a6e08d..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsMina3ServerUdpBenchmarkBinaryTest.java
+++ /dev/null
@@ -1,67 +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.Mina3UdpBenchmarkServer;
-import org.apache.mina.core.nio.udp.Netty3UdpBenchmarkClient;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class Netty3ClientVsMina3ServerUdpBenchmarkBinaryTest extends BenchmarkBinaryTest {
-
- /**
- * @param numberOfMessages
- * @param messageSize
- */
- public Netty3ClientVsMina3ServerUdpBenchmarkBinaryTest(int numberOfMessages, int messageSize, int timeout) {
- super(numberOfMessages, messageSize, timeout);
- }
-
- /** {@inheritDoc}
- */
- @Override
- public BenchmarkClient getClient() {
- return new Netty3UdpBenchmarkClient();
- }
-
- /** {@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/Netty3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java b/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
deleted file mode 100644
index a0bccd6..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerTcpBenchmarkBinaryTest.java
+++ /dev/null
@@ -1,65 +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.Netty3TcpBenchmarkClient;
-import org.apache.mina.core.nio.tcp.Netty3TcpBenchmarkServer;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class Netty3ClientVsNetty3ServerTcpBenchmarkBinaryTest extends BenchmarkBinaryTest {
-
- /**
- * @param numberOfMessages
- * @param messageSize
- */
- public Netty3ClientVsNetty3ServerTcpBenchmarkBinaryTest(int numberOfMessages, int messageSize, int timeout) {
- super(numberOfMessages, messageSize, timeout);
- }
-
- /** {@inheritDoc}
- */
- @Override
- public BenchmarkClient getClient() {
- return new Netty3TcpBenchmarkClient();
- }
-
- /** {@inheritDoc}
- */
- @Override
- public BenchmarkServer getServer() {
- return new Netty3TcpBenchmarkServer();
- }
-
- //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/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerUdpBenchmarkBinaryTest.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerUdpBenchmarkBinaryTest.java b/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerUdpBenchmarkBinaryTest.java
deleted file mode 100644
index 76d9bf8..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/Netty3ClientVsNetty3ServerUdpBenchmarkBinaryTest.java
+++ /dev/null
@@ -1,67 +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.Netty3UdpBenchmarkClient;
-import org.apache.mina.core.nio.udp.Netty3UdpBenchmarkServer;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class Netty3ClientVsNetty3ServerUdpBenchmarkBinaryTest extends BenchmarkBinaryTest {
-
- /**
- * @param numberOfMessages
- * @param messageSize
- */
- public Netty3ClientVsNetty3ServerUdpBenchmarkBinaryTest(int numberOfMessages, int messageSize, int timeout) {
- super(numberOfMessages, messageSize, timeout);
- }
-
- /** {@inheritDoc}
- */
- @Override
- public BenchmarkClient getClient() {
- return new Netty3UdpBenchmarkClient();
- }
-
- /** {@inheritDoc}
- */
- @Override
- public BenchmarkServer getServer() {
- return new Netty3UdpBenchmarkServer();
- }
-
- @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/bio/udp/BioUdpBenchmarkClient.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkClient.java b/benchmarks/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkClient.java
deleted file mode 100644
index fe0c062..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkClient.java
+++ /dev/null
@@ -1,80 +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.bio.udp;
-
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.util.concurrent.CountDownLatch;
-
-import org.apache.mina.core.BenchmarkClient;
-
-/**
- * A client that uses a BIO datagram to communicate with the server
- *
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class BioUdpBenchmarkClient implements BenchmarkClient {
- // The UDP client
- private DatagramSocket sender;
-
- /**
- * {@inheritDoc}
- */
- public void start(int port, final CountDownLatch counter, final byte[] data) throws IOException {
- InetAddress serverAddress = InetAddress.getLocalHost();
- byte[] buffer = new byte[65507];
- sender = new DatagramSocket(port + 1);
-
- DatagramPacket pduSent = new DatagramPacket(data, data.length, serverAddress, port);
- DatagramPacket pduReceived = new DatagramPacket(buffer, data.length);
- sender.send(pduSent);
-
- boolean done = false;
-
- while (!done) {
- try {
- sender.receive(pduReceived);
-
- for (int i = 0; i < pduReceived.getLength(); ++i) {
- counter.countDown();
-
- if (counter.getCount() > 0) {
- sender.send(pduSent);
- break;
- } else {
- done = true;
- }
- }
- } catch (IOException ioe) {
- // Nothing to do
- }
- }
-
- sender.close();
- }
-
- /**
- * {@inheritedDoc}
- */
- public void stop() throws IOException {
- }
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkServer.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkServer.java b/benchmarks/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkServer.java
deleted file mode 100644
index fd9af8d..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/bio/udp/BioUdpBenchmarkServer.java
+++ /dev/null
@@ -1,167 +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.bio.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.core.CounterFilter;
-import org.apache.mina.core.nio.udp.Mina3UdpBenchmarkServer;
-import org.apache.mina.session.AttributeKey;
-import org.apache.mina.transport.bio.BioUdpServer;
-import org.apache.mina.transport.udp.DefaultUdpSessionConfig;
-import org.apache.mina.transport.udp.UdpSessionConfig;
-
-/**
- * A Server that uses a BIO datagram to communicate with the server
- *
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class BioUdpBenchmarkServer 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 BioUdpServer udpServer;
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void start(int port) throws IOException {
- UdpSessionConfig config = new DefaultUdpSessionConfig();
- config.setReadBufferSize(65536);
- udpServer = new BioUdpServer(config, null);
- 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) {
- CounterFilter.messageSent.getAndIncrement();
- }
-
- @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();
- }
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkClient.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkClient.java b/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkClient.java
deleted file mode 100644
index 44ceeb7..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkClient.java
+++ /dev/null
@@ -1,107 +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 java.util.concurrent.CountDownLatch;
-
-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.BenchmarkClient;
-import org.apache.mina.transport.nio.NioTcpClient;
-
-/**
- * A MINA 3 TCP CLient.
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class Mina3TcpBenchmarkClient implements BenchmarkClient {
- // The TCP client
- private NioTcpClient client;
-
- /**
- * {@inheritDoc}
- */
- public void start(int port, final CountDownLatch counter, final byte[] data) throws IOException {
- client = new NioTcpClient();
- client.getSessionConfig().setSendBufferSize(64 * 1024);
- client.getSessionConfig().setTcpNoDelay(true);
- client.setIoHandler(new IoHandler() {
- private void sendMessage(IoSession session, byte[] data) {
- ByteBuffer iobuf = ByteBuffer.wrap(data);
- session.write(iobuf);
- }
-
- public void sessionOpened(IoSession session) {
- sendMessage(session, data);
- }
-
- public void messageReceived(IoSession session, Object message) {
- if (message instanceof ByteBuffer) {
- ByteBuffer buffer = (ByteBuffer) message;
-
- for (int i = 0; i < buffer.remaining(); ++i) {
- counter.countDown();
- long count = counter.getCount();
- if (count > 0) {
- sendMessage(session, data);
- }
- }
- }
- }
-
- 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) {
- }
- });
-
- client.connect(new InetSocketAddress(port));
- }
-
- /**
- * {@inheritedDoc}
- */
- public void stop() throws IOException {
- client.disconnect();
- }
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkServer.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkServer.java b/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkServer.java
deleted file mode 100644
index c8153a2..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Mina3TcpBenchmarkServer.java
+++ /dev/null
@@ -1,159 +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.core.CounterFilter;
-import org.apache.mina.session.AttributeKey;
-import org.apache.mina.transport.nio.FixedSelectorLoopPool;
-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(new FixedSelectorLoopPool("Server", 1), null);
- 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) {
- CounterFilter.messageSent.getAndIncrement();
- }
-
- @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();
- }
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkClient.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkClient.java b/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkClient.java
deleted file mode 100644
index 20ca67f..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkClient.java
+++ /dev/null
@@ -1,104 +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.util.concurrent.CountDownLatch;
-
-import org.apache.mina.core.BenchmarkClient;
-import org.jboss.netty.bootstrap.ClientBootstrap;
-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.MessageEvent;
-import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
-import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
-
-/**
- * A Netty 3 TCP CLient.
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class Netty3TcpBenchmarkClient implements BenchmarkClient {
-
- private ChannelFactory factory;
-
- /**
- *
- */
- public Netty3TcpBenchmarkClient() {
- }
-
- /**
- * {@inheritedDoc}
- */
- public void start(final int port, final CountDownLatch counter, final byte[] data) throws IOException {
- factory = new NioClientSocketChannelFactory();
- ClientBootstrap bootstrap = new ClientBootstrap(factory);
- bootstrap.setOption("sendBufferSize", 64 * 1024);
- bootstrap.setOption("tcpNoDelay", true);
- 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.releaseExternalResources();
- }
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkServer.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkServer.java b/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkServer.java
deleted file mode 100644
index 653bb76..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/nio/tcp/Netty3TcpBenchmarkServer.java
+++ /dev/null
@@ -1,194 +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.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/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkClient.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkClient.java b/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkClient.java
deleted file mode 100644
index a4dcf4d..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkClient.java
+++ /dev/null
@@ -1,116 +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 java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
-
-import org.apache.mina.api.IdleStatus;
-import org.apache.mina.api.IoFuture;
-import org.apache.mina.api.IoHandler;
-import org.apache.mina.api.IoService;
-import org.apache.mina.api.IoSession;
-import org.apache.mina.core.BenchmarkClient;
-import org.apache.mina.transport.nio.NioUdpClient;
-
-/**
- * A MINA 3 based UDP client
- *
- * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- */
-public class Mina3UdpBenchmarkClient implements BenchmarkClient {
- // The UDP client
- private NioUdpClient udpClient;
-
- /**
- * {@inheritDoc}
- */
- public void start(int port, final CountDownLatch counter, final byte[] data) throws IOException {
- udpClient = new NioUdpClient();
- udpClient.setIoHandler(new IoHandler() {
- private void sendMessage(IoSession session, byte[] data) {
- ByteBuffer iobuf = ByteBuffer.wrap(data);
- session.write(iobuf);
- }
-
- public void sessionOpened(IoSession session) {
- sendMessage(session, data);
- }
-
- public void messageReceived(IoSession session, Object message) {
- if (message instanceof ByteBuffer) {
- ByteBuffer buffer = (ByteBuffer) message;
- for (int i = 0; i < buffer.remaining(); ++i) {
- counter.countDown();
- long count = counter.getCount();
- if (count > 0) {
- sendMessage(session, data);
- }
- }
- }
- }
-
- 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) {
- }
- });
-
- IoFuture<IoSession> future = udpClient.connect(new InetSocketAddress(port));
-
- try {
- IoSession session = future.get();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (ExecutionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- /**
- * {@inheritedDoc}
- */
- public void stop() throws IOException {
- }
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkServer.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkServer.java b/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkServer.java
deleted file mode 100644
index a9bf2a9..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Mina3UdpBenchmarkServer.java
+++ /dev/null
@@ -1,167 +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.core.CounterFilter;
-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) {
- CounterFilter.messageSent.getAndIncrement();
- }
-
- @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();
- }
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkClient.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkClient.java b/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkClient.java
deleted file mode 100644
index ebc92e8..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkClient.java
+++ /dev/null
@@ -1,106 +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.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/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkServer.java
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkServer.java b/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkServer.java
deleted file mode 100644
index fa2d5c8..0000000
--- a/benchmarks/src/test/java/org/apache/mina/core/nio/udp/Netty3UdpBenchmarkServer.java
+++ /dev/null
@@ -1,197 +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.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/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/benchmarks/src/test/resources/log4j.properties b/benchmarks/src/test/resources/log4j.properties
deleted file mode 100644
index 696da6e..0000000
--- a/benchmarks/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
-
-
http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks2/pom.xml
----------------------------------------------------------------------
diff --git a/benchmarks2/pom.xml b/benchmarks2/pom.xml
deleted file mode 100644
index 2b8acd4..0000000
--- a/benchmarks2/pom.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-<?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-parent</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>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mina-core</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-all</artifactId>
- <version>${netty.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>
http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
----------------------------------------------------------------------
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 59e1e4a..0000000
--- a/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkBinaryTest.java
+++ /dev/null
@@ -1,123 +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;
-
-/**
- * @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);
-
- 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);
- }
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkClient.java
----------------------------------------------------------------------
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;
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/a79cb81b/benchmarks2/src/test/java/org/apache/mina/core/BenchmarkServer.java
----------------------------------------------------------------------
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;
-}