Browse Source

Merge pull request #1350 from codylerum/wildfly-8.2

Java: Update wildfly to 8.2
Hamilton Turner 10 years ago
parent
commit
eb1c7e0e1e

+ 2 - 0
frameworks/Java/wildfly-ee7/benchmark_config

@@ -3,6 +3,8 @@
   "tests": [{
     "mysql" : {
       "setup_file": "setup",
+      "json_url": "/wildfly-ee7/rest/json",
+      "plaintext_url": "/wildfly-ee7/rest/plaintext",
       "db_url": "/wildfly-ee7/rest/db",
       "query_url": "/wildfly-ee7/rest/queries?queries=",
       "fortune_url": "/wildfly-ee7/fortunes.xhtml",

+ 2 - 2
frameworks/Java/wildfly-ee7/pom.xml

@@ -12,8 +12,8 @@
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		<version.compiler.plugin>3.1</version.compiler.plugin>
 		<version.war.plugin>2.4</version.war.plugin>
-		<version.wildfly>8.1.0.Final</version.wildfly>
-		<version.mysql.connector>5.1.29</version.mysql.connector>
+		<version.wildfly>8.2.0.Final</version.wildfly>
+		<version.mysql.connector>5.1.34</version.mysql.connector>
 		<version.javaee.api>7.0</version.javaee.api>
 		<version.jboss.spec.javaee.7.0>1.0.0.Final</version.jboss.spec.javaee.7.0>
 	</properties>

+ 1 - 1
frameworks/Java/wildfly-ee7/server-resources/datasources/mysql-ds.xml

@@ -2,7 +2,7 @@
 <datasources xmlns="http://www.jboss.org/ironjacamar/schema">
     <datasource jta="true" jndi-name="java:jboss/datasources/helloWorld" pool-name="MySqlDS" enabled="true" use-java-context="true" use-ccm="true">
 		<connection-url>jdbc:mysql://${database.host}:3306/hello_world?jdbcCompliantTruncation=false&amp;elideSetAutoCommits=true&amp;useLocalSessionState=true&amp;cachePrepStmts=true&amp;cacheCallableStmts=true&amp;alwaysSendSetIsolation=false&amp;prepStmtCacheSize=4096&amp;cacheServerConfiguration=true&amp;prepStmtCacheSqlLimit=2048&amp;traceProtocol=false&amp;useServerPrepStmts=true&amp;enableQueryTimeouts=false&amp;useUnbufferedIO=false&amp;useReadAheadInput=false&amp;maintainTimeStats=false&amp;cacheRSMetadata=true</connection-url>
-		<driver>mysql-connector-java-${version.mysql.connector}.jar</driver>
+		<driver>mysql-connector-java-${version.mysql.connector}.jar_com.mysql.jdbc.Driver_5_1</driver>
 		<pool>
 		    <prefill>false</prefill>
 		    <min-pool-size>32</min-pool-size>

+ 1 - 1
frameworks/Java/wildfly-ee7/setup.sh

@@ -3,4 +3,4 @@
 export JAVA_OPTS="-Xms2g -Xmx2g -XX:MaxPermSize=256m -XX:+UseG1GC -XX:MaxGCPauseMillis=25 -verbosegc -Xloggc:/tmp/wildfly_gc.log"
 
 mvn clean initialize package -Pbenchmark -Ddatabase.host=${DBHOST}
-target/wildfly-8.1.0.Final/bin/standalone.sh -b 0.0.0.0 &
+target/wildfly-8.2.0.Final/bin/standalone.sh -b 0.0.0.0 &

+ 8 - 17
frameworks/Java/wildfly-ee7/src/main/java/com/techempower/ee7/jpa/PersistenceResources.java

@@ -1,27 +1,18 @@
 package com.techempower.ee7.jpa;
 
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.inject.Disposes;
+import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.Produces;
 import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.PersistenceUnit;
-import javax.persistence.SynchronizationType;
+import javax.persistence.PersistenceContext;
 
 public class PersistenceResources {
 
-  @PersistenceUnit
-  private EntityManagerFactory entityManagerFactory;
+    @PersistenceContext
+    private EntityManager em;
 
-  @Produces
-  @RequestScoped
-  public EntityManager entityManager() {
-    return entityManagerFactory.createEntityManager(SynchronizationType.UNSYNCHRONIZED);
-  }
-
-  protected void closeEntityManager(@Disposes EntityManager entityManager) {
-    if (entityManager.isOpen()) {
-      entityManager.close();
+    @Produces
+    @Dependent
+    public EntityManager entityManager() {
+        return em;
     }
-  }
 }

+ 6 - 8
frameworks/Java/wildfly-ee7/src/main/java/com/techempower/ee7/rest/CatchAllExceptionMapper.java

@@ -1,6 +1,5 @@
 package com.techempower.ee7.rest;
 
-import javax.inject.Inject;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 import javax.ws.rs.ext.ExceptionMapper;
@@ -11,12 +10,11 @@ import org.jboss.logging.Logger;
 @Provider
 public class CatchAllExceptionMapper implements ExceptionMapper<Exception> {
 
-  @Inject
-  private Logger log;
+    static final Logger log = Logger.getLogger(CatchAllExceptionMapper.class);
 
-  @Override
-  public Response toResponse(Exception exception) {
-    log.info("Request Failed: " + exception.getMessage());
-    return Response.status(Status.BAD_REQUEST).build();
-  }
+    @Override
+    public Response toResponse(Exception exception) {
+        log.info("Request Failed: " + exception.getMessage());
+        return Response.status(Status.BAD_REQUEST).build();
+    }
 }

+ 34 - 36
frameworks/Java/wildfly-ee7/src/main/java/com/techempower/ee7/tests/Updates.java

@@ -21,41 +21,39 @@ import com.techempower.ee7.util.Helpers;
 @Path("/updates")
 public class Updates {
 
-  private static final int MIN_QUERIES = 1;
-  private static final int MAX_QUERIES = 500;
-
-  @Inject
-  private EntityManager em;
-
-  @Inject
-  private Logger log;
-
-  @Transactional
-  @GET
-  @Produces(MediaType.APPLICATION_JSON)
-  public List<World> update(@QueryParam("queries") final String queries) {
-    final int iterations =
-        Helpers.boundedIntegerFromNullableString(queries, MIN_QUERIES, MAX_QUERIES);
-
-    List<World> worlds = new ArrayList<>(iterations);
-
-    for (int i = 0; i < iterations; i++) {
-      int id = Helpers.randomWorldId();
-      worlds.add(em.find(World.class, id));
-    }
-
-    for (World w : worlds) {
-      w.getRandomNumber(); // Mandatory to read for the test
-      w.setRandomNumber(Helpers.randomWorldId());
-    }
-
-    try {
-      em.joinTransaction();
-      em.flush();
-    } catch (PersistenceException e) {
-      log.info("Failed to flush changes to database.");
-      throw e;
+    private static final Logger log = Logger.getLogger(Updates.class);
+
+    private static final int MIN_QUERIES = 1;
+    private static final int MAX_QUERIES = 500;
+
+    @Inject
+    private EntityManager em;
+
+    @Transactional
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public List<World> update(@QueryParam("queries") final String queries) {
+        final int iterations = Helpers.boundedIntegerFromNullableString(queries, MIN_QUERIES, MAX_QUERIES);
+
+        List<World> worlds = new ArrayList<>(iterations);
+
+        for (int i = 0; i < iterations; i++) {
+            int id = Helpers.randomWorldId();
+            worlds.add(em.find(World.class, id));
+        }
+
+        for (World w : worlds) {
+            w.getRandomNumber(); // Mandatory to read for the test
+            w.setRandomNumber(Helpers.randomWorldId());
+        }
+
+        try {
+            em.flush();
+        }
+        catch (PersistenceException e) {
+            log.info("Failed to flush changes to database.");
+            throw e;
+        }
+        return worlds;
     }
-    return worlds;
-  }
 }

+ 28 - 27
frameworks/Java/wildfly-ee7/src/main/java/com/techempower/ee7/util/Helpers.java

@@ -4,33 +4,34 @@ import java.util.concurrent.ThreadLocalRandom;
 
 public class Helpers {
 
-  /**
-   * Random number between 1 and 10,000
-   * 
-   * @return
-   */
-  public static int randomWorldId() {
-    return ThreadLocalRandom.current().nextInt(1, 10001);
-  }
+    /**
+     * Random number between 1 and 10,000
+     * 
+     * @return
+     */
+    public static int randomWorldId() {
+        return ThreadLocalRandom.current().nextInt(1, 10001);
+    }
 
-  /**
-   * Returns a bounded integer. min if null or less than bounds. max if greater than bounds
-   * 
-   * @param value
-   * @param min
-   * @param max
-   * @return
-   */
-  public static int boundedIntegerFromNullableString(final String value, final int min,
-      final int max) {
-    if (value == null) {
-      return min;
-    } else {
-      try {
-        return Math.min(max, Math.max(min, Integer.parseInt(value)));
-      } catch (NumberFormatException e) {
-        return min;
-      }
+    /**
+     * Returns a bounded integer. min if null or less than bounds. max if greater than bounds
+     * 
+     * @param value
+     * @param min
+     * @param max
+     * @return
+     */
+    public static int boundedIntegerFromNullableString(final String value, final int min, final int max) {
+        if (value == null) {
+            return min;
+        }
+        else {
+            try {
+                return Math.min(max, Math.max(min, Integer.parseInt(value)));
+            }
+            catch (NumberFormatException e) {
+                return min;
+            }
+        }
     }
-  }
 }

+ 0 - 15
frameworks/Java/wildfly-ee7/src/main/java/com/techempower/ee7/util/LoggerProducer.java

@@ -1,15 +0,0 @@
-package com.techempower.ee7.util;
-
-import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.InjectionPoint;
-
-import org.jboss.logging.Logger;
-
-public class LoggerProducer {
-
-  @Produces
-  Logger produceLog(InjectionPoint injectionPoint) {
-    return Logger.getLogger(injectionPoint.getBean() != null ? injectionPoint.getBean()
-        .getBeanClass() : injectionPoint.getMember().getDeclaringClass());
-  }
-}