hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1447064 - in /httpcomponents/benchmark/httpcore/trunk: ./ src/main/java/org/apache/http/benchmark/ src/main/java/org/apache/http/benchmark/httpcore/ src/main/java/org/apache/http/benchmark/jetty/ src/main/java/org/apache/http/benchmark/netty/
Date Sun, 17 Feb 2013 19:59:55 GMT
Author: olegk
Date: Sun Feb 17 19:59:54 2013
New Revision: 1447064

URL: http://svn.apache.org/r1447064
Log:
Upgraded HttpCore to version 4.3-alpha2-SNAPSHOT; minor benchmark improvements

Added:
    httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/BenchConsts.java
  (with props)
Modified:
    httpcomponents/benchmark/httpcore/trunk/pom.xml
    httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/HttpCoreNIOServer.java
    httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/HttpCoreServer.java
    httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/HttpListener.java
    httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/jetty/JettyNIOServer.java
    httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/jetty/JettyServer.java
    httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/netty/HttpServerPipelineFactory.java
    httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/netty/NettyNIOServer.java

Modified: httpcomponents/benchmark/httpcore/trunk/pom.xml
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpcore/trunk/pom.xml?rev=1447064&r1=1447063&r2=1447064&view=diff
==============================================================================
--- httpcomponents/benchmark/httpcore/trunk/pom.xml (original)
+++ httpcomponents/benchmark/httpcore/trunk/pom.xml Sun Feb 17 19:59:54 2013
@@ -45,19 +45,19 @@
     <dependency>
       <groupId>org.apache.httpcomponents</groupId>
       <artifactId>httpcore</artifactId>
-      <version>4.2.3</version>
+      <version>4.3-alpha2-SNAPSHOT</version>
       <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.httpcomponents</groupId>
       <artifactId>httpcore-nio</artifactId>
-      <version>4.2.3</version>
+      <version>4.3-alpha2-SNAPSHOT</version>
       <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.httpcomponents</groupId>
       <artifactId>httpcore-ab</artifactId>
-      <version>4.2.3</version>
+      <version>4.3-alpha2-SNAPSHOT</version>
       <scope>compile</scope>
     </dependency>
     <dependency>

Added: httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/BenchConsts.java
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/BenchConsts.java?rev=1447064&view=auto
==============================================================================
--- httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/BenchConsts.java
(added)
+++ httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/BenchConsts.java
Sun Feb 17 19:59:54 2013
@@ -0,0 +1,35 @@
+/*
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.benchmark;
+
+public final class BenchConsts {
+
+    public static final int BUF_SIZE             = 8 * 1024;
+    public static final boolean TCP_NO_DELAY     = true;
+
+}

Propchange: httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/BenchConsts.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/BenchConsts.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/BenchConsts.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/HttpCoreNIOServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/HttpCoreNIOServer.java?rev=1447064&r1=1447063&r2=1447064&view=diff
==============================================================================
--- httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/HttpCoreNIOServer.java
(original)
+++ httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/HttpCoreNIOServer.java
Sun Feb 17 19:59:54 2013
@@ -30,18 +30,18 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 
 import org.apache.http.HttpResponseInterceptor;
+import org.apache.http.benchmark.BenchConsts;
 import org.apache.http.benchmark.HttpServer;
+import org.apache.http.config.ConnectionConfig;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.impl.nio.DefaultHttpServerIODispatch;
 import org.apache.http.impl.nio.reactor.DefaultListeningIOReactor;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerRegistry;
+import org.apache.http.impl.nio.reactor.IOReactorConfig;
 import org.apache.http.nio.protocol.HttpAsyncService;
+import org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.reactor.IOEventDispatch;
 import org.apache.http.nio.reactor.ListeningIOReactor;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.CoreConnectionPNames;
-import org.apache.http.params.CoreProtocolPNames;
-import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.HttpProcessor;
 import org.apache.http.protocol.ImmutableHttpProcessor;
 import org.apache.http.protocol.ResponseConnControl;
@@ -61,28 +61,32 @@ public class HttpCoreNIOServer implement
         }
         this.port = port;
 
-        final HttpParams params = new BasicHttpParams();
-        params
-            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 10000)
-            .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 12 * 1024)
-            .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
-            .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpCore-NIO-Test/1.1");
-
         final HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[]
{
                 new ResponseDate(),
-                new ResponseServer(),
+                new ResponseServer("HttpCore-NIO-Test/1.1"),
                 new ResponseContent(),
                 new ResponseConnControl()
         });
 
-        final HttpAsyncRequestHandlerRegistry reqistry = new HttpAsyncRequestHandlerRegistry();
-        reqistry.register("/rnd", new NRandomDataHandler());
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
+        registry.register("/rnd", new NRandomDataHandler());
 
         final HttpAsyncService handler = new HttpAsyncService(
-                httpproc, new DefaultConnectionReuseStrategy(), reqistry, params);
-
-        final ListeningIOReactor ioreactor = new DefaultListeningIOReactor();
-        final IOEventDispatch ioEventDispatch = new DefaultHttpServerIODispatch(handler,
params);
+                httpproc,
+                DefaultConnectionReuseStrategy.INSTANCE,
+                DefaultHttpResponseFactory.INSTANCE,
+                registry,
+                null);
+
+        final IOReactorConfig reactorConfig = IOReactorConfig.custom()
+            .setSoReuseAddress(true)
+            .setTcpNoDelay(BenchConsts.TCP_NO_DELAY)
+            .build();
+        final ListeningIOReactor ioreactor = new DefaultListeningIOReactor(reactorConfig);
+        final ConnectionConfig connectionConfig = ConnectionConfig.custom()
+            .build();
+        final IOEventDispatch ioEventDispatch = new DefaultHttpServerIODispatch(handler,
+            connectionConfig);
 
         this.listener = new NHttpListener(ioreactor, ioEventDispatch);
     }

Modified: httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/HttpCoreServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/HttpCoreServer.java?rev=1447064&r1=1447063&r2=1447064&view=diff
==============================================================================
--- httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/HttpCoreServer.java
(original)
+++ httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/HttpCoreServer.java
Sun Feb 17 19:59:54 2013
@@ -33,21 +33,18 @@ import java.util.Queue;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
 import org.apache.http.HttpResponseInterceptor;
+import org.apache.http.benchmark.BenchConsts;
 import org.apache.http.benchmark.HttpServer;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
-import org.apache.http.params.CoreConnectionPNames;
-import org.apache.http.params.CoreProtocolPNames;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.SyncBasicHttpParams;
 import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpRequestHandlerRegistry;
 import org.apache.http.protocol.HttpService;
 import org.apache.http.protocol.ImmutableHttpProcessor;
 import org.apache.http.protocol.ResponseConnControl;
 import org.apache.http.protocol.ResponseContent;
 import org.apache.http.protocol.ResponseDate;
 import org.apache.http.protocol.ResponseServer;
+import org.apache.http.protocol.UriHttpRequestHandlerMapper;
 import org.apache.http.util.VersionInfo;
 
 public class HttpCoreServer implements HttpServer {
@@ -61,35 +58,26 @@ public class HttpCoreServer implements H
             throw new IllegalArgumentException("Server port may not be negative or null");
         }
 
-        final HttpParams params = new SyncBasicHttpParams();
-        params
-            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 10000)
-            .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 12 * 1024)
-            .setIntParameter(CoreConnectionPNames.MIN_CHUNK_LIMIT, 1024)
-            .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
-            .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpCore-Test/1.1");
-
         final HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[]
{
                 new ResponseDate(),
-                new ResponseServer(),
+                new ResponseServer("HttpCore-Test/1.1"),
                 new ResponseContent(),
                 new ResponseConnControl()
         });
 
-        final HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
+        final UriHttpRequestHandlerMapper reqistry = new UriHttpRequestHandlerMapper();
         reqistry.register("/rnd", new RandomDataHandler());
 
         final HttpService httpservice = new HttpService(
                 httpproc,
-                new DefaultConnectionReuseStrategy(),
-                new DefaultHttpResponseFactory(),
-                reqistry,
-                params);
+                DefaultConnectionReuseStrategy.INSTANCE,
+                DefaultHttpResponseFactory.INSTANCE,
+                reqistry);
 
         this.workers = new ConcurrentLinkedQueue<HttpWorker>();
-        ServerSocket serverSocket = new ServerSocket(port);
+        final ServerSocket serverSocket = new ServerSocket(port);
         serverSocket.setReuseAddress(true);
-        serverSocket.setReceiveBufferSize(8 * 1024);
+        serverSocket.setReceiveBufferSize(BenchConsts.BUF_SIZE);
         this.listener = new HttpListener(
                 serverSocket,
                 httpservice,

Modified: httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/HttpListener.java
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/HttpListener.java?rev=1447064&r1=1447063&r2=1447064&view=diff
==============================================================================
--- httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/HttpListener.java
(original)
+++ httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/HttpListener.java
Sun Feb 17 19:59:54 2013
@@ -28,11 +28,11 @@
 package org.apache.http.benchmark.httpcore;
 
 import java.io.IOException;
-import java.io.InterruptedIOException;
 import java.net.ServerSocket;
 import java.net.Socket;
 
-import org.apache.http.impl.DefaultHttpServerConnection;
+import org.apache.http.benchmark.BenchConsts;
+import org.apache.http.impl.DefaultBHttpServerConnection;
 import org.apache.http.protocol.HttpService;
 
 class HttpListener extends Thread {
@@ -68,17 +68,17 @@ class HttpListener extends Thread {
             try {
                 // Set up HTTP connection
                 final Socket socket = this.serversocket.accept();
-                socket.setReceiveBufferSize(8 * 1024);
-                socket.setSendBufferSize(8 * 1024);
-
-                final DefaultHttpServerConnection conn = new DefaultHttpServerConnection();
-                conn.bind(socket, this.httpservice.getParams());
+                socket.setReceiveBufferSize(BenchConsts.BUF_SIZE);
+                socket.setSendBufferSize(BenchConsts.BUF_SIZE);
+                socket.setTcpNoDelay(BenchConsts.TCP_NO_DELAY);
+
+                final DefaultBHttpServerConnection conn = new DefaultBHttpServerConnection(
+                    BenchConsts.BUF_SIZE);
+                conn.bind(socket);
 
                 // Start worker thread
                 final HttpWorker t = new HttpWorker(this.httpservice, conn, this.workercallback);
                 t.start();
-            } catch (final InterruptedIOException ex) {
-                terminate();
             } catch (final IOException ex) {
                 if (!this.shutdown) {
                     this.exception = ex;

Modified: httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/jetty/JettyNIOServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/jetty/JettyNIOServer.java?rev=1447064&r1=1447063&r2=1447064&view=diff
==============================================================================
--- httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/jetty/JettyNIOServer.java
(original)
+++ httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/jetty/JettyNIOServer.java
Sun Feb 17 19:59:54 2013
@@ -27,6 +27,7 @@
 
 package org.apache.http.benchmark.jetty;
 
+import org.apache.http.benchmark.BenchConsts;
 import org.apache.http.benchmark.HttpServer;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.nio.SelectChannelConnector;
@@ -44,9 +45,9 @@ public class JettyNIOServer implements H
 
         final SelectChannelConnector connector = new SelectChannelConnector();
         connector.setPort(port);
-        connector.setRequestBufferSize(12 * 1024);
-        connector.setResponseBufferSize(12 * 1024);
-        connector.setAcceptors(2);
+        connector.setRequestBufferSize(BenchConsts.BUF_SIZE);
+        connector.setResponseBufferSize(BenchConsts.BUF_SIZE);
+        connector.setReuseAddress(true);
 
         final QueuedThreadPool threadpool = new QueuedThreadPool();
         threadpool.setMinThreads(25);

Modified: httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/jetty/JettyServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/jetty/JettyServer.java?rev=1447064&r1=1447063&r2=1447064&view=diff
==============================================================================
--- httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/jetty/JettyServer.java
(original)
+++ httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/jetty/JettyServer.java
Sun Feb 17 19:59:54 2013
@@ -27,6 +27,7 @@
 
 package org.apache.http.benchmark.jetty;
 
+import org.apache.http.benchmark.BenchConsts;
 import org.apache.http.benchmark.HttpServer;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.bio.SocketConnector;
@@ -44,9 +45,9 @@ public class JettyServer implements Http
 
         final SocketConnector connector = new SocketConnector();
         connector.setPort(port);
-        connector.setRequestBufferSize(12 * 1024);
-        connector.setResponseBufferSize(12 * 1024);
-        connector.setAcceptors(2);
+        connector.setRequestBufferSize(BenchConsts.BUF_SIZE);
+        connector.setResponseBufferSize(BenchConsts.BUF_SIZE);
+        connector.setReuseAddress(true);
 
         final QueuedThreadPool threadpool = new QueuedThreadPool();
         threadpool.setMinThreads(25);

Modified: httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/netty/HttpServerPipelineFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/netty/HttpServerPipelineFactory.java?rev=1447064&r1=1447063&r2=1447064&view=diff
==============================================================================
--- httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/netty/HttpServerPipelineFactory.java
(original)
+++ httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/netty/HttpServerPipelineFactory.java
Sun Feb 17 19:59:54 2013
@@ -36,7 +36,7 @@ import org.jboss.netty.handler.codec.htt
 public class HttpServerPipelineFactory implements ChannelPipelineFactory {
 
     public ChannelPipeline getPipeline() throws Exception {
-        ChannelPipeline pipeline = Channels.pipeline();
+        final ChannelPipeline pipeline = Channels.pipeline();
         pipeline.addLast("decoder", new HttpRequestDecoder());
         pipeline.addLast("encoder", new HttpResponseEncoder());
         pipeline.addLast("handler", new RandomDataHandler());

Modified: httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/netty/NettyNIOServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/netty/NettyNIOServer.java?rev=1447064&r1=1447063&r2=1447064&view=diff
==============================================================================
--- httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/netty/NettyNIOServer.java
(original)
+++ httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/netty/NettyNIOServer.java
Sun Feb 17 19:59:54 2013
@@ -30,6 +30,7 @@ package org.apache.http.benchmark.netty;
 import java.net.InetSocketAddress;
 import java.util.concurrent.Executors;
 
+import org.apache.http.benchmark.BenchConsts;
 import org.apache.http.benchmark.HttpServer;
 import org.jboss.netty.bootstrap.ServerBootstrap;
 import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
@@ -50,21 +51,25 @@ public class NettyNIOServer implements H
             Executors.newCachedThreadPool(),
             Executors.newCachedThreadPool()));
         this.serverBootstrap.setPipelineFactory(new HttpServerPipelineFactory());
-        this.serverBootstrap.setOption("child.tcpNoDelay", Boolean.TRUE);
+        this.serverBootstrap.setOption("child.tcpNoDelay", Boolean.valueOf(BenchConsts.TCP_NO_DELAY));
     }
 
+    @Override
     public String getName() {
         return "Netty";
     }
 
+    @Override
     public String getVersion() {
         return "3.6.2";
     }
 
+    @Override
     public void start() throws Exception {
         serverBootstrap.bind(new InetSocketAddress(port));
     }
 
+    @Override
     public void shutdown() {
         serverBootstrap.releaseExternalResources();
     }
@@ -74,7 +79,7 @@ public class NettyNIOServer implements H
             System.out.println("Usage: <port>");
             System.exit(1);
         }
-        int port = Integer.parseInt(args[0]);
+        final int port = Integer.parseInt(args[0]);
         final NettyNIOServer server = new NettyNIOServer(port);
         System.out.println("Listening on port: " + port);
         server.start();



Mime
View raw message