Skip to content

Commit

Permalink
Merge branch 'release/0.9.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
micheljung committed Sep 1, 2017
2 parents 0781ef6 + e570f24 commit 3adda67
Show file tree
Hide file tree
Showing 159 changed files with 2,930 additions and 3,972 deletions.
2 changes: 1 addition & 1 deletion .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions .idea/runConfigurations/FafServerApplication.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ before_install:
- sudo mv /tmp/docker-compose /usr/local/bin

install:
- git clone https://github.com/FAForever/faf-stack.git
- git clone https://github.com/FAForever/faf-stack.git faf-stack
&& pushd faf-stack
&& git checkout 024322dfef9c600f458b91baeb1b4a7326b31580
&& cp -r config.template config
&& popd
- docker-compose -f faf-stack/docker-compose.yml up -d faf-db

script:
- chmod +x gradlew && ./gradlew build --info

after_success:
- ./gradlew jacocoTestReport coveralls
- if [ "${TRAVIS_BRANCH}" == "master" ]; then
- if [ -n "${TRAVIS_TAG}" ]; then
./gradlew pushDockerImage;
fi
- if [ "${TRAVIS_BRANCH}" == "develop" ]; then
Expand Down
31 changes: 20 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,22 @@ buildscript {
dependencies {
classpath("com.bmuschko:gradle-docker-plugin:${gradleDockerVersion}")
classpath("org.springframework.build.gradle:propdeps-plugin:${propdepsVersion}")
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
classpath("org.kt3k.gradle.plugin:coveralls-gradle-plugin:${coverallsGradlePluginVersion}")
}
}

plugins {
id "io.franzbecker.gradle-lombok" version "1.10"
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'propdeps'


group = 'faforever'
version = '0.9.7'
version = '0.9.8'

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand All @@ -37,8 +42,13 @@ configurations {
compile.exclude module: "assertj-core"
}

lombok {
version = "1.16.18"
sha256 = ""
}

task wrapper(type: Wrapper) {
gradleVersion = '3.2.1'
gradleVersion = '3.5'
}

compileJava.dependsOn(processResources)
Expand Down Expand Up @@ -84,7 +94,7 @@ import com.bmuschko.gradle.docker.tasks.image.Dockerfile

applicationName = rootProject.name
applicationDistribution.exclude("**/spring-boot-devtools*.jar")
applicationDefaultJvmArgs = ["-Xmx128m"]
applicationDefaultJvmArgs = ["-server -Xms64m -Xmx512m -XX:MaxMetaspaceSize=256m -XX:MinHeapFreeRatio=25 -XX:MaxHeapFreeRatio=40 -XX:+UseG1GC -XX:+UseStringDeduplication -XX:-HeapDumpOnOutOfMemoryError"]

docker {
if (project.hasProperty('dockerHost')) {
Expand Down Expand Up @@ -148,33 +158,31 @@ dependencies {
// compile("org.zalando.stups:data-jpa-eclipselink-spring-boot-starter:${eclipseLinkStarterVersion}")
// compile("org.eclipse.persistence:org.eclipse.persistence.jpa:${eclipseLinkVersion}")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
// {
// exclude group: "org.hibernate", module: "hibernate-entitymanager"
// }
compile("org.springframework.boot:spring-boot-starter-cache")
compile("org.springframework.boot:spring-boot-starter-integration")
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.boot:spring-boot-starter-jetty")
compile("org.springframework.boot:spring-boot-devtools")
compile("org.springframework.security:spring-security-messaging")
compile("org.springframework.security:spring-security-jwt:${springSecurityJwtVersion}")
compile("org.springframework.security.oauth:spring-security-oauth2")
compile("org.springframework:spring-context-support")
compile("org.springframework.integration:spring-integration-ip")
compile("org.springframework.integration:spring-integration-security")
compile("org.springframework.integration:spring-integration-event")
compile("de.codecentric:spring-boot-admin-starter-client:${springBootAdminClientVersion}")
compile("io.reactivex.rxjava2:rxjava:${rxJavaVersion}")
compile("org.bouncycastle:bcprov-jdk15on:${bouncyCastleVersion}")
compile("org.jolokia:jolokia-core:${jolokiaVersion}")
compile("com.github.nsp:JSkills:${jSkillsVersion}")
compile("com.github.nocatch:nocatch:${noCatchVersion}")
compile("org.jetbrains:annotations:${jetbrainsAnnotationsVersion}")
compile("com.github.ben-manes.caffeine:caffeine")
compile("com.google.guava:guava:${guavaVersion}")
compile("org.flywaydb:flyway-core:${flywayVersion}")
compile("javax.inject:javax.inject:${javaxInjectVersion}")
compile("org.projectlombok:lombok:${lombokVersion}")
compile("com.github.jasminb:jsonapi-converter:${jsonApiConverterVersion}")
compile("com.twilio.sdk:twilio:${twilioVersion}")
compile("io.prometheus:simpleclient_hotspot:${prometheusVersion}")
compile("io.prometheus:simpleclient_servlet:${prometheusVersion}")
compile("io.prometheus:simpleclient_spring_boot:${prometheusVersion}")

compile("com.maxmind.geoip2:geoip2:${geoip2Version}"){
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
Expand All @@ -185,6 +193,7 @@ dependencies {

runtime("mysql:mysql-connector-java:${mysqlConnectorVersion}")

optional("org.springframework.boot:spring-boot-devtools")
optional("org.springframework.boot:spring-boot-configuration-processor")

testCompile("org.springframework.boot:spring-boot-starter-test")
Expand Down
7 changes: 3 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
flywayVersion=4.0.3
springVersion=4.1.3.RELEASE
springBootVersion=1.4.3.RELEASE
springBootVersion=1.5.6.RELEASE
springBootAdminClientVersion=1.4.5
springSecurityJwtVersion=1.0.7.RELEASE
gradleDockerVersion=3.0.4
Expand All @@ -17,9 +15,10 @@ noCatchVersion=1.1
jSkillsVersion=8b333ec63d
jolokiaVersion=1.3.5
bouncyCastleVersion=1.56
rxJavaVersion=2.0.4
ehcacheVersion=3.3.0
eclipseLinkVersion=2.6.4
eclipseLinkStarterVersion=0.10.1
jsonApiConverterVersion=0.6
twilioVersion=7.8.0
hibernate.version=5.2.10.Final
prometheusVersion=0.0.26
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Jan 19 00:16:22 CET 2017
#Fri May 26 14:41:09 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
22 changes: 15 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

##############################################################################
##
Expand Down Expand Up @@ -154,11 +154,19 @@ if $cygwin ; then
esac
fi

# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save ( ) {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
APP_ARGS=$(save "$@")

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "$@"
6 changes: 0 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ goto fail
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
Expand All @@ -60,11 +59,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line
Expand Down
3 changes: 1 addition & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ based server.
| Produces very clear, well readable and helpful logs. | Produces a lot of unreadable, messy and useless log messages. |
| Follows [Clean Code](https://dzone.com/articles/clean-code-principles?edition=154263&utm_source=Weekly%20Digest&utm_medium=email&utm_campaign=wd%202017-01-11) principles to assure high quality and maintainability. | Was built by "[Hackers](https://danielmiessler.com/study/programmer_hacker_developer/#gs.vEWu9K4)" with no greater design in mind, with focus on "getting the job done". |
| Is actively maintained by me, and various other people are (interested in) contributing. | Hasn't had a committed maintainer for over a year, and nobody is willing take over. Many unfinished PRs are lying around as the original authors lost interest, and nobody is taking care. |
| Uses a database abstraction technology so that the application is decoupled from the underlying database, which allows easy switching to another database. | Uses hardcoded SQL syntax that makes it expensive to switch to another database. |

## Solved problems of the current server

Expand All @@ -94,8 +95,6 @@ The following issues that exist in the Python server are not present in this Jav

The following features of the Python server have not yet been implemented in this Java server:

* Accepting "mutually agreed draw"
* Timeout unstarted games
* Send clan channels

## Additional features
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = 'faf-server'
rootProject.name = 'faf-java-server'
5 changes: 5 additions & 0 deletions src/main/docker/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

wget -q -o /dev/null http://localhost:8010

exit $?
6 changes: 5 additions & 1 deletion src/main/java/com/faforever/server/FafServerApplication.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package com.faforever.server;

import com.faforever.server.config.ServerProperties;
import io.prometheus.client.spring.boot.EnablePrometheusEndpoint;
import io.prometheus.client.spring.boot.EnableSpringBootMetricsCollector;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
@EnablePrometheusEndpoint
@EnableSpringBootMetricsCollector
@EnableConfigurationProperties({ServerProperties.class})
public class FafServerApplication {

public static void main(String[] args) {
public static void main(String[] args) {
ConfigurableApplicationContext context = new SpringApplicationBuilder(FafServerApplication.class)
.registerShutdownHook(false)
.run(args);
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/com/faforever/server/api/ApiAccessor.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.faforever.server.api;

import com.faforever.server.api.dto.AchievementUpdateRequest;
import com.faforever.server.api.dto.EventUpdateRequest;
import com.faforever.server.api.dto.UpdatedAchievementResponse;
import com.faforever.server.api.dto.UpdatedEventResponse;
import com.faforever.server.config.ServerProperties;
import com.faforever.server.stats.achievements.AchievementUpdate;
import com.faforever.server.stats.event.EventUpdate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
Expand All @@ -24,18 +27,19 @@ public ApiAccessor(RestOperations restOperations, ServerProperties serverPropert
this.serverProperties = serverProperties;
}

public List<UpdatedAchievementResponse> updateAchievements(List<com.faforever.server.stats.achievements.AchievementUpdate> achievementUpdates) {
public List<UpdatedAchievementResponse> updateAchievements(List<AchievementUpdate> achievementUpdates) {
List<AchievementUpdateRequest> updates = achievementUpdates.stream()
.map(AchievementUpdateRequest::fromInternal)
.collect(Collectors.toList());
return patch("/achievements/update", updates);
}

@Async
public Void updateEvents(List<EventUpdate> eventUpdates) {
// FIXME implement
// return completedFuture(restOperations.patchForObject(url("/playerEvents"), eventUpdates, Void.class));
return null;
public List<UpdatedEventResponse> updateEvents(List<EventUpdate> eventUpdates) {
List<EventUpdateRequest> updates = eventUpdates.stream()
.map(EventUpdateRequest::fromInternal)
.collect(Collectors.toList());
return patch("/events/update", updates);
}

@SuppressWarnings("unchecked")
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/faforever/server/api/dto/EventUpdateRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.faforever.server.api.dto;

import com.faforever.server.stats.event.EventUpdate;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class EventUpdateRequest {

private final String playerId;
private final String eventId;
private final int count;

public static EventUpdateRequest fromInternal(EventUpdate eventUpdate) {
return new EventUpdateRequest(
String.valueOf(eventUpdate.getPlayerId()),
eventUpdate.getEventId().getId(),
eventUpdate.getUpdateCount()
);
}
}
Loading

0 comments on commit 3adda67

Please sign in to comment.