Эх сурвалжийг харах

Bringing in Curacao 4
- Refactoring to remove SBT, replacing with Maven
- Changing benchmark tests to use Resin, instead of Jetty

Mark Kolich 10 жил өмнө
parent
commit
fe0d9c471b

+ 0 - 2
frameworks/Java/curacao/.gitignore

@@ -1,5 +1,3 @@
-/project/.*
-/project/target
 /target
 /.project
 /.classpath

+ 4 - 5
frameworks/Java/curacao/README.md

@@ -1,10 +1,10 @@
 # Curacao Benchmarking Test
 
-Curacao is an open-source toolkit for building REST/HTTP-based integration layers on top of asynchronous Servlets.
+Curacao is an open-source toolkit for building REST/HTTP-based integration layers on top of asynchronous servlets.
 
 ## Versions
 
-Curacao 2.6.3
+Curacao 4
 https://github.com/markkolich/curacao
 
 ## Tests
@@ -15,11 +15,10 @@ Uses [Google's GSON](https://code.google.com/p/google-gson/) under-the-hood.
 
 See the `json` method in [Benchmarks.java](src/main/java/benchmark/Benchmarks.java)
 
-    http://localhost:8080/json
+    http://localhost:8080/curacao/json
 
 ### Plaintext
 
 See the `plainText` method in [Benchmarks.java](src/main/java/benchmark/Benchmarks.java)
 
-    http://localhost:8080/plaintext
-
+    http://localhost:8080/curacao/plaintext

+ 11 - 11
frameworks/Java/curacao/benchmark_config.json

@@ -1,24 +1,24 @@
 {
-  "framework" : "curacao",
-  "tests" : [{
-    "default" : {
-      "setup_file" : "setup",
-      "json_url" : "/json",
-      "plaintext_url": "/plaintext",
+  "framework": "curacao",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/curacao/json",
+      "plaintext_url": "/curacao/plaintext",
       "port": 8080,
       "approach": "Realistic",
-      "classification": "Micro",
+      "classification": "Platform",
       "database": "None",
       "framework": "curacao",
       "language": "Java",
       "orm": "Raw",
       "platform": "Servlet",
-      "webserver": "None",
+      "webserver": "Resin",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "Curacao",
+      "display_name": "curacao",
       "notes": "",
-      "versus": "jetty"
+      "versus": "servlet"
     }
   }]
-}
+}

+ 0 - 35
frameworks/Java/curacao/build.sbt

@@ -1,35 +0,0 @@
-import AssemblyKeys._
-
-name := "curacao-benchmark"
-
-organization := "com.kolich"
-
-scalaVersion := "2.10.3"
-
-version := "1.0"
-
-resolvers ++= Seq(
-  "markkolich.github.io repo" at "http://markkolich.github.io/repo/"
-)
-
-libraryDependencies ++= Seq(
-  "curacao" % "curacao" % "4.0.0" % "compile",
-  "curacao" % "curacao-gson" % "4.0.0" % "compile",
-  "org.eclipse.jetty" % "jetty-webapp" % "9.2.9.v20150224" % "compile",
-  "javax.servlet" % "javax.servlet-api" % "3.0.1" % "provided",
-  "org.slf4j" % "slf4j-api" % "1.7.2" % "compile",
-  "ch.qos.logback" % "logback-core" % "1.0.7" % "compile",
-  "ch.qos.logback" % "logback-classic" % "1.0.7" % "compile"
-)
-
-classDirectory in Compile <<= baseDirectory(new File(_, "target/classes"))
-
-sbtassembly.Plugin.assemblySettings
-
-mainClass in assembly := Some("benchmark.Bootstrap")
-
-outputPath in assembly := file("dist/curacao-standalone.jar")
-
-assemblyOption in assembly ~= { _.copy(includeScala = false) }
-
-test in assembly := {}

+ 95 - 0
frameworks/Java/curacao/pom.xml

@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>curacao</groupId>
+    <artifactId>techempower-benchmark</artifactId>
+    <name>Curacao</name>
+    <packaging>war</packaging>
+    <version>1.0.0-BUILD-SNAPSHOT</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+
+        <!-- Curacao -->
+        <dependency>
+            <groupId>curacao</groupId>
+            <artifactId>curacao</artifactId>
+            <version>4.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>curacao</groupId>
+            <artifactId>curacao-gson</artifactId>
+            <version>4.0.0</version>
+        </dependency>
+
+        <!-- Servlet -->
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>3.1.0</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <!-- Logback -->
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-core</artifactId>
+            <version>1.1.3</version>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>1.1.3</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <inherited>true</inherited>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.1</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                    <optimize>true</optimize>
+                    <debug>false</debug>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <version>2.6</version>
+                <configuration>
+                    <warName>curacao</warName>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>tomcat-maven-plugin</artifactId>
+                <version>1.1</version>
+            </plugin>
+        </plugins>
+    </build>
+
+    <repositories>
+        <repository>
+            <id>markkolich.github.io</id>
+            <name>markkolich.github.io</name>
+            <url>http://markkolich.github.io/repo</url>
+            <releases />
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </repository>
+    </repositories>
+
+</project>

+ 0 - 1
frameworks/Java/curacao/project/build.properties

@@ -1 +0,0 @@
-sbt.version=0.13.2

+ 0 - 3
frameworks/Java/curacao/project/plugins.sbt

@@ -1,3 +0,0 @@
-addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
-
-addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")

+ 5 - 4
frameworks/Java/curacao/setup.sh

@@ -1,7 +1,8 @@
 #!/bin/bash
 
-fw_depends java sbt
+fw_depends java8 resin maven
 
-sbt assembly
-
-java -jar dist/curacao-standalone.jar &
+mvn clean compile war:war
+rm -rf $RESIN_HOME/webapps/*
+cp target/curacao.war $RESIN_HOME/webapps
+$RESIN_HOME/bin/resinctl start

+ 9 - 1
frameworks/Java/curacao/source_code

@@ -1,5 +1,13 @@
+./curacao/src
+./curacao/src/main
+./curacao/src/main/java
 ./curacao/src/main/java/benchmark
-./curacao/src/main/java/benchmark/Bootstrap.java
 ./curacao/src/main/java/benchmark/Benchmarks.java
 ./curacao/src/main/java/benchmark/entities
 ./curacao/src/main/java/benchmark/entities/HelloWorld.java
+./curacao/src/main/resources
+./curacao/src/main/resources/application.conf
+./curacao/src/main/resources/logback.xml
+./curacao/src/main/webapp
+./curacao/src/main/webapp/WEB-INF
+./curacao/src/main/webapp/WEB-INF/web.xml

+ 2 - 3
frameworks/Java/curacao/src/main/java/benchmark/Benchmarks.java

@@ -3,17 +3,16 @@ package benchmark;
 import benchmark.entities.HelloWorld;
 import curacao.annotations.Controller;
 import curacao.annotations.RequestMapping;
-import curacao.mappers.request.matchers.CuracaoAntPathMatcher;
 
 @Controller
 public final class Benchmarks {
 
-    @RequestMapping(value="/json", matcher=CuracaoAntPathMatcher.class)
+    @RequestMapping("^\\/json$")
     public final HelloWorld json() {
         return new HelloWorld("Hello, World!");
     }
 
-    @RequestMapping(value="/plaintext", matcher=CuracaoAntPathMatcher.class)
+    @RequestMapping("^\\/plaintext$")
     public final String plainText() {
         return "Hello, World!";
     }

+ 0 - 52
frameworks/Java/curacao/src/main/java/benchmark/Bootstrap.java

@@ -1,52 +0,0 @@
-package benchmark;
-
-import curacao.CuracaoContextListener;
-import curacao.CuracaoDispatcherServlet;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.servlet.ServletHolder;
-import org.eclipse.jetty.webapp.WebAppContext;
-
-import java.io.File;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-public final class Bootstrap {
-
-    private static final int DEFAULT_SERVER_LISTEN_PORT = 8080;
-
-    public static void main(final String[] args) throws Exception {
-
-        final File workingDir = getWorkingDir();
-
-        int port;
-        try {
-            port = Integer.parseInt(args[0]);
-        } catch (Exception e) {
-            port = DEFAULT_SERVER_LISTEN_PORT;
-        }
-
-        final Server server = new Server(port);
-
-        final ServletHolder holder = new ServletHolder(CuracaoDispatcherServlet.class);
-        holder.setAsyncSupported(true); // Async supported = true
-        holder.setInitOrder(1); // Load on startup = true
-
-        final WebAppContext context = new WebAppContext();
-        context.addEventListener(new CuracaoContextListener()); // Required
-        context.setContextPath("/");
-        context.setResourceBase(workingDir.getAbsolutePath());
-        context.addServlet(holder, "/*");
-
-        server.setHandler(context);
-
-        server.start();
-        server.join();
-
-    }
-
-    private static final File getWorkingDir() {
-        final Path currentRelativePath = Paths.get("");
-        return currentRelativePath.toAbsolutePath().toFile();
-    }
-
-}

+ 2 - 3
frameworks/Java/curacao/src/main/java/benchmark/entities/HelloWorld.java

@@ -7,14 +7,13 @@ import curacao.gson.GsonAppendableCuracaoEntity;
 
 public final class HelloWorld extends GsonAppendableCuracaoEntity {
 
-    private static final Gson gson__ =
-        new GsonBuilder().serializeNulls().create();
+    private static final Gson gson = new GsonBuilder().serializeNulls().create();
 
     @SerializedName("message")
     private final String message_;
 
     public HelloWorld(final String message) {
-        super(gson__);
+        super(gson);
         message_ = message;
     }
 

+ 4 - 9
frameworks/Java/curacao/src/main/resources/application.conf

@@ -1,12 +1,7 @@
 curacao {
-
   boot-package = "benchmark"
-
-  ## Never timeout.
   async-context-timeout = 0
-
-  ## Both the request and response thread pools are "unbounded" intentionally.
-  pools.request.size = 0
-  pools.response.size = 0
-
-}
+  thread-pool {
+    name-format = "curacao-%d"
+  }
+}

+ 1 - 1
frameworks/Java/curacao/src/main/resources/logback.xml

@@ -12,7 +12,7 @@
         <appender-ref ref="CONSOLE"/>
     </logger>
 
-    <logger name="com.kolich.curacao" additivity="false" level="ERROR">
+    <logger name="curacao" additivity="false" level="ERROR">
         <appender-ref ref="CONSOLE"/>
     </logger>
 

+ 22 - 0
frameworks/Java/curacao/src/main/webapp/WEB-INF/web.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+    version="3.0">
+
+    <listener>
+        <listener-class>curacao.CuracaoContextListener</listener-class>
+    </listener>
+
+	<servlet>
+		<servlet-name>CuracaoDispatcherServlet</servlet-name>
+		<servlet-class>curacao.CuracaoDispatcherServlet</servlet-class>
+		<load-on-startup>1</load-on-startup>
+		<async-supported>true</async-supported>
+	</servlet>
+	<servlet-mapping>
+		<servlet-name>CuracaoDispatcherServlet</servlet-name>
+		<url-pattern>/*</url-pattern>
+	</servlet-mapping>
+	
+</web-app>