forked from TechEmpower/FrameworkBenchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/TechEmpower/FrameworkBenc…
- Loading branch information
Showing
139 changed files
with
8,008 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,5 @@ mods/ | |
/.settings | ||
/.buildpath | ||
/.project | ||
*.iml | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"framework": "dropwizard", | ||
"tests": [{ | ||
"default": { | ||
"setup_file": "setup", | ||
"json_url": "/json", | ||
"db_url": "/db", | ||
"query_url": "/db?queries=", | ||
"port": 9000, | ||
"sort": 69 | ||
} | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
http: | ||
port: 9000 | ||
|
||
requestLog: | ||
|
||
# Settings for logging to stdout. | ||
console: | ||
# If true, log requests to stdout. | ||
enabled: false | ||
|
||
database: | ||
# the name of your JDBC driver | ||
driverClass: com.mysql.jdbc.Driver | ||
|
||
# the username | ||
user: benchmarkdbuser | ||
|
||
# the password | ||
password: benchmarkdbpass | ||
|
||
# the JDBC URL | ||
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 | ||
|
||
# any properties specific to your JDBC driver: | ||
properties: | ||
charSet: UTF-8 | ||
|
||
# the maximum amount of time to wait on an empty pool before throwing an exception | ||
maxWaitForConnection: 1s | ||
|
||
# the SQL query to run when validating a connection's liveness | ||
validationQuery: "/* MyService Health Check */ SELECT 1" | ||
|
||
# the minimum number of connections to keep open | ||
minSize: 8 | ||
|
||
# the maximum number of connections to keep open | ||
maxSize: 256 | ||
|
||
# whether or not idle connections should be validated | ||
checkConnectionWhileIdle: false | ||
|
||
# how long a connection must be held before it can be validated | ||
checkConnectionHealthWhenIdleFor: 10s | ||
|
||
# the maximum lifetime of an idle connection | ||
closeConnectionIfIdleFor: 1 minute | ||
|
||
logging: | ||
|
||
# The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL. | ||
level: OFF | ||
|
||
console: | ||
|
||
# If true, write log statements to stdout. | ||
enabled: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.xekm</groupId> | ||
<artifactId>hello-world</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.yammer.dropwizard</groupId> | ||
<artifactId>dropwizard-core</artifactId> | ||
<version>0.6.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.yammer.dropwizard</groupId> | ||
<artifactId>dropwizard-hibernate</artifactId> | ||
<version>0.6.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>5.1.6</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addDefaultImplementationEntries>true</addDefaultImplementationEntries> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>1.6</version> | ||
<configuration> | ||
<createDependencyReducedPom>true</createDependencyReducedPom> | ||
<filters> | ||
<filter> | ||
<artifact>*:*</artifact> | ||
<excludes> | ||
<exclude>META-INF/*.SF</exclude> | ||
<exclude>META-INF/*.DSA</exclude> | ||
<exclude>META-INF/*.RSA</exclude> | ||
</excludes> | ||
</filter> | ||
</filters> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<transformers> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<mainClass>com.example.helloworld.HelloWorldService</mainClass> | ||
</transformer> | ||
</transformers> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import subprocess | ||
import sys | ||
import setup_util | ||
from os.path import expanduser | ||
import os | ||
|
||
home = expanduser("~") | ||
|
||
def start(args): | ||
setup_util.replace_text("dropwizard/hello-world.yml", "url: jdbc:mysql://.*/hello_world", "url: jdbc:mysql://" + args.database_host + ":3306/hello_world") | ||
|
||
try: | ||
subprocess.check_call("mvn clean package;", shell=True, cwd="dropwizard") | ||
subprocess.Popen("java -jar target/hello-world-0.0.1-SNAPSHOT.jar server hello-world.yml", shell=True, cwd="dropwizard") | ||
return 0 | ||
except subprocess.CalledProcessError: | ||
return 1 | ||
def stop(): | ||
p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE) | ||
out, err = p.communicate() | ||
for line in out.splitlines(): | ||
if 'hello-world' in line: | ||
pid = int(line.split(None, 2)[1]) | ||
os.kill(pid, 9) | ||
return 0 |
25 changes: 25 additions & 0 deletions
25
dropwizard/src/main/java/com/example/helloworld/HelloWorldConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
package com.example.helloworld; | ||
|
||
import javax.validation.Valid; | ||
import javax.validation.constraints.NotNull; | ||
|
||
import org.hibernate.validator.constraints.NotEmpty; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.yammer.dropwizard.config.Configuration; | ||
import com.yammer.dropwizard.db.DatabaseConfiguration; | ||
|
||
public class HelloWorldConfiguration | ||
extends Configuration | ||
{ | ||
@Valid | ||
@NotNull | ||
@JsonProperty | ||
private DatabaseConfiguration database = new DatabaseConfiguration(); | ||
|
||
public DatabaseConfiguration getDatabaseConfiguration() | ||
{ | ||
return database; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
dropwizard/src/main/java/com/example/helloworld/HelloWorldService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
package com.example.helloworld; | ||
|
||
import com.example.helloworld.core.World; | ||
import com.example.helloworld.db.WorldDAO; | ||
import com.example.helloworld.resources.JsonResource; | ||
import com.example.helloworld.resources.WorldResource; | ||
import com.yammer.dropwizard.Service; | ||
import com.yammer.dropwizard.config.Bootstrap; | ||
import com.yammer.dropwizard.config.Environment; | ||
import com.yammer.dropwizard.db.DatabaseConfiguration; | ||
import com.yammer.dropwizard.hibernate.HibernateBundle; | ||
|
||
public class HelloWorldService | ||
extends Service<HelloWorldConfiguration> | ||
{ | ||
private final HibernateBundle<HelloWorldConfiguration> hibernate = new HibernateBundle<HelloWorldConfiguration>( | ||
World.class) | ||
{ | ||
@Override | ||
public DatabaseConfiguration getDatabaseConfiguration( | ||
HelloWorldConfiguration configuration) | ||
{ | ||
return configuration.getDatabaseConfiguration(); | ||
} | ||
}; | ||
|
||
public static void main(String[] args) throws Exception | ||
{ | ||
new HelloWorldService().run(args); | ||
} | ||
|
||
@Override | ||
public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) | ||
{ | ||
bootstrap.setName("hello-world"); | ||
bootstrap.addBundle(hibernate); | ||
} | ||
|
||
@Override | ||
public void run(HelloWorldConfiguration config, Environment environment) | ||
{ | ||
final WorldDAO dao = new WorldDAO(hibernate.getSessionFactory()); | ||
environment.addResource(new WorldResource(dao)); | ||
environment.addResource(new JsonResource()); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
dropwizard/src/main/java/com/example/helloworld/core/World.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
package com.example.helloworld.core; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@Table(name = "World") | ||
public class World | ||
{ | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
private long id; | ||
|
||
@Column(name = "randomNumber", nullable = false) | ||
private long randomNumber; | ||
|
||
public long getId() | ||
{ | ||
return id; | ||
} | ||
|
||
public void setId(long id) | ||
{ | ||
this.id = id; | ||
} | ||
|
||
public long getRandomNumber() | ||
{ | ||
return this.randomNumber; | ||
} | ||
|
||
public void setRandomNumber(long randomNumber) | ||
{ | ||
this.randomNumber = randomNumber; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
dropwizard/src/main/java/com/example/helloworld/db/WorldDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
package com.example.helloworld.db; | ||
|
||
import org.hibernate.SessionFactory; | ||
|
||
import com.example.helloworld.core.World; | ||
import com.google.common.base.Optional; | ||
import com.yammer.dropwizard.hibernate.AbstractDAO; | ||
|
||
public class WorldDAO | ||
extends AbstractDAO<World> | ||
{ | ||
public WorldDAO(SessionFactory factory) | ||
{ | ||
super(factory); | ||
} | ||
|
||
public Optional<World> findById(Long id) | ||
{ | ||
return Optional.fromNullable(get(id)); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
dropwizard/src/main/java/com/example/helloworld/resources/JsonResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
package com.example.helloworld.resources; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
@Path("/json") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public class JsonResource | ||
{ | ||
private final Map<String, String> MESSAGE = new HashMap<String, String>(); | ||
|
||
public JsonResource() | ||
{ | ||
MESSAGE.put("message", "Hello, world!"); | ||
} | ||
|
||
@GET | ||
public Map<String, String> sayHello() | ||
{ | ||
return MESSAGE; | ||
} | ||
} |
Oops, something went wrong.