From e564f7b9447e8f6bf5cc73c8857c907f22178db3 Mon Sep 17 00:00:00 2001 From: PatrikBuhr Date: Wed, 1 Mar 2023 13:16:38 +0100 Subject: [PATCH] Stepping to springboot 3 Upgrading to java 17. Signed-off-by: PatrikBuhr Issue-ID: NONRTRIC-840 Change-Id: I40e72f5d7ab09222bf0ea076163e00f2896290e8 --- pmlog/Dockerfile | 2 +- pmlog/api/pmlog-api.json | 142 +++++++++++++++------ pmlog/api/pmlog-api.yaml | 135 ++++++++++++++++---- pmlog/pom.xml | 40 ++---- .../src/main/java/org/oran/pmlog/InfluxStore.java | 8 +- pmlog/src/main/java/org/oran/pmlog/PmReport.java | 6 +- .../org/oran/pmlog/IcsSimulatorController.java | 11 +- .../src/test/java/org/oran/pmlog/Integration.java | 6 +- 8 files changed, 244 insertions(+), 106 deletions(-) diff --git a/pmlog/Dockerfile b/pmlog/Dockerfile index d5dc1fbc..c1d6be50 100644 --- a/pmlog/Dockerfile +++ b/pmlog/Dockerfile @@ -20,7 +20,7 @@ # ============LICENSE_END========================================================= -FROM openjdk:11-jre-slim +FROM openjdk:17-jdk-slim EXPOSE 8084 8435 diff --git a/pmlog/api/pmlog-api.json b/pmlog/api/pmlog-api.json index 560c8dad..4ad7230b 100644 --- a/pmlog/api/pmlog-api.json +++ b/pmlog/api/pmlog-api.json @@ -10,55 +10,80 @@ "paths": { "/actuator/threaddump": {"get": { "summary": "Actuator web endpoint 'threaddump'", - "operationId": "threaddump_4", + "operationId": "threaddump", "responses": {"200": { "description": "OK", - "content": {"*/*": {"schema": {"type": "object"}}} + "content": { + "text/plain;charset=UTF-8": {"schema": {"type": "object"}}, + "application/vnd.spring-boot.actuator.v3+json": {"schema": {"type": "object"}}, + "application/json": {"schema": {"type": "object"}}, + "application/vnd.spring-boot.actuator.v2+json": {"schema": {"type": "object"}} + } }}, "tags": ["Actuator"] }}, "/actuator/info": {"get": { "summary": "Actuator web endpoint 'info'", - "operationId": "info_2", + "operationId": "info", "responses": {"200": { "description": "OK", - "content": {"*/*": {"schema": {"type": "object"}}} + "content": { + "application/vnd.spring-boot.actuator.v3+json": {"schema": {"type": "object"}}, + "application/json": {"schema": {"type": "object"}}, + "application/vnd.spring-boot.actuator.v2+json": {"schema": {"type": "object"}} + } }}, "tags": ["Actuator"] }}, "/actuator/loggers": {"get": { "summary": "Actuator web endpoint 'loggers'", - "operationId": "loggers_2", + "operationId": "loggers", "responses": {"200": { "description": "OK", - "content": {"*/*": {"schema": {"type": "object"}}} + "content": { + "application/vnd.spring-boot.actuator.v3+json": {"schema": {"type": "object"}}, + "application/json": {"schema": {"type": "object"}}, + "application/vnd.spring-boot.actuator.v2+json": {"schema": {"type": "object"}} + } }}, "tags": ["Actuator"] }}, "/actuator/health/**": {"get": { "summary": "Actuator web endpoint 'health-path'", - "operationId": "health-path_2", + "operationId": "health-path", "responses": {"200": { "description": "OK", - "content": {"*/*": {"schema": {"type": "object"}}} + "content": { + "application/vnd.spring-boot.actuator.v3+json": {"schema": {"type": "object"}}, + "application/json": {"schema": {"type": "object"}}, + "application/vnd.spring-boot.actuator.v2+json": {"schema": {"type": "object"}} + } }}, "tags": ["Actuator"] }}, "/actuator/shutdown": {"post": { "summary": "Actuator web endpoint 'shutdown'", - "operationId": "shutdown_2", + "operationId": "shutdown", "responses": {"200": { "description": "OK", - "content": {"*/*": {"schema": {"type": "object"}}} + "content": { + "application/vnd.spring-boot.actuator.v3+json": {"schema": {"type": "object"}}, + "application/json": {"schema": {"type": "object"}}, + "application/vnd.spring-boot.actuator.v2+json": {"schema": {"type": "object"}} + } }}, "tags": ["Actuator"] }}, "/actuator/metrics/{requiredMetricName}": {"get": { "summary": "Actuator web endpoint 'metrics-requiredMetricName'", - "operationId": "metrics-requiredMetricName_2", + "operationId": "metrics-requiredMetricName", "responses": {"200": { "description": "OK", - "content": {"*/*": {"schema": {"type": "object"}}} + "content": { + "application/vnd.spring-boot.actuator.v3+json": {"schema": {"type": "object"}}, + "application/json": {"schema": {"type": "object"}}, + "application/vnd.spring-boot.actuator.v2+json": {"schema": {"type": "object"}} + } }}, "parameters": [{ "schema": {"type": "string"}, @@ -70,25 +95,41 @@ }}, "/actuator": {"get": { "summary": "Actuator root web endpoint", - "operationId": "links_1", + "operationId": "links", "responses": {"200": { "description": "OK", - "content": {"*/*": {"schema": { - "additionalProperties": { - "additionalProperties": {"$ref": "#/components/schemas/Link"}, + "content": { + "application/vnd.spring-boot.actuator.v3+json": {"schema": { + "additionalProperties": { + "additionalProperties": {"$ref": "#/components/schemas/Link"}, + "type": "object" + }, "type": "object" - }, - "type": "object" - }}} + }}, + "application/json": {"schema": { + "additionalProperties": { + "additionalProperties": {"$ref": "#/components/schemas/Link"}, + "type": "object" + }, + "type": "object" + }}, + "application/vnd.spring-boot.actuator.v2+json": {"schema": { + "additionalProperties": { + "additionalProperties": {"$ref": "#/components/schemas/Link"}, + "type": "object" + }, + "type": "object" + }} + } }}, "tags": ["Actuator"] }}, "/actuator/logfile": {"get": { "summary": "Actuator web endpoint 'logfile'", - "operationId": "logfile_2", + "operationId": "logfile", "responses": {"200": { "description": "OK", - "content": {"*/*": {"schema": {"type": "object"}}} + "content": {"text/plain;charset=UTF-8": {"schema": {"type": "object"}}} }}, "tags": ["Actuator"] }}, @@ -113,7 +154,19 @@ "/actuator/loggers/{name}": { "post": { "summary": "Actuator web endpoint 'loggers-name'", - "operationId": "loggers-name_3", + "requestBody": {"content": {"application/json": {"schema": { + "type": "string", + "enum": [ + "TRACE", + "DEBUG", + "INFO", + "WARN", + "ERROR", + "FATAL", + "OFF" + ] + }}}}, + "operationId": "loggers-name_2", "responses": {"200": { "description": "OK", "content": {"*/*": {"schema": {"type": "object"}}} @@ -128,10 +181,14 @@ }, "get": { "summary": "Actuator web endpoint 'loggers-name'", - "operationId": "loggers-name_4", + "operationId": "loggers-name", "responses": {"200": { "description": "OK", - "content": {"*/*": {"schema": {"type": "object"}}} + "content": { + "application/vnd.spring-boot.actuator.v3+json": {"schema": {"type": "object"}}, + "application/json": {"schema": {"type": "object"}}, + "application/vnd.spring-boot.actuator.v2+json": {"schema": {"type": "object"}} + } }}, "parameters": [{ "schema": {"type": "string"}, @@ -144,28 +201,36 @@ }, "/actuator/health": {"get": { "summary": "Actuator web endpoint 'health'", - "operationId": "health_2", + "operationId": "health", "responses": {"200": { "description": "OK", - "content": {"*/*": {"schema": {"type": "object"}}} + "content": { + "application/vnd.spring-boot.actuator.v3+json": {"schema": {"type": "object"}}, + "application/json": {"schema": {"type": "object"}}, + "application/vnd.spring-boot.actuator.v2+json": {"schema": {"type": "object"}} + } }}, "tags": ["Actuator"] }}, "/actuator/metrics": {"get": { "summary": "Actuator web endpoint 'metrics'", - "operationId": "metrics_2", + "operationId": "metrics", "responses": {"200": { "description": "OK", - "content": {"*/*": {"schema": {"type": "object"}}} + "content": { + "application/vnd.spring-boot.actuator.v3+json": {"schema": {"type": "object"}}, + "application/json": {"schema": {"type": "object"}}, + "application/vnd.spring-boot.actuator.v2+json": {"schema": {"type": "object"}} + } }}, "tags": ["Actuator"] }}, "/actuator/heapdump": {"get": { "summary": "Actuator web endpoint 'heapdump'", - "operationId": "heapdump_2", + "operationId": "heapdump", "responses": {"200": { "description": "OK", - "content": {"*/*": {"schema": {"type": "object"}}} + "content": {"application/octet-stream": {"schema": {"type": "object"}}} }}, "tags": ["Actuator"] }} @@ -179,15 +244,12 @@ "title": "PM Logger", "version": "1.0" }, - "tags": [ - {"name": "Information Coordinator Service Simulator (exists only in test)"}, - { - "name": "Actuator", - "description": "Monitor and interact", - "externalDocs": { - "description": "Spring Boot Actuator Web API Documentation", - "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" - } + "tags": [{ + "name": "Actuator", + "description": "Monitor and interact", + "externalDocs": { + "description": "Spring Boot Actuator Web API Documentation", + "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" } - ] + }] } \ No newline at end of file diff --git a/pmlog/api/pmlog-api.yaml b/pmlog/api/pmlog-api.yaml index 5dec51ba..638f2bb5 100644 --- a/pmlog/api/pmlog-api.yaml +++ b/pmlog/api/pmlog-api.yaml @@ -10,7 +10,6 @@ info: servers: - url: / tags: -- name: Information Coordinator Service Simulator (exists only in test) - name: Actuator description: Monitor and interact externalDocs: @@ -22,12 +21,21 @@ paths: tags: - Actuator summary: Actuator web endpoint 'threaddump' - operationId: threaddump_4 + operationId: threaddump responses: 200: description: OK content: - '*/*': + text/plain;charset=UTF-8: + schema: + type: object + application/vnd.spring-boot.actuator.v3+json: + schema: + type: object + application/json: + schema: + type: object + application/vnd.spring-boot.actuator.v2+json: schema: type: object /actuator/info: @@ -35,12 +43,18 @@ paths: tags: - Actuator summary: Actuator web endpoint 'info' - operationId: info_2 + operationId: info responses: 200: description: OK content: - '*/*': + application/vnd.spring-boot.actuator.v3+json: + schema: + type: object + application/json: + schema: + type: object + application/vnd.spring-boot.actuator.v2+json: schema: type: object /actuator/loggers: @@ -48,12 +62,18 @@ paths: tags: - Actuator summary: Actuator web endpoint 'loggers' - operationId: loggers_2 + operationId: loggers responses: 200: description: OK content: - '*/*': + application/vnd.spring-boot.actuator.v3+json: + schema: + type: object + application/json: + schema: + type: object + application/vnd.spring-boot.actuator.v2+json: schema: type: object /actuator/health/**: @@ -61,12 +81,18 @@ paths: tags: - Actuator summary: Actuator web endpoint 'health-path' - operationId: health-path_2 + operationId: health-path responses: 200: description: OK content: - '*/*': + application/vnd.spring-boot.actuator.v3+json: + schema: + type: object + application/json: + schema: + type: object + application/vnd.spring-boot.actuator.v2+json: schema: type: object /actuator/shutdown: @@ -74,12 +100,18 @@ paths: tags: - Actuator summary: Actuator web endpoint 'shutdown' - operationId: shutdown_2 + operationId: shutdown responses: 200: description: OK content: - '*/*': + application/vnd.spring-boot.actuator.v3+json: + schema: + type: object + application/json: + schema: + type: object + application/vnd.spring-boot.actuator.v2+json: schema: type: object /actuator/metrics/{requiredMetricName}: @@ -87,7 +119,7 @@ paths: tags: - Actuator summary: Actuator web endpoint 'metrics-requiredMetricName' - operationId: metrics-requiredMetricName_2 + operationId: metrics-requiredMetricName parameters: - name: requiredMetricName in: path @@ -100,7 +132,13 @@ paths: 200: description: OK content: - '*/*': + application/vnd.spring-boot.actuator.v3+json: + schema: + type: object + application/json: + schema: + type: object + application/vnd.spring-boot.actuator.v2+json: schema: type: object /actuator: @@ -108,12 +146,26 @@ paths: tags: - Actuator summary: Actuator root web endpoint - operationId: links_1 + operationId: links responses: 200: description: OK content: - '*/*': + application/vnd.spring-boot.actuator.v3+json: + schema: + type: object + additionalProperties: + type: object + additionalProperties: + $ref: '#/components/schemas/Link' + application/json: + schema: + type: object + additionalProperties: + type: object + additionalProperties: + $ref: '#/components/schemas/Link' + application/vnd.spring-boot.actuator.v2+json: schema: type: object additionalProperties: @@ -125,12 +177,12 @@ paths: tags: - Actuator summary: Actuator web endpoint 'logfile' - operationId: logfile_2 + operationId: logfile responses: 200: description: OK content: - '*/*': + text/plain;charset=UTF-8: schema: type: object /data-consumer/v1/info-jobs/{infoJobId}: @@ -164,7 +216,7 @@ paths: tags: - Actuator summary: Actuator web endpoint 'loggers-name' - operationId: loggers-name_4 + operationId: loggers-name parameters: - name: name in: path @@ -177,14 +229,20 @@ paths: 200: description: OK content: - '*/*': + application/vnd.spring-boot.actuator.v3+json: + schema: + type: object + application/json: + schema: + type: object + application/vnd.spring-boot.actuator.v2+json: schema: type: object post: tags: - Actuator summary: Actuator web endpoint 'loggers-name' - operationId: loggers-name_3 + operationId: loggers-name_2 parameters: - name: name in: path @@ -193,6 +251,19 @@ paths: explode: false schema: type: string + requestBody: + content: + application/json: + schema: + type: string + enum: + - TRACE + - DEBUG + - INFO + - WARN + - ERROR + - FATAL + - OFF responses: 200: description: OK @@ -205,12 +276,18 @@ paths: tags: - Actuator summary: Actuator web endpoint 'health' - operationId: health_2 + operationId: health responses: 200: description: OK content: - '*/*': + application/vnd.spring-boot.actuator.v3+json: + schema: + type: object + application/json: + schema: + type: object + application/vnd.spring-boot.actuator.v2+json: schema: type: object /actuator/metrics: @@ -218,12 +295,18 @@ paths: tags: - Actuator summary: Actuator web endpoint 'metrics' - operationId: metrics_2 + operationId: metrics responses: 200: description: OK content: - '*/*': + application/vnd.spring-boot.actuator.v3+json: + schema: + type: object + application/json: + schema: + type: object + application/vnd.spring-boot.actuator.v2+json: schema: type: object /actuator/heapdump: @@ -231,12 +314,12 @@ paths: tags: - Actuator summary: Actuator web endpoint 'heapdump' - operationId: heapdump_2 + operationId: heapdump responses: 200: description: OK content: - '*/*': + application/octet-stream: schema: type: object components: diff --git a/pmlog/pom.xml b/pmlog/pom.xml index c423060a..89f9902e 100644 --- a/pmlog/pom.xml +++ b/pmlog/pom.xml @@ -21,12 +21,12 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.springframework.boot spring-boot-starter-parent - 2.7.8 + 3.0.3 org.o-ran-sc.nonrtric.plt @@ -46,10 +46,8 @@ - 11 - 3.0.0 + 17 2.9.0 - 2.2.1 20211205 3.8.0 2.12.2 @@ -58,9 +56,20 @@ 3.7.0.1746 0.8.8 3.0.11 + 2.0.2 true + + org.springdoc + springdoc-openapi-starter-webmvc-ui + ${springdoc.version} + + + org.springdoc + springdoc-openapi-ui + ${springdoc.version} + com.influxdb influxdb-client-java @@ -82,16 +91,6 @@ org.springframework spring-webflux - - io.swagger.core.v3 - swagger-jaxrs2 - ${swagger.version} - - - io.swagger.core.v3 - swagger-jaxrs2-servlet-initializer - ${swagger.version} - com.google.code.gson gson @@ -106,17 +105,6 @@ org.springframework.boot spring-boot-starter-actuator - - - io.springfox - springfox-swagger2 - ${springfox.version} - - - io.springfox - springfox-swagger-ui - ${springfox.version} - org.springframework.boot diff --git a/pmlog/src/main/java/org/oran/pmlog/InfluxStore.java b/pmlog/src/main/java/org/oran/pmlog/InfluxStore.java index 7462e9af..ba9f21ca 100644 --- a/pmlog/src/main/java/org/oran/pmlog/InfluxStore.java +++ b/pmlog/src/main/java/org/oran/pmlog/InfluxStore.java @@ -105,11 +105,6 @@ public class InfluxStore { return measInfoList.getMeasTypes().getMeasType(measResult.getP()); } - private String fdn(PmReport report, PmReport.MeasValuesList measValueList) { - return report.event.getPerf3gppFields().getMeasDataCollection().getMeasuredEntityDn() + "," - + measValueList.getMeasObjInstId(); - } - private void addCounterFieldToPoint(Point point, PmReport.MeasInfoList measInfoList, PmReport.MeasValuesList measValueList, PmReport.MeasResult measResult) { String measType = measType(measResult, measInfoList); @@ -137,7 +132,8 @@ public class InfluxStore { if (measValueList.getSuspectFlag().equals("true")) { continue; } - Point point = Point.measurement(fdn(report, measValueList)).time(endTime(report), WritePrecision.MS); + Point point = Point.measurement(report.fullDistinguishedName(measValueList)).time(endTime(report), + WritePrecision.MS); point.addField("GranularityPeriod", measDataCollection.getGranularityPeriod()); diff --git a/pmlog/src/main/java/org/oran/pmlog/PmReport.java b/pmlog/src/main/java/org/oran/pmlog/PmReport.java index bf80d66f..3b102456 100644 --- a/pmlog/src/main/java/org/oran/pmlog/PmReport.java +++ b/pmlog/src/main/java/org/oran/pmlog/PmReport.java @@ -29,7 +29,6 @@ import lombok.Builder; import lombok.Getter; import lombok.Setter; - @Builder(toBuilder = true) public class PmReport { @@ -45,6 +44,11 @@ public class PmReport { return event.commonEventHeader.lastEpochMicrosec / 1000; } + public String fullDistinguishedName(PmReport.MeasValuesList measValueList) { + return event.getPerf3gppFields().getMeasDataCollection().getMeasuredEntityDn() + "," + + measValueList.getMeasObjInstId(); + } + @Expose public Event event; diff --git a/pmlog/src/test/java/org/oran/pmlog/IcsSimulatorController.java b/pmlog/src/test/java/org/oran/pmlog/IcsSimulatorController.java index e04655d5..918733ec 100644 --- a/pmlog/src/test/java/org/oran/pmlog/IcsSimulatorController.java +++ b/pmlog/src/test/java/org/oran/pmlog/IcsSimulatorController.java @@ -69,9 +69,14 @@ public class IcsSimulatorController { @PathVariable("infoJobId") String jobId, // @RequestBody String body) { logger.debug("*** added consumer job {}", jobId); - ConsumerJobInfo informationJobObject = gson.fromJson(body, ConsumerJobInfo.class); - testResults.setCreatedJob(informationJobObject); - return new ResponseEntity<>(HttpStatus.OK); + try { + ConsumerJobInfo informationJobObject = gson.fromJson(body, ConsumerJobInfo.class); + testResults.setCreatedJob(informationJobObject); + return new ResponseEntity<>(HttpStatus.OK); + } catch (Exception e) { + logger.error("Received malformed data: {}, {}", body, e.getMessage()); + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } } } diff --git a/pmlog/src/test/java/org/oran/pmlog/Integration.java b/pmlog/src/test/java/org/oran/pmlog/Integration.java index ca1fdd2c..840298d4 100644 --- a/pmlog/src/test/java/org/oran/pmlog/Integration.java +++ b/pmlog/src/test/java/org/oran/pmlog/Integration.java @@ -138,7 +138,7 @@ class Integration { Thread.sleep(4000); } - private String generateCounterValue(int sequenceValue, int noOfObjects, String counterName) { + private String generateCounterValue(int sequenceValue, int noOfObjects, String counterName, String resourceFdn) { long value = (random.nextInt() % 100) * sequenceValue + (counterName.hashCode() % 5000); return Long.toString(value); } @@ -172,12 +172,12 @@ class Integration { setEndTime(report, sequenceValue, noOfObjects); - // Fill it with random values + // Fill it with generated values for (PmReport.MeasInfoList measInfoList : measDataCollection.getMeasInfoList()) { for (PmReport.MeasValuesList measValueList : measInfoList.getMeasValuesList()) { for (PmReport.MeasResult measResult : measValueList.getMeasResults()) { String value = this.generateCounterValue(sequenceValue, noOfObjects, - measType(measResult, measInfoList)); + measType(measResult, measInfoList), report.fullDistinguishedName(measValueList)); measResult.setSValue(value); } } -- 2.16.6