Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frameworks/Java/officefloor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/production/
28 changes: 28 additions & 0 deletions frameworks/Java/officefloor/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"framework": "officefloor",
"tests": [{
"default": {
"setup_file": "setup",
"json_url": "/json-service.woof",
"db_url": "/singleQuery-service.woof",
"query_url": "/multipleQueries-service.woof?queries=",
"fortune_url": "/fortune.woof",
"update_url": "/databaseUpdate-service.woof?queries=",
"plaintext_url": "/plaintext.woof",
"port": 7878,
"approach": "Realistic",
"classification": "Fullstack",
"database": "MySQL",
"framework": "officefloor",
"language": "Java",
"orm": "Full",
"platform": "OfficeFloor",
"webserver": "WoOF (Web on OfficeFloor)",
"os": "Linux",
"database_os": "Linux",
"display_name": "officefloor",
"notes": "",
"versus": ""
}
}]
}
119 changes: 119 additions & 0 deletions frameworks/Java/officefloor/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<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>net.officefloor.performance</groupId>
<artifactId>TechEmpowerPerformance</artifactId>
<version>0.0.1</version>
<packaging>war</packaging>
<name>TechEmpowerPerformance</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<officefloor-version>2.16.0</officefloor-version>
<compiler-version>3.1</compiler-version>
<datanucleus-version>4.0.0-release</datanucleus-version>
<mysql-version>5.1.36</mysql-version>
<junit-version>4.11</junit-version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<!-- Standard JVM for compilation -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>${datanucleus-version}</version>
<configuration>
<api>JPA</api>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.officefloor.plugin</groupId>
<artifactId>officeplugin_woof</artifactId>
<version>${officefloor-version}</version>
</dependency>
<dependency>
<groupId>net.officefloor.plugin</groupId>
<artifactId>officeplugin_json</artifactId>
<version>${officefloor-version}</version>
</dependency>
<dependency>
<groupId>net.officefloor.plugin</groupId>
<artifactId>officeplugin_jpa</artifactId>
<version>${officefloor-version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-accessplatform-jpa-rdbms</artifactId>
<type>pom</type>
<version>${datanucleus-version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-version}</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.12.4</version>
</dependency>
<dependency>
<!-- Should be scope test, but available to run stand alone for manual testing -->
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.187</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
5 changes: 5 additions & 0 deletions frameworks/Java/officefloor/raw/datasource.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
datanucleus.ConnectionDriverName = com.mysql.jdbc.Driver
datanucleus.ConnectionURL = jdbc:mysql://DATABASE_HOST: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
datanucleus.ConnectionUserName = benchmarkdbuser
datanucleus.ConnectionPassword = benchmarkdbpass
datanucleus.connectionPoolingType = C3P0
42 changes: 42 additions & 0 deletions frameworks/Java/officefloor/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# Propagate any failure
set -e

# Install Java8 manually (fw_depends java8 is failing in vagrant-development)
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
sudo apt-get install -y oracle-java8-installer

# Ensure maven uses appropriate version of Java
export JAVA_HOME=/usr/lib/jvm/java-8-oracle/
sudo update-alternatives --set java /usr/lib/jvm/java-8-oracle/jre/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/java-8-oracle/bin/javac

# Need maven 3.1.1 or higher (default for Ubuntu is 3.0.5)
echo "Loading maven ..."
sudo add-apt-repository "deb http://ppa.launchpad.net/natecarlson/maven3/ubuntu precise main"
sudo apt-get update
sudo apt-get -y --force-yes install maven3
if [ -e /usr/bin/mvn ]
then
sudo rm -f /usr/bin/mvn
fi
sudo ln -s /usr/share/maven3/bin/mvn /usr/bin/mvn

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete everything about this and replace with:

fw_depends java mvn

We are presently in the midst of opening a pull request to fix up the various java version problems (likely, the culprit behind why you did your dependencies this way), so once we get that in (hopefully, today or tomorrow) you can open your new pull request.

# Setup configuration file (normally properties files contains environment specific information but create copy to avoid SCM issues)
echo "Creating configuration for OfficeFloor environment ..."
mkdir -p ./production
cp ./raw/datasource.properties ./production
sed -i 's|DATABASE_HOST|'"${DBHOST}"'|g' ./production/datasource.properties
echo "Configuration created"

# Compile application
echo "Building OfficeFloor test application ..."
mvn -DskipTests clean package
echo "OfficeFloor test application built"

# Run application
echo "Starting OfficeFloor application"
mvn -DincludeGWT=false -DenvDir=production net.officefloor.maven:woof-maven-plugin:run
20 changes: 20 additions & 0 deletions frameworks/Java/officefloor/source_code
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
./officefloor/pom.xml
./officefloor/src/main/java/net/officefloor/performance/entities/Fortune.java
./officefloor/src/main/java/net/officefloor/performance/entities/World.java
./officefloor/src/main/java/net/officefloor/performance/logic/DatabaseUpdateLogic.java
./officefloor/src/main/java/net/officefloor/performance/logic/FortunesLogic.java
./officefloor/src/main/java/net/officefloor/performance/logic/JsonSerialisationLogic.java
./officefloor/src/main/java/net/officefloor/performance/logic/LogicUtil.java
./officefloor/src/main/java/net/officefloor/performance/logic/MultipleDatabaseQueriesLogic.java
./officefloor/src/main/java/net/officefloor/performance/logic/SingleDatabaseQueryLogic.java
./officefloor/src/main/resources/application.objects
./officefloor/src/main/resources/application.teams
./officefloor/src/main/resources/application.woof
./officefloor/src/main/resources/c3p0.properties
./officefloor/src/main/resources/datasource.properties
./officefloor/src/main/resources/log4j.properties
./officefloor/src/main/resources/META-INF/persistence.xml
./officefloor/src/main/webapp/fortune.woof.html
./officefloor/src/main/webapp/plaintext.woof.html
./officefloor/src/main/webapp/service.woof.html
./officefloor/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package net.officefloor.performance.entities;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import net.officefloor.plugin.web.http.template.UnescapedHtml;
import lombok.Data;
import lombok.NonNull;

/**
* Fortune entity.
*
* @author Daniel Sagenschneider
*/
@Data
@Entity
@NamedQueries({ @NamedQuery(name = "Fortune.getAll", query = "SELECT e FROM Fortune e") })
public class Fortune {
public static final String NAMED_QUERY_ALL = "Fortune.getAll";

@Id
private int id;

@NonNull
private String message;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package net.officefloor.performance.entities;

import javax.persistence.Entity;
import javax.persistence.Id;

import lombok.Data;

/**
* World entity.
*
* @author Daniel Sagenschneider
*/
@Data
@Entity
public class World {
@Id
private int id;
private int randomNumber;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package net.officefloor.performance.logic;

import java.io.IOException;
import java.io.Serializable;
import java.util.Arrays;

import javax.persistence.EntityManager;

import lombok.Data;
import net.officefloor.performance.entities.World;
import net.officefloor.plugin.json.JsonResponseWriter;
import net.officefloor.plugin.web.http.application.HttpParameters;

/**
* Logic for Database Update query.
*
* @author Daniel Sagenschneider
*/
public class DatabaseUpdateLogic {

@Data
@HttpParameters
public static class Parameters implements Serializable {
private String queries;
}

public void service(Parameters parameters, EntityManager entityManager,
JsonResponseWriter response) throws IOException {

// Obtain the number of queries
int queryCount = LogicUtil.getQueryCount(parameters.queries);

// Create the listing of random identifiers
int[] identifiers = new int[queryCount];
for (int i = 0; i < identifiers.length; i++) {
identifiers[i] = LogicUtil.generateRandomNumber(1, 10000);
}

// Sort identifiers to avoid dead locks
Arrays.sort(identifiers);

// Obtain the world objects (changing their random values)
World[] list = new World[queryCount];
for (int i = 0; i < list.length; i++) {

// Obtain the object
int identifier = identifiers[i];
World world = entityManager.find(World.class, identifier);
list[i] = world;

// Change the random value
world.setRandomNumber(LogicUtil.generateRandomNumber(1, 10000));
}

// Send the response
response.writeResponse(list);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package net.officefloor.performance.logic;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

import javax.persistence.EntityManager;

import lombok.Data;
import net.officefloor.performance.entities.Fortune;

/**
* Logic for Database Update query.
*
* @author Daniel Sagenschneider
*/
public class FortunesLogic {

@Data
public static class TemplateData {
private final Fortune[] fortunes;
}

public TemplateData getTemplate(EntityManager entityManager) {

// Obtain all the fortunes
List<Fortune> list = entityManager.createNamedQuery(
Fortune.NAMED_QUERY_ALL, Fortune.class).getResultList();

// Obtain the fortunes as array
Fortune[] fortunes = list.toArray(new Fortune[list.size() + 1]);
int index = 0;
for (Fortune fortune : list) {
fortunes[index++] = fortune;
}

// Add the necessary Fortune
fortunes[fortunes.length - 1] = new Fortune(
"Additional fortune added at request time.");

// Sort the fortunes
Arrays.sort(fortunes, new Comparator<Fortune>() {
@Override
public int compare(Fortune a, Fortune b) {
return String.CASE_INSENSITIVE_ORDER.compare(a.getMessage(),
b.getMessage());
}
});

// Return the data for the template
return new TemplateData(fortunes);
}

}
Loading