Skip to content

Commit

Permalink
Update to MicroProfile 3.0 and Jakarta EE 8
Browse files Browse the repository at this point in the history
  • Loading branch information
aguibert committed Oct 2, 2019
1 parent 3fedf01 commit 256a785
Show file tree
Hide file tree
Showing 20 changed files with 111 additions and 128 deletions.
2 changes: 1 addition & 1 deletion auth-service/Dockerfile
@@ -1,4 +1,4 @@
FROM open-liberty:microProfile2-java11
FROM open-liberty:microProfile3-java11
ADD --chown=1001:0 build/libs/auth-service.war /config/dropins
COPY --chown=1001:0 src/main/liberty/config /config/
RUN printf 'frontend_url=http://lb-frontend:12000/login\n\
Expand Down
6 changes: 3 additions & 3 deletions auth-service/build.gradle
Expand Up @@ -16,9 +16,9 @@ liberty {
}

dependencies {
compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.0'
compile group: 'com.google.api-client', name: 'google-api-client', version: '1.23.0'
compile group: 'org.twitter4j', name: 'twitter4j-core', version: '4.0.+'
compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
compile group: 'com.google.api-client', name: 'google-api-client', version: '1.30.4'
compile group: 'org.twitter4j', name: 'twitter4j-core', version: '4.0.7'
}

// The installLiberty task doesn't work when run in parallel with other installLiberty tasks
Expand Down
Expand Up @@ -18,7 +18,6 @@
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;

import org.eclipse.microprofile.metrics.MetricUnits;
import org.eclipse.microprofile.metrics.annotation.Counted;
import org.libertybikes.auth.service.ConfigBean;
import org.libertybikes.auth.service.JwtAuth;
Expand Down Expand Up @@ -52,9 +51,7 @@ private void validate(Object obj) {
}

@GET
@Counted(unit = MetricUnits.NONE,
name = "num_github_logins",
monotonic = true,
@Counted(name = "num_github_logins",
displayName = "Number of Github Logins",
description = "How many times a user has logged in through Github Auth.",
absolute = true)
Expand Down
Expand Up @@ -18,7 +18,6 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.eclipse.microprofile.metrics.MetricUnits;
import org.eclipse.microprofile.metrics.annotation.Counted;
import org.libertybikes.auth.service.ConfigBean;
import org.libertybikes.auth.service.JwtAuth;
Expand Down Expand Up @@ -88,9 +87,7 @@ private Map<String, String> introspectAuth(GoogleAuthorizationCodeFlow flow, Goo
}

@GET
@Counted(unit = MetricUnits.NONE,
name = "num_google_logins",
monotonic = true,
@Counted(name = "num_google_logins",
displayName = "Number of Google Logins",
description = "How many times a user has logged in through Google Auth.",
absolute = true)
Expand Down
Expand Up @@ -13,7 +13,6 @@
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;

import org.eclipse.microprofile.metrics.MetricUnits;
import org.eclipse.microprofile.metrics.annotation.Counted;
import org.libertybikes.auth.service.ConfigBean;
import org.libertybikes.auth.service.JwtAuth;
Expand All @@ -33,9 +32,7 @@ public class TwitterCallback extends JwtAuth {
ConfigBean config;

@GET
@Counted(unit = MetricUnits.NONE,
name = "num_twitter_logins",
monotonic = true,
@Counted(name = "num_twitter_logins",
displayName = "Number of Twitter Logins",
description = "How many times a user has logged in through Twitter Auth.",
absolute = true)
Expand Down
4 changes: 2 additions & 2 deletions auth-service/src/main/liberty/config/server.xml
Expand Up @@ -8,9 +8,9 @@
<feature>jsonb-1.0</feature>
<feature>mpConfig-1.3</feature>
<feature>mpJwt-1.1</feature>
<feature>mpRestClient-1.2</feature>
<feature>mpRestClient-1.3</feature>
<feature>mpOpenAPI-1.1</feature>
<feature>mpMetrics-1.1</feature>
<feature>mpMetrics-2.0</feature>
</featureManager>

<mpMetrics authentication="false"/>
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Expand Up @@ -66,12 +66,12 @@ subprojects {
}

dependencies {
providedCompile group: 'org.eclipse.microprofile', name: 'microprofile', version: '2.2'
providedCompile group: 'javax', name: 'javaee-api', version: '8.0'
providedCompile group: 'org.eclipse.microprofile', name: 'microprofile', version: '3.0'
providedCompile group: 'jakarta.platform', name: 'jakarta.jakartaee-api', version: '8.0.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.eclipse', name: 'yasson', version: '1.0.3'
testCompile group: 'org.glassfish', name: 'jakarta.json', version: '1.1.5'
libertyRuntime group: 'io.openliberty', name: 'openliberty-runtime', version: '[19.0.0.8,)'
testCompile group: 'org.eclipse', name: 'yasson', version: '1.0.5'
//testCompile group: 'org.glassfish', name: 'jakarta.json', version: '1.1.5'
libertyRuntime group: 'io.openliberty', name: 'openliberty-runtime', version: '19.0.0.9'
}

eclipse {
Expand Down
2 changes: 1 addition & 1 deletion frontend/Dockerfile
@@ -1,4 +1,4 @@
FROM open-liberty:microProfile2-java11
FROM open-liberty:microProfile3-java11
ADD --chown=1001:0 build/libs/frontend.war /config/apps
COPY --chown=1001:0 src/main/liberty/config /config/
RUN printf 'httpPort=12000\n\
Expand Down
17 changes: 0 additions & 17 deletions frontend/build.gradle
@@ -1,20 +1,3 @@
// apply plugin: 'com.moowork.node'

// buildscript {
// ext {
// gradleNodeVersion = '1.2.0'
// }

// repositories {
// mavenCentral()
// maven { url 'https://plugins.gradle.org/m2' }
// }

// dependencies {
// classpath "com.moowork.gradle:gradle-node-plugin:$gradleNodeVersion"
// }
// }

plugins {
id 'com.moowork.node' version '1.3.1'
}
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/main/liberty/config/server.xml
@@ -1,7 +1,7 @@
<server>
<featureManager>
<feature>servlet-4.0</feature>
<feature>mpMetrics-1.1</feature>
<feature>mpMetrics-2.0</feature>
</featureManager>

<mpMetrics authentication="false"/>
Expand All @@ -10,6 +10,5 @@

<applicationManager autoExpand="true"/>

<webApplication location="${application.name}" contextRoot="/" >
</webApplication>
<webApplication location="${application.name}" contextRoot="/"/>
</server>
2 changes: 1 addition & 1 deletion game-service/Dockerfile
@@ -1,4 +1,4 @@
FROM open-liberty:microProfile2-java11
FROM open-liberty:microProfile3-java11
ADD --chown=1001:0 build/libs/game-service.war /config/dropins
COPY --chown=1001:0 src/main/liberty/config /config/
RUN printf 'httpPort=8080\n\
Expand Down
3 changes: 1 addition & 2 deletions game-service/build.gradle
@@ -1,6 +1,5 @@
dependencies {
compileOnly group: 'javax.websocket', name: 'javax.websocket-api', version: '1.1'
compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.0'
compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
}

ext {
Expand Down
Expand Up @@ -6,66 +6,78 @@
import javax.enterprise.inject.spi.CDI;

import org.eclipse.microprofile.metrics.Metadata;
import org.eclipse.microprofile.metrics.MetadataBuilder;
import org.eclipse.microprofile.metrics.MetricRegistry;
import org.eclipse.microprofile.metrics.MetricType;
import org.eclipse.microprofile.metrics.MetricUnits;
import org.eclipse.microprofile.metrics.Timer.Context;

public class GameMetrics {
// MpMetric Metadatas
public static final Metadata currentRoundsCounter = new Metadata("current_num_of_rounds", // name
"Current Number of Rounds", // display name
"Number of rounds currently running", // description
MetricType.COUNTER, // type
MetricUnits.NONE); // units

public static final Metadata totalRoundsCounter = new Metadata("total_num_of_rounds", // name
"Total Number of Rounds", // display name
"Number of rounds that have been created", // description
MetricType.COUNTER, // type
MetricUnits.NONE); // units

public static final Metadata currentPlayersCounter = new Metadata("current_num_of_players", // name
"Current Number of Players", // display name
"Number of players that are currently playing in a round", // description
MetricType.COUNTER, // type
MetricUnits.NONE); // units

public static final Metadata totalPlayersCounter = new Metadata("total_num_of_players", // name
"Total Number of Players That Have Played", // display name
"Number of players that have played in a round, requeuing and replaying increases the count", // description
MetricType.COUNTER, // type
MetricUnits.NONE); // units

public static final Metadata totalMobilePlayersCounter = new Metadata("total_num_of_mobile_players", // name
"Total Number of Mobile Players That Have Played", // display name
"Number of mobile players that have played in a round, requeuing and replaying increases the count", // description
MetricType.COUNTER, // type
MetricUnits.NONE); // units

public static final Metadata gameRoundTimerMetadata = new Metadata("game_round_timer", // name
"Game Round Timer", // display name
"The Time Game Rounds Last", // description
MetricType.TIMER, // type
MetricUnits.SECONDS); // units

public static final Metadata currentPartiesCounterMetadata = new Metadata("current_number_of_parties", // name
"Current Number of Parties", // display name
"Number of parties currently running", // description
MetricType.COUNTER, // type
MetricUnits.NONE); // units

public static final Metadata currentQueuedPlayersCounter = new Metadata("current_num_of_players_in_queue", // name
"Current Number of Players Waiting In A Queue", // display name
"Number of players that are currently waiting in a queue", // description
MetricType.COUNTER, // type
MetricUnits.NONE); // units

public static final Metadata openWebsocketTimerMetadata = new Metadata("open_game_websocket_timer", // name
"Open Game Round Websocket Timer", // display name
"The Time Game Round Websockets Are Open", // description
MetricType.TIMER, // type
MetricUnits.SECONDS); // units
public static final Metadata currentRoundsCounter = new MetadataBuilder()
.withName("current_num_of_rounds")
.withDisplayName("Current Number of Rounds")
.withDescription("Number of rounds currently running")
.withType(MetricType.CONCURRENT_GAUGE)
.build();

public static final Metadata totalRoundsCounter = new MetadataBuilder()
.withName("total_num_of_rounds")
.withDisplayName("Total Number of Rounds")
.withDescription("Number of rounds that have been created")
.withType(MetricType.COUNTER)
.build();

public static final Metadata currentPlayersCounter = new MetadataBuilder()
.withName("current_num_of_players")
.withDisplayName("Current Number of Players")
.withDescription("Number of players that are currently playing in a round")
.withType(MetricType.CONCURRENT_GAUGE)
.build();

public static final Metadata totalPlayersCounter = new MetadataBuilder()
.withName("total_num_of_players")
.withDisplayName("Total Number of Players That Have Played")
.withDescription("Number of players that have played in a round, requeuing and replaying increases the count")
.withType(MetricType.COUNTER)
.build();

public static final Metadata totalMobilePlayersCounter = new MetadataBuilder()
.withName("total_num_of_mobile_players")
.withDisplayName("Total Number of Mobile Players That Have Played")
.withDescription("Number of mobile players that have played in a round, requeuing and replaying increases the count")
.withType(MetricType.COUNTER)
.build();

public static final Metadata gameRoundTimerMetadata = new MetadataBuilder()
.withName("game_round_timer")
.withDisplayName("Game Round Timer")
.withDescription("The Time Game Rounds Last")
.withType(MetricType.TIMER)
.withUnit(MetricUnits.SECONDS)
.build();

public static final Metadata currentPartiesCounterMetadata = new MetadataBuilder()
.withName("current_number_of_parties")
.withDisplayName("Current Number of Parties")
.withDescription("Number of parties currently running")
.withType(MetricType.CONCURRENT_GAUGE)
.build();

public static final Metadata currentQueuedPlayersCounter = new MetadataBuilder()
.withName("current_num_of_players_in_queue")
.withDisplayName("Current Number of Players Waiting In A Queue")
.withDescription("Number of players that are currently waiting in a queue")
.withType(MetricType.CONCURRENT_GAUGE)
.build();

public static final Metadata openWebsocketTimerMetadata = new MetadataBuilder()
.withName("open_game_websocket_timer")
.withDisplayName("Open Game Round Websocket Timer")
.withDescription("The Time Game Round Websockets Are Open")
.withType(MetricType.TIMER)
.withUnit(MetricUnits.SECONDS)
.build();

private static MetricRegistry registry;

Expand All @@ -83,13 +95,15 @@ private static MetricRegistry getRegistry() {

public static void counterInc(Metadata metricMetadata) {
if (registry != null || (getRegistry() != null)) {
registry.counter(metricMetadata).inc();
registry.concurrentGauge(metricMetadata).inc();
//registry.counter(metricMetadata).inc();
}
}

public static void counterDec(Metadata metricMetadata) {
if (registry != null || (getRegistry() != null)) {
registry.counter(metricMetadata).dec();
registry.concurrentGauge(metricMetadata).dec();
//registry.counter(metricMetadata).dec();
}
}

Expand Down
Expand Up @@ -10,7 +10,6 @@
import javax.ws.rs.sse.Sse;
import javax.ws.rs.sse.SseEventSink;

import org.eclipse.microprofile.metrics.MetricUnits;
import org.eclipse.microprofile.metrics.annotation.Counted;
import org.libertybikes.game.core.GameRound;
import org.libertybikes.game.core.GameRound.LifecycleCallback;
Expand Down Expand Up @@ -43,11 +42,7 @@ public void preDestroy() {
}

@Inject
@Counted(unit = MetricUnits.NONE,
name = "number_of_parties",
monotonic = true,
description = "Total Number of Parties",
absolute = true)
@Counted(name = "number_of_parties", description = "Total Number of Parties", absolute = true)
public Party() {
this(getRandomPartyID());
}
Expand Down
4 changes: 2 additions & 2 deletions game-service/src/main/liberty/config/server.xml
Expand Up @@ -8,9 +8,9 @@
<feature>jsonb-1.0</feature>
<feature>mpConfig-1.3</feature>
<feature>mpFaultTolerance-2.0</feature>
<feature>mpMetrics-1.1</feature>
<feature>mpMetrics-2.0</feature>
<feature>mpOpenAPI-1.1</feature>
<feature>mpRestClient-1.2</feature>
<feature>mpRestClient-1.3</feature>
<feature>websocket-1.1</feature>
</featureManager>

Expand Down

0 comments on commit 256a785

Please sign in to comment.