Browse Source

Upgrade to spring-boot 1.2.5
and minor corrections in pom.xml, source_code
and WorldDatabaseController.java

Eric Nielsen 10 years ago
parent
commit
0b11a54c86

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

@@ -61,8 +61,7 @@ Check out [SampleApplication, the main Application file](src/main/java/com/teche
 ## Infrastructure Software Versions
 ## Infrastructure Software Versions
 The tests were run with:
 The tests were run with:
 
 
-* [Spring 4.1.4.RELEASE](http://projects.spring.io/spring-framework/)
-* [Spring Boot 1.2.1.RELEASE](http://projects.spring.io/spring-boot/)
-* [Spring Data JPA 1.7.1.RELEASE](http://projects.spring.io/spring-data-jpa/)
-* [Java OpenJDK 1.7.0_09](http://openjdk.java.net/)
-* [Undertow 1.1.1.Final](http://undertow.io/)
+* [Spring 4.1.7.RELEASE](http://projects.spring.io/spring-framework/)
+* [Spring Boot 1.2.5.RELEASE](http://projects.spring.io/spring-boot/)
+* [Spring Data JPA 1.7.3.RELEASE](http://projects.spring.io/spring-data-jpa/)
+* [Undertow 1.1.7.Final](http://undertow.io/)

+ 21 - 12
frameworks/Java/spring/pom.xml

@@ -8,7 +8,7 @@
     <parent>
     <parent>
         <groupId>org.springframework.boot</groupId>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>1.2.1.RELEASE</version>
+        <version>1.2.5.RELEASE</version>
     </parent>
     </parent>
 
 
     <groupId>com.techempower</groupId>
     <groupId>com.techempower</groupId>
@@ -22,19 +22,10 @@
     </properties>
     </properties>
 
 
     <dependencies>
     <dependencies>
-        <dependency>
-            <groupId>com.h2database</groupId>
-            <artifactId>h2</artifactId>
-            <scope>runtime</scope>
-        </dependency>
         <dependency>
         <dependency>
             <groupId>mysql</groupId>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
             <artifactId>mysql-connector-java</artifactId>
         </dependency>
         </dependency>
-        <dependency>
-            <groupId>com.zaxxer</groupId>
-            <artifactId>HikariCP</artifactId>
-        </dependency>
         <dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-jpa</artifactId>
             <artifactId>spring-boot-starter-data-jpa</artifactId>
@@ -54,8 +45,8 @@
         	<artifactId>spring-boot-starter-undertow</artifactId>
         	<artifactId>spring-boot-starter-undertow</artifactId>
         </dependency>
         </dependency>
         <dependency>
         <dependency>
-            <groupId>org.thymeleaf</groupId>
-            <artifactId>thymeleaf-spring4</artifactId>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-thymeleaf</artifactId>
         </dependency>
         </dependency>
     </dependencies>
     </dependencies>
 
 
@@ -76,4 +67,22 @@
             <url>https://jcenter.bintray.com</url>
             <url>https://jcenter.bintray.com</url>
         </repository>
         </repository>
     </repositories>
     </repositories>
+
+    <profiles>
+        <profile>
+            <id>local</id>
+            <activation>
+                <property>
+                    <name>env.SPRING_PROFILES_ACTIVE</name>
+                    <value>local</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>com.h2database</groupId>
+                    <artifactId>h2</artifactId>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
 </project>
 </project>

+ 1 - 1
frameworks/Java/spring/source_code

@@ -6,7 +6,7 @@
 ./spring/src/main/java/com/techempower/spring/web/FortuneController.java
 ./spring/src/main/java/com/techempower/spring/web/FortuneController.java
 ./spring/src/main/java/com/techempower/spring/web/HelloController.java
 ./spring/src/main/java/com/techempower/spring/web/HelloController.java
 ./spring/src/main/java/com/techempower/spring/web/WorldDatabaseController.java
 ./spring/src/main/java/com/techempower/spring/web/WorldDatabaseController.java
+./spring/src/main/java/com/techempower/spring/Common.java
 ./spring/src/main/resources/application.yml
 ./spring/src/main/resources/application.yml
 ./spring/src/main/resources/logback.xml
 ./spring/src/main/resources/logback.xml
-./spring/src/main/resources/schema.sql
 ./spring/src/main/resources/templates/fortunes.html
 ./spring/src/main/resources/templates/fortunes.html

+ 27 - 34
frameworks/Java/spring/src/main/java/com/techempower/spring/web/WorldDatabaseController.java

@@ -29,8 +29,7 @@ final class WorldDatabaseController {
 
 
 	@RequestMapping(value = "/db", produces = "application/json")
 	@RequestMapping(value = "/db", produces = "application/json")
 	World singleQuery() {
 	World singleQuery() {
-		final Random random = ThreadLocalRandom.current();
-		return this.worldRepository.findOne(random.nextInt(DB_ROWS) + 1);
+		return this.worldRepository.findOne(ThreadLocalRandom.current().nextInt(DB_ROWS) + 1);
 	}
 	}
 
 
 	@RequestMapping(value = "/queries", produces = "application/json")
 	@RequestMapping(value = "/queries", produces = "application/json")
@@ -41,15 +40,12 @@ final class WorldDatabaseController {
 		List<Future<World>> wfs = new ArrayList<>(queryCount);
 		List<Future<World>> wfs = new ArrayList<>(queryCount);
 		// it gets better with Java 8, promise!
 		// it gets better with Java 8, promise!
 		for (int i = 0; i < queryCount; i++) {
 		for (int i = 0; i < queryCount; i++) {
-			wfs.add(
-				Common.EXECUTOR.submit(
-					new Callable<World>() {
-						@Override
-						public World call() throws Exception {
-							return worldRepository.findOne(
-								ThreadLocalRandom.current().nextInt(DB_ROWS) + 1);
-						}
-					}));
+			wfs.add(Common.EXECUTOR.submit(new Callable<World>() {
+				@Override
+				public World call() throws Exception {
+					return worldRepository.findOne(ThreadLocalRandom.current().nextInt(DB_ROWS) + 1);
+				}
+			}));
 		}
 		}
 
 
 		return waitFor(wfs);
 		return waitFor(wfs);
@@ -57,23 +53,22 @@ final class WorldDatabaseController {
 
 
 	@RequestMapping(value = "/updates", produces = "application/json")
 	@RequestMapping(value = "/updates", produces = "application/json")
 	List<World> updateQueries(@RequestParam(value="queries", required=false, defaultValue="1") String rawQueryCount) {
 	List<World> updateQueries(@RequestParam(value="queries", required=false, defaultValue="1") String rawQueryCount) {
-		Integer queryCount = boundQueryCount(rawQueryCount);
+		int queryCount = boundQueryCount(rawQueryCount);
 
 
 		List<Future<World>> wfs = new ArrayList<>(queryCount);
 		List<Future<World>> wfs = new ArrayList<>(queryCount);
 
 
 		for (int i = 0; i < queryCount; i++) {
 		for (int i = 0; i < queryCount; i++) {
-			wfs.add(Common.EXECUTOR.submit(
-				new Callable<World>() {
-					@Override
-					@Transactional(propagation = Propagation.REQUIRES_NEW)
-					public World call() throws Exception {
-						Random random = ThreadLocalRandom.current();
-						World world = worldRepository.findOne(random.nextInt(DB_ROWS) + 1);
-						world.setRandomNumber(random.nextInt(DB_ROWS) + 1);
-						worldRepository.save(world);
-						return world;
-					}
-				}));
+			wfs.add(Common.EXECUTOR.submit(new Callable<World>() {
+				@Override
+				@Transactional(propagation = Propagation.REQUIRES_NEW)
+				public World call() throws Exception {
+					Random random = ThreadLocalRandom.current();
+					World world = worldRepository.findOne(random.nextInt(DB_ROWS) + 1);
+					world.setRandomNumber(random.nextInt(DB_ROWS) + 1);
+					worldRepository.save(world);
+					return world;
+				}
+			}));
 		}
 		}
 
 
 		return waitFor(wfs);
 		return waitFor(wfs);
@@ -91,19 +86,17 @@ final class WorldDatabaseController {
 		return worlds;
 		return worlds;
 	}
 	}
 
 
-	private Integer boundQueryCount(final String rawString) {
-		Integer raw;
+	private int boundQueryCount(final String rawString) {
 		try {
 		try {
-			raw = Integer.parseInt(rawString);
+			int raw = Integer.parseInt(rawString);
+			if (raw < 1) {
+				return 1;
+			} else if (raw > 500) {
+				return 500;
+			}
+			return raw;
 		} catch (NumberFormatException e) {
 		} catch (NumberFormatException e) {
-			raw = null;
-		}
-		if (raw == null || raw < 1) {
 			return 1;
 			return 1;
-		} else if (raw > 500) {
-			return 500;
 		}
 		}
-
-		return raw;
 	}
 	}
 }
 }

+ 1 - 0
frameworks/Java/spring/src/main/resources/application.yml

@@ -22,4 +22,5 @@ spring:
     url: jdbc:h2:mem:framework_benchmark
     url: jdbc:h2:mem:framework_benchmark
   jpa:
   jpa:
     hibernate:
     hibernate:
+      naming-strategy: org.hibernate.cfg.EJB3NamingStrategy
       ddl-auto: create-drop
       ddl-auto: create-drop