Merge pull request #230 from aguibert/microProfile3

Update to MicroProfile 3
This commit is contained in:
Andrew Guibert 2019-10-02 15:33:12 -05:00 committed by GitHub
commit 0980319d63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 107 additions and 127 deletions

View File

@ -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\

View File

@ -10,15 +10,13 @@ liberty {
dropins = [war]
bootstrapProperties = ['httpPort': httpPort, 'httpsPort': httpsPort]
configDirectory = file('src/main/liberty/config')
jvmOptions = ['-Dorg.libertybikes.auth.service.github.GitHubOAuthAPI/mp-rest/url=https://github.com',
'-Dorg.libertybikes.auth.service.github.GitHubUserAPI/mp-rest/url=https://api.github.com']
}
}
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

View File

@ -18,7 +18,6 @@ import javax.ws.rs.Path;
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;
@ -52,9 +51,7 @@ public class GitHubCallback extends JwtAuth {
}
@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)

View File

@ -9,7 +9,7 @@ import javax.ws.rs.core.MediaType;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
@RegisterRestClient
@RegisterRestClient(baseUri = "https://github.com")
@Path("/login/oauth")
public interface GitHubOAuthAPI {

View File

@ -9,7 +9,7 @@ import javax.ws.rs.core.MediaType;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
@RegisterRestClient
@RegisterRestClient(baseUri = "https://api.github.com")
@Path("/user")
public interface GitHubUserAPI {

View File

@ -18,7 +18,6 @@ import javax.ws.rs.core.Context;
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;
@ -88,9 +87,7 @@ public class GoogleCallback extends JwtAuth {
}
@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)

View File

@ -13,7 +13,6 @@ import javax.ws.rs.Path;
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;
@ -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)

View File

@ -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"/>

View File

@ -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 {

View File

@ -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\

View File

@ -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'
}

View File

@ -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"/>
@ -10,6 +10,5 @@
<applicationManager autoExpand="true"/>
<webApplication location="${application.name}" contextRoot="/" >
</webApplication>
<webApplication location="${application.name}" contextRoot="/"/>
</server>

View File

@ -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\

View File

@ -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 {
@ -15,8 +14,7 @@ liberty {
dropins = [war]
bootstrapProperties = ['httpPort': httpPort, 'httpsPort': httpsPort]
configDirectory = file('src/main/liberty/config')
jvmOptions = ['-Dorg.libertybikes.restclient.PlayerService/mp-rest/url=http://localhost:8081/',
'-DsingleParty=' + System.getProperty('singleParty', 'true')]
jvmOptions = ['-DsingleParty=' + System.getProperty('singleParty', 'true')]
}
}

View File

@ -6,6 +6,7 @@ package org.libertybikes.game.metric;
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;
@ -13,59 +14,70 @@ 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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;
@ -83,13 +95,15 @@ public class GameMetrics {
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();
}
}

View File

@ -10,7 +10,6 @@ import javax.json.bind.annotation.JsonbTransient;
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;
@ -43,11 +42,7 @@ public class Party {
}
@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());
}

View File

@ -12,7 +12,7 @@ import javax.ws.rs.core.MediaType;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
@RegisterRestClient
@RegisterRestClient(baseUri = "http://localhost:8081/")
@Path("/")
public interface PlayerService {

View File

@ -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>

View File

@ -15,6 +15,7 @@
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": 2,
"links": [],
"panels": [
{
@ -78,9 +79,9 @@
"tableColumn": "",
"targets": [
{
"expr": "application:num_player_logins",
"expr": "application_num_player_logins_total",
"format": "time_series",
"instant": false,
"instant": true,
"intervalFactor": 1,
"refId": "A"
}
@ -159,9 +160,9 @@
"tableColumn": "",
"targets": [
{
"expr": "application:current_num_of_players",
"expr": "application_current_num_of_players_current",
"format": "time_series",
"instant": false,
"instant": true,
"intervalFactor": 1,
"refId": "A"
}
@ -245,7 +246,7 @@
"tableColumn": "__name__",
"targets": [
{
"expr": "application:rate_of_websocket_calls_one_min_rate_per_second",
"expr": "application_rate_of_websocket_calls_one_min_rate_per_second",
"format": "time_series",
"hide": false,
"intervalFactor": 1,
@ -328,7 +329,7 @@
"tableColumn": "",
"targets": [
{
"expr": "application:current_num_of_players_in_queue",
"expr": "application_current_num_of_players_in_queue_current",
"format": "time_series",
"instant": true,
"intervalFactor": 1,
@ -410,7 +411,7 @@
"tableColumn": "",
"targets": [
{
"expr": "application:total_num_of_rounds",
"expr": "application_total_num_of_rounds_current",
"format": "time_series",
"hide": false,
"instant": true,
@ -472,7 +473,7 @@
"steppedLine": true,
"targets": [
{
"expr": "base:cpu_system_load_average",
"expr": "base_cpu_systemLoadAverage",
"format": "time_series",
"instant": false,
"interval": "5s",
@ -624,7 +625,7 @@
"steppedLine": true,
"targets": [
{
"expr": "base:memory_used_heap_bytes",
"expr": "base_memory_usedHeap_bytes",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{job}}",

View File

@ -1,4 +1,4 @@
FROM open-liberty:microProfile2-java11
FROM open-liberty:microProfile3-java11
ADD --chown=1001:0 build/libs/player-service.war /config/dropins
COPY --chown=1001:0 src/main/liberty/config /config/
RUN printf 'httpPort=8081\n\

View File

@ -14,7 +14,7 @@ liberty {
}
dependencies {
compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.0'
compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
}
// The installLiberty task doesn't work when run in parallel with other installLiberty tasks

View File

@ -15,9 +15,9 @@ import javax.ws.rs.core.MediaType;
import org.eclipse.microprofile.jwt.JsonWebToken;
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.libertybikes.player.data.PlayerDB;
@Path("/player")
@ -39,11 +39,12 @@ public class PlayerService {
@Inject
private MetricRegistry registry;
private static final Metadata numLoginsCounter = new Metadata("num_player_logins", // name
"Number of Total Logins", // display name
"How many times a user has logged in.", // description
MetricType.COUNTER, // type
MetricUnits.NONE); // units
private static final Metadata numLoginsCounter = new MetadataBuilder()
.withName("num_player_logins")
.withDisplayName("Number of Total Logins")
.withDescription("How many times a user has logged in.")
.withType(MetricType.COUNTER)
.build();
@POST
@Produces(MediaType.TEXT_HTML)

View File

@ -9,7 +9,7 @@
<feature>mpConfig-1.3</feature>
<feature>mpJwt-1.1</feature>
<feature>mpOpenAPI-1.1</feature>
<feature>mpMetrics-1.1</feature>
<feature>mpMetrics-2.0</feature>
</featureManager>
<mpMetrics authentication="false"/>