Browse Source

:arrow_up: Upgrade dependencies, simplify code, optimize, remove non-default modes

circlespainter 9 years ago
parent
commit
6055685dc1

+ 6 - 8
frameworks/Java/comsat-servlet/README.md

@@ -1,6 +1,6 @@
-# Parallel Universe Comsat Servlet Benchmarking Test
+# Parallel Universe Comsat Servlet Undertow Benchmarking Test
 
 
-This is the [Parallel Universe Comsat Servlet](http://docs.paralleluniverse.co/comsat/#servlets) version of a [benchmarking test suite](../) comparing a variety of web development platforms. It serves requests in lightweight [Quasar fibers](http://docs.paralleluniverse.co/quasar/#fibers) rather than heavyweight Java threads and it any servlet containers. Configurations are provided for Jetty, Tomcat and Undertow (default).
+This is the [Parallel Universe Comsat Servlet](http://docs.paralleluniverse.co/comsat/#servlets) version of a [benchmarking test suite](../) comparing a variety of web development platforms. It serves requests in lightweight [Quasar fibers](http://docs.paralleluniverse.co/quasar/#fibers) rather than heavyweight Java threads and it works with any servlet containers (tests are run against embedded Undertow, Jetty and Tomcat). The servlet container used in this benchmark is Undertow.
 
 
 ### JSON Encoding and Plaintext Tests
 ### JSON Encoding and Plaintext Tests
 
 
@@ -9,12 +9,10 @@ This is the [Parallel Universe Comsat Servlet](http://docs.paralleluniverse.co/c
 
 
 ## Versions
 ## Versions
 
 
-* Jackson JSON 2.5.4 (https://github.com/FasterXML/jackson)
-* Quasar 0.7.3 (http://docs.paralleluniverse.co/quasar)
-* Comsat 0.5.0 (http://docs.paralleluniverse.co/comsat)
-* Undertow 1.2.10-final (http://undertow.io)
-* Tomcat 8.0.26 (http://tomcat.apache.org)
-* Jetty 9.2.13.v20150730 (http://eclipse.org/jetty)
+* Jackson JSON 2.7.0 (https://github.com/FasterXML/jackson)
+* Quasar 0.7.4 (http://docs.paralleluniverse.co/quasar)
+* Comsat 0.6.0-SNAPSHOT (http://docs.paralleluniverse.co/comsat)
+* Undertow 1.3.15-final (http://undertow.io)
 
 
 ## Test URLs
 ## Test URLs
 
 

+ 0 - 38
frameworks/Java/comsat-servlet/benchmark_config.json

@@ -20,44 +20,6 @@
         "display_name": "comsat-servlet-undertow",
         "display_name": "comsat-servlet-undertow",
         "notes": "Comsat servlet on embedded Undertow",
         "notes": "Comsat servlet on embedded Undertow",
         "versus": ""
         "versus": ""
-      },
-      "jetty": {
-        "setup_file": "setup-jetty",
-        "json_url": "/json",
-        "plaintext_url": "/plaintext",
-        "port": 8080,
-        "approach": "Realistic",
-        "classification": "Platform",
-        "database": "None",
-        "framework": "comsat-servlet",
-        "language": "Java",
-        "orm": "Raw",
-        "platform": "Comsat Servlet",
-        "webserver": "Jetty",
-        "os": "Linux",
-        "database_os": "Linux",
-        "display_name": "comsat-servlet-jetty",
-        "notes": "Comsat servlet on embedded Jetty",
-        "versus": ""
-      },
-      "tomcat": {
-        "setup_file": "setup-tomcat",
-        "json_url": "/json",
-        "plaintext_url": "/plaintext",
-        "port": 8080,
-        "approach": "Realistic",
-        "classification": "Platform",
-        "database": "None",
-        "framework": "comsat-servlet",
-        "language": "Java",
-        "orm": "Raw",
-        "platform": "Comsat Servlet",
-        "webserver": "Tomcat",
-        "os": "Linux",
-        "database_os": "Linux",
-        "display_name": "comsat-servlet-jetty",
-        "notes": "Comsat servlet on embedded Tomcat",
-        "versus": ""
       }
       }
     }
     }
   ]
   ]

+ 10 - 20
frameworks/Java/comsat-servlet/build.gradle

@@ -1,6 +1,6 @@
 // Capsule plugin
 // Capsule plugin
 plugins {
 plugins {
-    id "us.kirchmeier.capsule" version "1.0.0"
+    id "us.kirchmeier.capsule" version "1.0.2"
 }
 }
 
 
 apply plugin: 'java'
 apply plugin: 'java'
@@ -8,17 +8,19 @@ apply plugin: 'java'
 sourceCompatibility = 1.8
 sourceCompatibility = 1.8
 targetCompatibility = 1.8
 targetCompatibility = 1.8
 
 
-version = '1.0'
+version = '0.2'
 
 
-ext.jacksonVer = '2.5.4'
-ext.quasarVer  = '0.7.3'
-ext.comsatVer  = '0.5.0'
+ext.jacksonVer = '2.7.0'
+ext.quasarVer  = '0.7.4'
+ext.comsatVer  = '0.6.0-SNAPSHOT'
+ext.capsuleVer = '1.0.1'
 
 
 [compileJava, compileTestJava]*.options*.encoding = "UTF-8"
 [compileJava, compileTestJava]*.options*.encoding = "UTF-8"
 
 
 repositories {
 repositories {
-    // mavenLocal()
     mavenCentral()
     mavenCentral()
+    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
+    // mavenLocal()
 }
 }
 
 
 configurations {
 configurations {
@@ -33,7 +35,7 @@ dependencies {
     compile "co.paralleluniverse:comsat-servlet:$comsatVer"
     compile "co.paralleluniverse:comsat-servlet:$comsatVer"
     compile "co.paralleluniverse:comsat-test-utils:$comsatVer"
     compile "co.paralleluniverse:comsat-test-utils:$comsatVer"
 
 
-    capsule "co.paralleluniverse:capsule:1.0"
+    capsule "co.paralleluniverse:capsule:$capsuleVer"
 
 
     quasar "co.paralleluniverse:quasar-core:$quasarVer:jdk8"
     quasar "co.paralleluniverse:quasar-core:$quasarVer:jdk8"
 }
 }
@@ -43,21 +45,9 @@ task capsule(type: FatCapsule) {
 
 
     capsuleManifest {
     capsuleManifest {
         javaAgents = [configurations.quasar.iterator().next().getName()]
         javaAgents = [configurations.quasar.iterator().next().getName()]
-
-        mode('undertow') {
-            systemProperties['serverClass'] = 'co.paralleluniverse.embedded.containers.UndertowServer'
-        }
-
-        mode('jetty') {
-            systemProperties['serverClass'] = 'co.paralleluniverse.embedded.containers.JettyServer'
-        }
-
-        mode('tomcat') {
-            systemProperties['serverClass'] = 'co.paralleluniverse.embedded.containers.TomcatServer'
-        }
     }
     }
 }
 }
 
 
 task wrapper(type: Wrapper) {
 task wrapper(type: Wrapper) {
-    gradleVersion = '2.7'
+    gradleVersion = '2.11'
 }
 }

BIN
frameworks/Java/comsat-servlet/gradle/wrapper/gradle-wrapper.jar


+ 2 - 2
frameworks/Java/comsat-servlet/gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,6 @@
-#Fri Sep 18 14:31:37 IDT 2015
+#Tue Feb 09 19:18:32 IST 2016
 distributionBase=GRADLE_USER_HOME
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-bin.zip

+ 3 - 7
frameworks/Java/comsat-servlet/gradlew

@@ -42,11 +42,6 @@ case "`uname`" in
     ;;
     ;;
 esac
 esac
 
 
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
-    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
 # Attempt to set APP_HOME
 # Attempt to set APP_HOME
 # Resolve links: $0 may be a link
 # Resolve links: $0 may be a link
 PRG="$0"
 PRG="$0"
@@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do
     fi
     fi
 done
 done
 SAVED="`pwd`"
 SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
+cd "`dirname \"$PRG\"`/" >/dev/null
 APP_HOME="`pwd -P`"
 APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
+cd "$SAVED" >/dev/null
 
 
 CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
 CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
 
 
@@ -114,6 +109,7 @@ fi
 if $cygwin ; then
 if $cygwin ; then
     APP_HOME=`cygpath --path --mixed "$APP_HOME"`
     APP_HOME=`cygpath --path --mixed "$APP_HOME"`
     CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
     CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
 
 
     # We build the pattern for arguments to be converted via cygpath
     # We build the pattern for arguments to be converted via cygpath
     ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
     ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`

+ 1 - 1
frameworks/Java/comsat-servlet/gradlew.bat

@@ -46,7 +46,7 @@ echo location of your Java installation.
 goto fail
 goto fail
 
 
 :init
 :init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
 
 
 if not "%OS%" == "Windows_NT" goto win9xME_args
 if not "%OS%" == "Windows_NT" goto win9xME_args
 if "%@eval[2+2]" == "4" goto 4NT_args
 if "%@eval[2+2]" == "4" goto 4NT_args

+ 0 - 8
frameworks/Java/comsat-servlet/setup-generic.sh

@@ -1,8 +0,0 @@
-#!/bin/bash
-
-fw_depends java
-
-$TROOT/gradlew clean capsule
-
-CAPSULE=`ls build/libs/comsat-servlet-*-capsule.jar`
-java -Dcapsule.mode=$MODE -jar $CAPSULE

+ 0 - 5
frameworks/Java/comsat-servlet/setup-jetty.sh

@@ -1,5 +0,0 @@
-#!/bin/bash
-
-MODE="jetty"
-
-. $TROOT/setup-generic.sh

+ 0 - 5
frameworks/Java/comsat-servlet/setup-tomcat.sh

@@ -1,5 +0,0 @@
-#!/bin/bash
-
-MODE="tomcat"
-
-. $TROOT/setup-generic.sh

+ 0 - 5
frameworks/Java/comsat-servlet/setup-undertow.sh

@@ -1,5 +0,0 @@
-#!/bin/bash
-
-MODE="undertow"
-
-. $TROOT/setup-generic.sh

+ 0 - 1
frameworks/Java/comsat-servlet/setup.sh

@@ -1 +0,0 @@
-setup-undertow.sh

+ 8 - 0
frameworks/Java/comsat-servlet/setup.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+fw_depends java
+
+$TROOT/gradlew clean capsule
+
+CAPSULE=`ls build/libs/comsat-servlet-*-capsule.jar`
+java -jar $CAPSULE

+ 0 - 2
frameworks/Java/comsat-servlet/source_code

@@ -1,4 +1,2 @@
 ./jetty-servlet/src/main/java/hello/
 ./jetty-servlet/src/main/java/hello/
 ./jetty-servlet/src/main/java/hello/HelloWebServer.java
 ./jetty-servlet/src/main/java/hello/HelloWebServer.java
-./jetty-servlet/src/main/java/hello/JsonServlet.java
-./jetty-servlet/src/main/java/hello/PlaintextServlet.java

+ 120 - 38
frameworks/Java/comsat-servlet/src/main/java/hello/HelloWebServer.java

@@ -1,48 +1,130 @@
 package hello;
 package hello;
 
 
 import co.paralleluniverse.embedded.containers.AbstractEmbeddedServer;
 import co.paralleluniverse.embedded.containers.AbstractEmbeddedServer;
-import co.paralleluniverse.embedded.containers.EmbeddedServer;
+import co.paralleluniverse.fibers.Suspendable;
+import co.paralleluniverse.fibers.servlet.FiberHttpServlet;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.undertow.Undertow;
+import io.undertow.UndertowOptions;
+import io.undertow.server.HttpHandler;
+import io.undertow.servlet.Servlets;
+import io.undertow.servlet.api.DeploymentInfo;
+import io.undertow.servlet.api.DeploymentManager;
+import org.xnio.Options;
 
 
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 
 
 /**
 /**
- * An implementation of the TechEmpower benchmark tests using Comsat servlets and the Undertow web server.
+ * An implementation of the TechEmpower benchmark tests using Comsat servlets and the Undertow servlet container.
  */
  */
 public final class HelloWebServer {
 public final class HelloWebServer {
-	public static void main(String[] args) throws Exception {
-		final EmbeddedServer server = (EmbeddedServer) Class.forName(System.getProperty("serverClass")).newInstance();
-		server.addServlet("plaintext", PlaintextServlet.class, "/plaintext");
-		server.addServlet("json", JsonServlet.class, "/json");
-
-		Runtime.getRuntime().addShutdownHook(new Thread() {
-			@Override
-			public void run() {
-				try {
-					server.stop();
-
-					System.err.println("Server is down.");
-				} catch (Exception e) {
-					throw new RuntimeException(e);
-				}
-			}
-		});
-
-		new Thread() {
-			@Override
-			public void run() {
-				try {
-					AbstractEmbeddedServer.waitUrlAvailable("http://localhost:8080/plaintext");
-					AbstractEmbeddedServer.waitUrlAvailable("http://localhost:8080/json");
-
-					System.err.println("Server test cases are instrumented and bootstrapped.");
-				} catch (InterruptedException | IOException e) {
-					throw new RuntimeException(e);
-				}
-			}
-		}.start();
-
-		server.start();
-
-		System.err.println("Server is up.");
-	}
+    private static final class JsonServlet extends FiberHttpServlet {
+        private static final class HelloWorldData {
+            @SuppressWarnings("unused")
+            public final String message = "Hello, World!";
+        }
+
+        private static final ObjectMapper mapper = new ObjectMapper();
+
+        @Override
+        @Suspendable
+        protected final void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+            resp.setContentType("application/json");
+            resp.setHeader("Server", "comsat-servlet-undertow");
+            mapper.writeValue(resp.getOutputStream(), new HelloWorldData());
+        }
+    }
+
+    private static final class PlaintextServlet extends FiberHttpServlet {
+        private static final byte[] helloWorld = "Hello, World!".getBytes(StandardCharsets.ISO_8859_1);
+
+        @Override
+        @Suspendable
+        protected final void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+            resp.setContentType("text/plain");
+            resp.setHeader("Server", "comsat-servlet-undertow");
+            resp.getOutputStream().write(helloWorld);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        final DeploymentInfo deployment = Servlets.deployment().setDeploymentName("")
+            .setClassLoader(ClassLoader.getSystemClassLoader())
+            .setContextPath("/");
+
+        deployment.addServlet(Servlets.servlet("plaintext", PlaintextServlet.class).addMapping("/plaintext").setAsyncSupported(true));
+        deployment.addServlet(Servlets.servlet("json", JsonServlet.class).addMapping("/json").setAsyncSupported(true));
+
+        final DeploymentManager servletsContainer = Servlets.defaultContainer().addDeployment(deployment);
+
+        servletsContainer.deploy();
+
+        final HttpHandler handler = servletsContainer.start();
+
+        //noinspection deprecation
+        final Undertow server = Undertow.builder()
+            .setHandler(handler)
+            .setDirectBuffers(true)
+
+            .setIoThreads(100)
+            .setWorkerThreads(100)
+
+            .setBufferSize(1024)
+            .setBuffersPerRegion(100)
+
+            // .setSocketOption(Options.ALLOW_BLOCKING, true)
+            .setSocketOption(Options.REUSE_ADDRESSES, true)
+            // .setSocketOption(Options.CORK, true)
+            // .setSocketOption(Options.USE_DIRECT_BUFFERS, true)
+            // .setSocketOption(Options.BACKLOG, Integer.MAX_VALUE)
+            // .setSocketOption(Options.RECEIVE_BUFFER, 2048)
+            // .setSocketOption(Options.SEND_BUFFER, 2048)
+            // .setSocketOption(Options.CONNECTION_HIGH_WATER, Integer.MAX_VALUE)
+            // .setSocketOption(Options.CONNECTION_LOW_WATER, Integer.MAX_VALUE)
+            // .setSocketOption(Options.READ_TIMEOUT, Integer.MAX_VALUE)
+            // .setSocketOption(Options.WRITE_TIMEOUT, Integer.MAX_VALUE)
+            // .setServerOption(UndertowOptions.ALWAYS_SET_KEEP_ALIVE, false) //don't send a keep-alive header for HTTP/1.1 requests, as it is not required
+
+            // .setServerOption(UndertowOptions.ALWAYS_SET_DATE, true)
+            .setServerOption(UndertowOptions.ENABLE_CONNECTOR_STATISTICS, false)
+            .setServerOption(UndertowOptions.RECORD_REQUEST_START_TIME, false)
+
+            .addHttpListener(8080, "0.0.0.0")
+            .build();
+
+        server.start();
+
+        System.err.println("Server is up.");
+
+        Runtime.getRuntime().addShutdownHook(new Thread() {
+            @Override
+            public final void run() {
+                try {
+                    server.stop();
+
+                    System.err.println("Server is down.");
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        });
+
+        new Thread() {
+            @Override
+            public final void run() {
+                try {
+                    AbstractEmbeddedServer.waitUrlAvailable("http://localhost:8080/plaintext");
+                    AbstractEmbeddedServer.waitUrlAvailable("http://localhost:8080/json");
+
+                    System.err.println("Server test cases are instrumented and bootstrapped.");
+                } catch (final InterruptedException | IOException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }.start();
+    }
 }
 }

+ 0 - 28
frameworks/Java/comsat-servlet/src/main/java/hello/JsonServlet.java

@@ -1,28 +0,0 @@
-package hello;
-
-import co.paralleluniverse.fibers.Suspendable;
-import co.paralleluniverse.fibers.servlet.FiberHttpServlet;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-public final class JsonServlet extends FiberHttpServlet {
-	private static final class HelloWorldData {
-		@SuppressWarnings("unused")
-		public final String message = "Hello, World!";
-	}
-
-	private static final ObjectMapper mapper = new ObjectMapper();
-
-	@Override
-	@Suspendable
-	protected final void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
-		resp.setContentType("application/json");
-		resp.setHeader("Server", "comsat-servlet");
-		mapper.writeValue(resp.getOutputStream(), new HelloWorldData());
-	}
-}

+ 0 - 22
frameworks/Java/comsat-servlet/src/main/java/hello/PlaintextServlet.java

@@ -1,22 +0,0 @@
-package hello;
-
-import co.paralleluniverse.fibers.Suspendable;
-import co.paralleluniverse.fibers.servlet.FiberHttpServlet;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-
-public final class PlaintextServlet extends FiberHttpServlet {
-	private static final byte[] helloWorld = "Hello, World!".getBytes(StandardCharsets.ISO_8859_1);
-
-	@Override
-	@Suspendable
-	protected final void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
-		resp.setContentType("text/plain");
-		resp.setHeader("Server", "comsat-servlet");
-		resp.getOutputStream().write(helloWorld);
-	}
-}