Browse Source

Split play-java into play-java and play-java-ebean

The directory was previously called 'play-java' and the display name
was 'play-java-ebean'. They are now split as follows:
* a non-database part with a directory and display name of
  'play-java'.
* a database/ebean part with a directory and display name of
  'play-java-ebean'.
Rich Dougherty 11 years ago
parent
commit
7929b9e5a4

+ 1 - 0
.travis.yml

@@ -99,6 +99,7 @@ env:
     - TESTDIR=play1siena
     - TESTDIR=play1siena
     - TESTDIR=play-activate-mysql
     - TESTDIR=play-activate-mysql
     - TESTDIR=play-java
     - TESTDIR=play-java
+    - TESTDIR=play-java-ebean
     - TESTDIR=play-java-jpa
     - TESTDIR=play-java-jpa
     - TESTDIR=play-scala
     - TESTDIR=play-scala
     - TESTDIR=play-scala-mongodb
     - TESTDIR=play-scala-mongodb

+ 30 - 0
play-java-ebean/.gitignore

@@ -0,0 +1,30 @@
+logs
+project/project
+project/target
+target
+tmp
+.history
+dist
+
+# Ignore all dotfiles...
+.*
+# except for .gitignore
+!.gitignore
+
+# Ignore Play! working directory #
+db
+eclipse
+lib
+log
+logs
+modules
+precompiled
+project/project
+project/target
+target
+tmp
+test-result
+server.pid
+*.iml
+*.eml
+

+ 20 - 0
play-java-ebean/README.md

@@ -0,0 +1,20 @@
+#Play Benchmarking Test
+
+This is the Play portion of a [benchmarking test suite](../) comparing a variety of web development platforms.
+
+### Data-Store/Database Mapping Test
+
+* [Database test controller](app/controllers/Application.java)
+* [Database test model](app/models/World.java)
+
+## Infrastructure Software Versions
+The tests were run with:
+
+* [Java OpenJDK 1.7](http://openjdk.java.net/)
+* [Play 2.2.0](http://http://www.playframework.com/)
+
+## Test URLs
+
+### Data-Store/Database Mapping Test
+
+http://localhost/db?queries=5

+ 0 - 0
play-java-ebean/__init__.py


+ 71 - 0
play-java-ebean/app/controllers/Application.java

@@ -0,0 +1,71 @@
+package controllers;
+
+import akka.dispatch.ExecutionContexts;
+import models.World;
+import play.Play;
+import play.core.NamedThreadFactory;
+import play.libs.F;
+import play.libs.Json;
+
+import play.mvc.Controller;
+import play.mvc.Result;
+import scala.concurrent.ExecutionContext;
+import utils.Predicate;
+import utils.Predicated;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.*;
+
+public class Application extends Controller {
+
+    private static final int MAX_QUERIES_PER_REQUEST = 20;
+    private static final int TEST_DATABASE_ROWS = 10000;
+
+    private static final int partitionCount = Play.application().configuration().getInt("db.default.partitionCount");
+    private static final int maxConnections =
+            partitionCount * Play.application().configuration().getInt("db.default.maxConnectionsPerPartition");
+    private static final int minConnections =
+            partitionCount * Play.application().configuration().getInt("db.default.minConnectionsPerPartition");
+
+    private static final ThreadPoolExecutor tpe = new ThreadPoolExecutor(minConnections, maxConnections,
+            0L, TimeUnit.MILLISECONDS,
+            new LinkedBlockingQueue<Runnable>(),
+            new NamedThreadFactory("dbEc"));
+    private static final ExecutionContext dbEc = ExecutionContexts.fromExecutorService(tpe);
+
+    // A predicate for checking our ability to service database requests is determined by ensuring that the request
+    // queue doesn't fill up beyond a certain threshold. For convenience we use the max number of connections * the max
+    // # of db requests per web request to determine this threshold. It is a rough check as we don't know how many
+    // queries we're going to make or what other threads are running in parallel etc. Nevertheless, the check is
+    // adequate in order to throttle the acceptance of requests to the size of the pool.
+    public static class IsDbAvailable implements Predicate {
+        @Override
+        public boolean condition() {
+            return tpe.getQueue().size() < maxConnections * MAX_QUERIES_PER_REQUEST;
+        }
+    }
+
+    @Predicated(predicate = IsDbAvailable.class, failed = SERVICE_UNAVAILABLE)
+    public static F.Promise<Result> db(final Integer queries) {
+        final Random random = ThreadLocalRandom.current();
+        final List<F.Promise<? extends World>> promises = new ArrayList<F.Promise<? extends World>>(queries);
+        for (int i = 0; i < queries; ++i) {
+            final F.Promise<World> p = F.Promise.promise(new F.Function0<World>() {
+                @Override
+                public World apply() throws Throwable {
+                    return World.find.byId(Long.valueOf(random.nextInt(TEST_DATABASE_ROWS) + 1));
+                }
+            }, dbEc);
+            promises.add(p);
+        }
+        return F.Promise.sequence(promises).map(new F.Function<List<World>, Result>() {
+            @Override
+            public Result apply(List<World> worlds) {
+                return ok(Json.toJson(worlds));
+            }
+        });
+    }
+
+}

+ 0 - 0
play-java/app/models/World.java → play-java-ebean/app/models/World.java


+ 0 - 0
play-java/app/utils/Predicate.java → play-java-ebean/app/utils/Predicate.java


+ 0 - 0
play-java/app/utils/Predicated.java → play-java-ebean/app/utils/Predicated.java


+ 0 - 0
play-java/app/utils/PredicatedAction.java → play-java-ebean/app/utils/PredicatedAction.java


+ 24 - 0
play-java-ebean/benchmark_config

@@ -0,0 +1,24 @@
+{
+  "framework": "play-java-ebean",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "db_url": "/db",
+      "query_url": "/db?queries=",
+      "port": 9000,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "MySQL",
+      "framework": "play2",
+      "language": "Java",
+      "orm": "Full",
+      "platform": "Netty",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "play-java-ebean",
+      "notes": "",
+      "versus": "netty"
+    }
+  }]
+}

+ 13 - 0
play-java-ebean/build.sbt

@@ -0,0 +1,13 @@
+name := "play-java-ebean"
+
+version := "1.0-SNAPSHOT"
+
+libraryDependencies ++= Seq(
+  javaJdbc,
+  javaEbean,
+  "mysql" % "mysql-connector-java" % "5.1.22"
+  )
+
+dependencyOverrides += "com.jolbox" % "bonecp" % "0.7.1.RELEASE"
+
+playJavaSettings

+ 74 - 0
play-java-ebean/conf/application.conf

@@ -0,0 +1,74 @@
+# This is the main configuration file for the application.
+# ~~~~~
+
+# Secret key
+# ~~~~~
+# The secret key is used to secure cryptographics functions.
+# If you deploy your application to several instances be sure to use the same key!
+application.secret="RItx1I:80?W@]8GAtPDuF8Ydd3mXM85p/<7og]Q;uBOdijQAauRDgu73B6`wQP59"
+
+# The application languages
+# ~~~~~
+application.langs="en"
+
+# Global object class
+# ~~~~~
+# Define the Global object class for this application.
+# Default to Global in the root package.
+# global=Global
+
+# Database configuration
+# ~~~~~ 
+# You can declare as many datasources as you want.
+# By convention, the default datasource is named `default`
+#
+# db.default.driver=org.h2.Driver
+# db.default.url="jdbc:h2:mem:play"
+# db.default.user=sa
+# db.default.password=
+#
+# You can expose this datasource via JNDI if needed (Useful for JPA)
+# db.default.jndiName=DefaultDS
+db.default.driver= com.mysql.jdbc.Driver
+db.default.url="jdbc:mysql://localhost:3306/hello_world?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useUnbufferedInput=false&useReadAheadInput=false&maintainTimeStats=false&useServerPrepStmts&cacheRSMetadata=true"
+db.default.user=benchmarkdbuser
+db.default.password=benchmarkdbpass
+db.default.jndiName=DefaultDS
+
+db.default.partitionCount=4
+
+# The number of connections to create per partition. Setting this to 
+# 5 with 3 partitions means you will have 15 unique connections to the 
+# database. Note that BoneCP will not create all these connections in 
+# one go but rather start off with minConnectionsPerPartition and 
+# gradually increase connections as required.
+db.default.maxConnectionsPerPartition=64
+
+# The number of initial connections, per partition.
+db.default.minConnectionsPerPartition=64
+
+# Evolutions
+# ~~~~~
+# You can disable evolutions if needed
+evolutionplugin=disabled
+
+# Ebean configuration
+# ~~~~~
+# You can declare as many Ebean servers as you want.
+# By convention, the default server is named `default`
+#
+ebean.default="models.*"
+
+# Logger
+# ~~~~~
+# You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory .
+
+# Root logger:
+logger.root=ERROR
+
+# Logger used by the framework:
+logger.play=ERROR
+
+# Logger provided to your application:
+logger.application=ERROR
+

+ 9 - 0
play-java-ebean/conf/routes

@@ -0,0 +1,9 @@
+# Routes
+# This file defines all application routes (Higher priority routes first)
+# ~~~~
+
+# Home page
+GET     /db                             controllers.Application.db(queries: Int ?= 1)
+
+# Map static resources from the /public folder to the /assets URL path
+GET     /assets/*file               controllers.Assets.at(path="/public", file)

+ 1 - 0
play-java-ebean/project/build.properties

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

+ 8 - 0
play-java-ebean/project/plugins.sbt

@@ -0,0 +1,8 @@
+// Comment to get more information during initialization
+logLevel := Level.Warn
+
+// The Typesafe repository 
+resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
+
+// Use the Play sbt plugin for Play projects
+addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.0")

+ 12 - 0
play-java-ebean/setup.py

@@ -0,0 +1,12 @@
+import setup_util
+import subprocess
+
+def start(args, logfile, errfile):
+  setup_util.replace_text("play-java-ebean/conf/application.conf", "jdbc:mysql:\/\/.*:3306", "jdbc:mysql://" + args.database_host + ":3306")
+  subprocess.Popen(["play","start"], stdin=subprocess.PIPE, cwd="play-java-ebean", stderr=errfile, stdout=logfile)
+  return 0
+
+def stop(logfile, errfile):
+  p = subprocess.Popen(["play","stop"], cwd="play-java-ebean", stderr=errfile, stdout=logfile)
+  p.communicate()
+  return 0

+ 9 - 0
play-java-ebean/source_code

@@ -0,0 +1,9 @@
+./play-java/app/
+./play-java/app/controllers
+./play-java/app/controllers/Application.java
+./play-java/app/utils
+./play-java/app/utils/Predicate.java
+./play-java/app/utils/PredicatedAction.java
+./play-java/app/utils/Predicated.java
+./play-java/app/models
+./play-java/app/models/World.java

+ 2 - 11
play-java/README.md

@@ -6,22 +6,13 @@ This is the Play portion of a [benchmarking test suite](../) comparing a variety
 
 
 * [JSON test source](app/controllers/Application.java)
 * [JSON test source](app/controllers/Application.java)
 
 
-### Data-Store/Database Mapping Test
-
-* [Database test controller](app/controllers/Application.java)
-* [Database test model](app/models/World.java)
-
 ## Infrastructure Software Versions
 ## Infrastructure Software Versions
 The tests were run with:
 The tests were run with:
 
 
 * [Java OpenJDK 1.7.0_09](http://openjdk.java.net/)
 * [Java OpenJDK 1.7.0_09](http://openjdk.java.net/)
-* [Play 2.1.0](http://http://www.playframework.com/)
+* [Play 2](http://http://www.playframework.com/)
 
 
 ## Test URLs
 ## Test URLs
 ### JSON Encoding Test
 ### JSON Encoding Test
 
 
-http://localhost/json
-
-### Data-Store/Database Mapping Test
-
-http://localhost/db?queries=5
+http://localhost/json

+ 0 - 62
play-java/app/controllers/Application.java

@@ -1,81 +1,19 @@
 package controllers;
 package controllers;
 
 
-import akka.dispatch.ExecutionContexts;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
-import models.World;
-import play.Play;
-import play.core.NamedThreadFactory;
-import play.libs.F;
-import play.libs.Json;
-
 import play.mvc.Controller;
 import play.mvc.Controller;
 import play.mvc.Result;
 import play.mvc.Result;
-import scala.concurrent.ExecutionContext;
-import utils.Predicate;
-import utils.Predicated;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.*;
 
 
 public class Application extends Controller {
 public class Application extends Controller {
 
 
-    private static final int MAX_QUERIES_PER_REQUEST = 20;
-    private static final int TEST_DATABASE_ROWS = 10000;
     //http://stackoverflow.com/questions/3907929/should-i-make-jacksons-objectmapper-as-static-final
     //http://stackoverflow.com/questions/3907929/should-i-make-jacksons-objectmapper-as-static-final
     private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
     private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
 
 
-    private static final int partitionCount = Play.application().configuration().getInt("db.default.partitionCount");
-    private static final int maxConnections =
-            partitionCount * Play.application().configuration().getInt("db.default.maxConnectionsPerPartition");
-    private static final int minConnections =
-            partitionCount * Play.application().configuration().getInt("db.default.minConnectionsPerPartition");
-
-    private static final ThreadPoolExecutor tpe = new ThreadPoolExecutor(minConnections, maxConnections,
-            0L, TimeUnit.MILLISECONDS,
-            new LinkedBlockingQueue<Runnable>(),
-            new NamedThreadFactory("dbEc"));
-    private static final ExecutionContext dbEc = ExecutionContexts.fromExecutorService(tpe);
-
-    // A predicate for checking our ability to service database requests is determined by ensuring that the request
-    // queue doesn't fill up beyond a certain threshold. For convenience we use the max number of connections * the max
-    // # of db requests per web request to determine this threshold. It is a rough check as we don't know how many
-    // queries we're going to make or what other threads are running in parallel etc. Nevertheless, the check is
-    // adequate in order to throttle the acceptance of requests to the size of the pool.
-    public static class IsDbAvailable implements Predicate {
-        @Override
-        public boolean condition() {
-            return tpe.getQueue().size() < maxConnections * MAX_QUERIES_PER_REQUEST;
-        }
-    }
-
     public static Result json() {
     public static Result json() {
         final ObjectNode result = OBJECT_MAPPER.createObjectNode();
         final ObjectNode result = OBJECT_MAPPER.createObjectNode();
         result.put("message", "Hello, World!");
         result.put("message", "Hello, World!");
         return ok(result);
         return ok(result);
     }
     }
 
 
-    @Predicated(predicate = IsDbAvailable.class, failed = SERVICE_UNAVAILABLE)
-    public static F.Promise<Result> db(final Integer queries) {
-        final Random random = ThreadLocalRandom.current();
-        final List<F.Promise<? extends World>> promises = new ArrayList<F.Promise<? extends World>>(queries);
-        for (int i = 0; i < queries; ++i) {
-            final F.Promise<World> p = F.Promise.promise(new F.Function0<World>() {
-                @Override
-                public World apply() throws Throwable {
-                    return World.find.byId(Long.valueOf(random.nextInt(TEST_DATABASE_ROWS) + 1));
-                }
-            }, dbEc);
-            promises.add(p);
-        }
-        return F.Promise.sequence(promises).map(new F.Function<List<World>, Result>() {
-            @Override
-            public Result apply(List<World> worlds) {
-                return ok(Json.toJson(worlds));
-            }
-        });
-    }
-
 }
 }

+ 3 - 5
play-java/benchmark_config

@@ -1,15 +1,13 @@
 {
 {
-  "framework": "play2",
+  "framework": "play-java",
   "tests": [{
   "tests": [{
     "default": {
     "default": {
       "setup_file": "setup",
       "setup_file": "setup",
       "json_url": "/json",
       "json_url": "/json",
-      "db_url": "/db",
-      "query_url": "/db?queries=",
       "port": 9000,
       "port": 9000,
       "approach": "Realistic",
       "approach": "Realistic",
       "classification": "Fullstack",
       "classification": "Fullstack",
-      "database": "MySQL",
+      "database": "None",
       "framework": "play2",
       "framework": "play2",
       "language": "Java",
       "language": "Java",
       "orm": "Full",
       "orm": "Full",
@@ -17,7 +15,7 @@
       "webserver": "None",
       "webserver": "None",
       "os": "Linux",
       "os": "Linux",
       "database_os": "Linux",
       "database_os": "Linux",
-      "display_name": "play-java-ebean",
+      "display_name": "play-java",
       "notes": "",
       "notes": "",
       "versus": "netty"
       "versus": "netty"
     }
     }

+ 0 - 8
play-java/build.sbt

@@ -2,12 +2,4 @@ name := "play-java"
 
 
 version := "1.0-SNAPSHOT"
 version := "1.0-SNAPSHOT"
 
 
-libraryDependencies ++= Seq(
-  javaJdbc,
-  javaEbean,
-  "mysql" % "mysql-connector-java" % "5.1.22"
-  )
-
-dependencyOverrides += "com.jolbox" % "bonecp" % "0.7.1.RELEASE"
-
 playJavaSettings
 playJavaSettings

+ 0 - 48
play-java/conf/application.conf

@@ -11,54 +11,6 @@ application.secret="RItx1I:80?W@]8GAtPDuF8Ydd3mXM85p/<7og]Q;uBOdijQAauRDgu73B6`w
 # ~~~~~
 # ~~~~~
 application.langs="en"
 application.langs="en"
 
 
-# Global object class
-# ~~~~~
-# Define the Global object class for this application.
-# Default to Global in the root package.
-# global=Global
-
-# Database configuration
-# ~~~~~ 
-# You can declare as many datasources as you want.
-# By convention, the default datasource is named `default`
-#
-# db.default.driver=org.h2.Driver
-# db.default.url="jdbc:h2:mem:play"
-# db.default.user=sa
-# db.default.password=
-#
-# You can expose this datasource via JNDI if needed (Useful for JPA)
-# db.default.jndiName=DefaultDS
-db.default.driver= com.mysql.jdbc.Driver
-db.default.url="jdbc:mysql://localhost:3306/hello_world?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useUnbufferedInput=false&useReadAheadInput=false&maintainTimeStats=false&useServerPrepStmts&cacheRSMetadata=true"
-db.default.user=benchmarkdbuser
-db.default.password=benchmarkdbpass
-db.default.jndiName=DefaultDS
-
-db.default.partitionCount=4
-
-# The number of connections to create per partition. Setting this to 
-# 5 with 3 partitions means you will have 15 unique connections to the 
-# database. Note that BoneCP will not create all these connections in 
-# one go but rather start off with minConnectionsPerPartition and 
-# gradually increase connections as required.
-db.default.maxConnectionsPerPartition=64
-
-# The number of initial connections, per partition.
-db.default.minConnectionsPerPartition=64
-
-# Evolutions
-# ~~~~~
-# You can disable evolutions if needed
-# evolutionplugin=disabled
-
-# Ebean configuration
-# ~~~~~
-# You can declare as many Ebean servers as you want.
-# By convention, the default server is named `default`
-#
-ebean.default="models.*"
-
 # Logger
 # Logger
 # ~~~~~
 # ~~~~~
 # You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory .
 # You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory .

+ 0 - 1
play-java/conf/routes

@@ -4,7 +4,6 @@
 
 
 # Home page
 # Home page
 GET     /json                           controllers.Application.json
 GET     /json                           controllers.Application.json
-GET     /db                             controllers.Application.db(queries: Int ?= 1)
 
 
 # Map static resources from the /public folder to the /assets URL path
 # Map static resources from the /public folder to the /assets URL path
 GET     /assets/*file               controllers.Assets.at(path="/public", file)
 GET     /assets/*file               controllers.Assets.at(path="/public", file)

+ 0 - 1
play-java/setup.py

@@ -2,7 +2,6 @@ import setup_util
 import subprocess
 import subprocess
 
 
 def start(args, logfile, errfile):
 def start(args, logfile, errfile):
-  setup_util.replace_text("play-java/conf/application.conf", "jdbc:mysql:\/\/.*:3306", "jdbc:mysql://" + args.database_host + ":3306")
   subprocess.Popen(["play","start"], stdin=subprocess.PIPE, cwd="play-java", stderr=errfile, stdout=logfile)
   subprocess.Popen(["play","start"], stdin=subprocess.PIPE, cwd="play-java", stderr=errfile, stdout=logfile)
   return 0
   return 0