diff options
author | Filip Krzywka <filip.krzywka@nokia.com> | 2019-01-17 13:30:32 +0100 |
---|---|---|
committer | Filip Krzywka <filip.krzywka@nokia.com> | 2019-01-17 14:38:18 +0100 |
commit | 89ec57e95480fad586b86b8545cec5dd690eae4c (patch) | |
tree | 8db6a60dca1173f396cd75068a32a7402271f931 | |
parent | e31a7893134c9d68b4148bbb9cb55c6659c73046 (diff) |
Generate Java code from GPB
This adds module for generating Java code from
Google Protocol Buffers files
Change-Id: Ie7d71ad0fb18854d98f50688c00034cc1699f0b4
Issue-ID: DCAEGEN2-1097
Signed-off-by: Filip Krzywka <filip.krzywka@nokia.com>
13 files changed, 311 insertions, 29 deletions
@@ -36,6 +36,8 @@ <slf4j.version>1.7.25</slf4j.version> <logback.version>1.2.3</logback.version> <mockito.version>2.23.4</mockito.version> + <protobuf.version>3.6.1</protobuf.version> + <protoc-jar-maven-plugin.version>3.6.0.2</protoc-jar-maven-plugin.version> </properties> <modules> @@ -80,6 +82,16 @@ <artifactId>maven-project-info-reports-plugin</artifactId> <version>2.9</version> </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>1.7</version> + </plugin> + <plugin> + <groupId>com.github.os72</groupId> + <artifactId>protoc-jar-maven-plugin</artifactId> + <version>${protoc-jar-maven-plugin.version}</version> + </plugin> </plugins> </pluginManagement> <plugins> @@ -157,6 +169,11 @@ <artifactId>spring-boot-starter-web</artifactId> <version>${spring.boot.version}</version> </dependency> + <dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protobuf-java</artifactId> + <version>${protobuf.version}</version> + </dependency> <dependency> <groupId>org.immutables</groupId> diff --git a/services/hv-ves-client/pom.xml b/services/hv-ves-client/pom.xml index b2c5fcc8..8a2814ee 100644 --- a/services/hv-ves-client/pom.xml +++ b/services/hv-ves-client/pom.xml @@ -31,7 +31,6 @@ </parent> <artifactId>dcaegen2-services-sdk-services-hvvesclient</artifactId> - <version>1.1.1-SNAPSHOT</version> <name>High Volume VES Collector Client</name> <description></description> @@ -39,5 +38,6 @@ <modules> <module>producer</module> + <module>protobuf</module> </modules> </project> diff --git a/services/hv-ves-client/producer/api/pom.xml b/services/hv-ves-client/producer/api/pom.xml index 65a96190..44e15c9d 100644 --- a/services/hv-ves-client/producer/api/pom.xml +++ b/services/hv-ves-client/producer/api/pom.xml @@ -39,6 +39,12 @@ <dependencies> <dependency> + <groupId>${project.parent.groupId}</groupId> + <artifactId>hvvesclient-protobuf</artifactId> + <version>${project.parent.version}</version> + <scope>compile</scope> + </dependency> + <dependency> <groupId>org.reactivestreams</groupId> <artifactId>reactive-streams</artifactId> </dependency> diff --git a/services/hv-ves-client/producer/api/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/api/HvVesProducer.java b/services/hv-ves-client/producer/api/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/api/HvVesProducer.java index ea928dc1..43cd3feb 100644 --- a/services/hv-ves-client/producer/api/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/api/HvVesProducer.java +++ b/services/hv-ves-client/producer/api/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/api/HvVesProducer.java @@ -20,7 +20,7 @@ package org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api; import org.jetbrains.annotations.NotNull; -import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.domain.VesEvent; +import org.onap.ves.VesEventOuterClass.VesEvent; import org.reactivestreams.Publisher; /** diff --git a/services/hv-ves-client/producer/ct/pom.xml b/services/hv-ves-client/producer/ct/pom.xml index e68976d9..ba8861c9 100644 --- a/services/hv-ves-client/producer/ct/pom.xml +++ b/services/hv-ves-client/producer/ct/pom.xml @@ -31,7 +31,6 @@ </parent> <artifactId>hvvesclient-producer-ct</artifactId> - <version>1.1.1-SNAPSHOT</version> <name>High Volume VES Collector Client :: Producer :: Component Tests</name> <description></description> @@ -40,17 +39,23 @@ <dependencies> <dependency> - <groupId>org.onap.dcaegen2.services.sdk</groupId> + <groupId>${project.parent.groupId}</groupId> <artifactId>hvvesclient-producer-api</artifactId> - <version>${project.version}</version> + <version>${project.parent.version}</version> </dependency> <dependency> - <groupId>org.onap.dcaegen2.services.sdk</groupId> + <groupId>${project.parent.groupId}</groupId> <artifactId>hvvesclient-producer-impl</artifactId> - <version>${project.version}</version> + <version>${project.parent.version}</version> <scope>runtime</scope> </dependency> <dependency> + <groupId>${project.parent.groupId}</groupId> + <artifactId>hvvesclient-protobuf</artifactId> + <version>${project.parent.version}</version> + <scope>compile</scope> + </dependency> + <dependency> <groupId>io.projectreactor.netty</groupId> <artifactId>reactor-netty</artifactId> </dependency> diff --git a/services/hv-ves-client/producer/ct/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/ct/HvVesProducerIT.java b/services/hv-ves-client/producer/ct/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/ct/HvVesProducerIT.java index df7fa206..0aa51aa9 100644 --- a/services/hv-ves-client/producer/ct/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/ct/HvVesProducerIT.java +++ b/services/hv-ves-client/producer/ct/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/ct/HvVesProducerIT.java @@ -26,7 +26,7 @@ import io.netty.buffer.ByteBufAllocator; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.domain.VesEvent; +import org.onap.ves.VesEventOuterClass.VesEvent; import reactor.core.publisher.Flux; /** @@ -49,8 +49,7 @@ class HvVesProducerIT { @Test void todo() { // given - final Flux<VesEvent> input = Flux.just("hello", "world") - .map(VesEvent::new); + final Flux<VesEvent> input = Flux.just(VesEvent.getDefaultInstance()); // when // This will currently fail diff --git a/services/hv-ves-client/producer/ct/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/ct/SystemUnderTestWrapper.java b/services/hv-ves-client/producer/ct/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/ct/SystemUnderTestWrapper.java index ccd13d00..f459c98f 100644 --- a/services/hv-ves-client/producer/ct/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/ct/SystemUnderTestWrapper.java +++ b/services/hv-ves-client/producer/ct/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/ct/SystemUnderTestWrapper.java @@ -20,13 +20,15 @@ package org.onap.dcaegen2.services.sdk.services.hvves.client.producer.ct; import io.netty.buffer.ByteBuf; + import java.net.InetSocketAddress; import java.time.Duration; + import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.HvVesProducer; import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.HvVesProducerFactory; import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.ImmutableProducerOptions; import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.ImmutableProducerOptions.Builder; -import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.domain.VesEvent; +import org.onap.ves.VesEventOuterClass.VesEvent; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/HvVesProducerImpl.java b/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/HvVesProducerImpl.java index b900219f..25128d1e 100644 --- a/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/HvVesProducerImpl.java +++ b/services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/HvVesProducerImpl.java @@ -21,13 +21,14 @@ package org.onap.dcaegen2.services.sdk.services.hvves.client.producer.impl; import org.jetbrains.annotations.NotNull; import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.HvVesProducer; -import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.domain.VesEvent; +import org.onap.ves.VesEventOuterClass.VesEvent; import org.reactivestreams.Publisher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; + /** * @author <a href="mailto:piotr.jaszczyk@nokia.com">Piotr Jaszczyk</a> */ @@ -37,7 +38,7 @@ public class HvVesProducerImpl implements HvVesProducer { @Override public @NotNull Mono<Void> send(Publisher<VesEvent> messages) { return Flux.from(messages) - .doOnNext(msg -> LOGGER.info("Dummy sending: {}", msg.data)) + .doOnNext(msg -> LOGGER.info("Not-so-dummy sending: {}", msg.toString())) .then(); } } diff --git a/services/hv-ves-client/producer/pom.xml b/services/hv-ves-client/producer/pom.xml index 89020fdb..75b537f2 100644 --- a/services/hv-ves-client/producer/pom.xml +++ b/services/hv-ves-client/producer/pom.xml @@ -31,7 +31,6 @@ </parent> <artifactId>hvvesclient-producer</artifactId> - <version>1.1.1-SNAPSHOT</version> <name>High Volume VES Collector Client :: Producer</name> <description></description> diff --git a/services/hv-ves-client/protobuf/pom.xml b/services/hv-ves-client/protobuf/pom.xml new file mode 100644 index 00000000..75b1f7e1 --- /dev/null +++ b/services/hv-ves-client/protobuf/pom.xml @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ ============LICENSE_START======================================================= + ~ DCAEGEN2-SERVICES-SDK + ~ ================================================================================ + ~ Copyright (C) 2019 Nokia + ~ ================================================================================ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + ~ ============LICENSE_END========================================================= + --> +<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> + + <parent> + <artifactId>dcaegen2-services-sdk-services-hvvesclient</artifactId> + <groupId>org.onap.dcaegen2.services.sdk</groupId> + <version>1.1.1-SNAPSHOT</version> + <relativePath>..</relativePath> + </parent> + + <name>High Volume VES Collector Client :: Protobuf</name> + <artifactId>hvvesclient-protobuf</artifactId> + <description>Module for generating java classes from Google Protocol Buffers files</description> + + <properties> + <protobuf-generated-files.directory>${project.build.directory}/generated-sources/proto/main/java/ + </protobuf-generated-files.directory> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>${protobuf-generated-files.directory}</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.github.os72</groupId> + <artifactId>protoc-jar-maven-plugin</artifactId> + <executions> + <execution> + <phase>generate-sources</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <protocArtifact>com.google.protobuf:protoc:${protobuf.version}</protocArtifact> + <inputDirectories> + <include>${project.basedir}/src/main/proto</include> + </inputDirectories> + <outputTargets> + <outputTarget> + <type>java</type> + <addSources>none</addSources> + <outputDirectory>${protobuf-generated-files.directory}</outputDirectory> + </outputTarget> + </outputTargets> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protobuf-java</artifactId> + </dependency> + </dependencies> + +</project>
\ No newline at end of file diff --git a/services/hv-ves-client/protobuf/src/main/proto/MeasDataCollection.proto b/services/hv-ves-client/protobuf/src/main/proto/MeasDataCollection.proto new file mode 100644 index 00000000..498358fc --- /dev/null +++ b/services/hv-ves-client/protobuf/src/main/proto/MeasDataCollection.proto @@ -0,0 +1,78 @@ +/* + * ============LICENSE_START======================================================= + * dcaegen2-collectors-veshv + * ================================================================================ + * Copyright (C) 2018 NOKIA + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +syntax = "proto3"; +package org.onap.ves; + +// Definition for RTPM, structure aligned with 3GPP PM format optimized for RTPM delivery pre-standard TS 28.550 V2.0.0 (2018-09). +// Some field details are taken from 3GPP TS 32.436 V15.0.0 (2018-06) ASN.1 file. +// Note (2018-09): work is in progress for 3GPP TS 28.550. Changes will be made, if needed, to align with final version. +// Differences/additions to 3GPP TS 28.550 are marked with "%%". + +message MeasDataCollection // top-level message +{ + // %% Combined messageFileHeader, measData (single instance), messageFileFooter (not needed: timestamp = collectionBeginTime + granularityPeriod). + string formatVersion = 1; // required, current value "28.550 2.0" + uint32 granularityPeriod = 2; // required, duration in seconds, %% moved from MeasInfo (single reporting period per event) + string measuredEntityUserName = 3; // network function user definable name ("userLabel") defined for the measured entity in 3GPP TS 28.622 + string measuredEntityDn = 4; // DN as per 3GPP TS 32.300 + string measuredEntitySoftwareVersion = 5; + repeated string measObjInstIdList = 6; // %%: optional, monitored object LDNs as per 3GPP TS 32.300 and 3GPP TS 32.432 + repeated MeasInfo measInfo = 7; +} + +message MeasInfo +{ + oneof MeasInfoId { // measurement group identifier + uint32 iMeasInfoId = 1; // identifier as integer (%%: more compact) + string sMeasInfoId = 2; // identifier as string (more generic) + } + + oneof MeasTypes { // measurement identifiers associated with the measurement results + IMeasTypes iMeasTypes = 3; // identifiers as integers (%%: more compact) + SMeasTypes sMeasTypes = 4; // identifiers as strings (more generic) + } + // Needed only because GPB does not support repeated fields directly inside 'oneof' + message IMeasTypes { repeated uint32 iMeasType = 1; } + message SMeasTypes { repeated string sMeasType = 1; } + + string jobId = 5; + repeated MeasValue measValues = 6; // performance measurements grouped by measurement object +} + +message MeasValue +{ + oneof MeasObjInstId { // monitored object LDN as per 3GPP TS 32.300 and 3GPP TS 32.432 + string sMeasObjInstId = 1; // LDN itself + uint32 measObjInstIdListIdx = 2; // %%: index into measObjInstIdList (1-based) + } + repeated MeasResult measResults = 3; + bool suspectFlag = 4; + map<string, string> measObjAddlFlds = 5; // %%: optional per-object data (name/value HashMap) +} + +message MeasResult +{ + uint32 p = 1; // Index in the MeasTypes array (1-based), needed only if measResults has fewer elements than MeasTypes + oneof xValue { + sint64 iValue = 2; + double rValue = 3; + bool isNull = 4; + } +} diff --git a/services/hv-ves-client/producer/api/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/domain/VesEvent.java b/services/hv-ves-client/protobuf/src/main/proto/Perf3gppFields.proto index 23b093f3..453d1062 100644 --- a/services/hv-ves-client/producer/api/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/domain/VesEvent.java +++ b/services/hv-ves-client/protobuf/src/main/proto/Perf3gppFields.proto @@ -1,8 +1,8 @@ /* * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK + * dcaegen2-collectors-veshv * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. + * Copyright (C) 2018 NOKIA * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,18 +17,21 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.dcaegen2.services.sdk.services.hvves.client.producer.domain; +syntax = "proto3"; +package org.onap.ves; +import "MeasDataCollection.proto"; // for 3GPP PM format -import org.jetbrains.annotations.TestOnly; - -/** - * TODO: should be generated from protobuf definitions in a separate module. - */ -@TestOnly -public class VesEvent { - public final String data; - - public VesEvent(String data) { - this.data = data; - } +message Perf3gppFields +{ + string perf3gppFieldsVersion = 1; // required, current value "1.0" + MeasDataCollection measDataCollection = 2; // required + // Based on 3GPP TS 28.550 + // Logical mapping from 3GPP to ONAP header fields: + // 3GPP MeasFileHeader ONAP/VES CommonEventHeader + // senderName sourceName + // senderType nfNamingCode + nfcNamingCode + // vendorName nfVendorName + // collectionBeginTime startEpochMicrosec + // timestamp lastEpochMicrosec + map<string, string> eventAddlFlds = 3; // optional per-event data (name/value HashMap) } diff --git a/services/hv-ves-client/protobuf/src/main/proto/VesEvent.proto b/services/hv-ves-client/protobuf/src/main/proto/VesEvent.proto new file mode 100644 index 00000000..2db6b64e --- /dev/null +++ b/services/hv-ves-client/protobuf/src/main/proto/VesEvent.proto @@ -0,0 +1,75 @@ +/* + * ============LICENSE_START======================================================= + * dcaegen2-collectors-veshv + * ================================================================================ + * Copyright (C) 2018 NOKIA + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +syntax = "proto3"; +package org.onap.ves; + +message VesEvent // top-level message, currently the maximum event size supported by the HV-VES Collector is 1 MiB +{ + CommonEventHeader commonEventHeader=1; // required + + bytes eventFields=2; // required, payload + // this field contains a domain-specific GPB message + // the field being opaque (bytes), the decoding of the payload occurs in a separate step + // the name of the GPB message for domain XYZ is XyzFields + // e.g. for domain==perf3gpp, the GPB message is Perf3gppFields +} + +// VES CommonEventHeader adapted to GPB (Google Protocol Buffers) + +message CommonEventHeader +{ + string version = 1; // required, "version of the gpb common event header", current value "1.0" + string domain = 2; // required, "the eventing domain associated with the event", allowed values: + // fault, heartbeat, measurement, mobileFlow, other, pnfRegistration, sipSignaling, + // stateChange, syslog, thresholdCrossingAlert, voiceQuality, perf3gpp + + uint32 sequence = 3; // required, "ordering of events communicated by an event source instance or 0 if not needed" + + enum Priority + { + PRIORITY_NOT_PROVIDED = 0; + HIGH = 1; + MEDIUM = 2; + NORMAL = 3; + LOW = 4; + } + Priority priority = 4; // required, "processing priority" + + string eventId = 5; // required, "event key that is unique to the event source" + string eventName = 6; // required, "unique event name" + string eventType = 7; // "for example - guest05, platform" + + uint64 lastEpochMicrosec = 8; // required, "the latest unix time aka epoch time associated with the event from any component--as microseconds elapsed since 1 Jan 1970 not including leap seconds" + uint64 startEpochMicrosec = 9; // required, "the earliest unix time aka epoch time associated with the event from any component--as microseconds elapsed since 1 Jan 1970 not including leap seconds" + + string nfNamingCode = 10; // "4 character network function type, aligned with vnf naming standards" + string nfcNamingCode = 11; // "3 character network function component type, aligned with vfc naming standards" + string nfVendorName = 12; // " Vendor Name providing the nf " + + bytes reportingEntityId = 13; // "UUID identifying the entity reporting the event, for example an OAM VM; must be populated by the ATT enrichment process" + string reportingEntityName = 14; // required, "name of the entity reporting the event, for example, an EMS name; may be the same as sourceName should match A&AI entry" + bytes sourceId = 15; // "UUID identifying the entity experiencing the event issue; must be populated by the ATT enrichment process" + string sourceName = 16; // required, "name of the entity experiencing the event issued use A&AI entry" + string timeZoneOffset = 17; // "Offset to GMT to indicate local time zone for the device" + string vesEventListenerVersion = 18; // required, "Version of the VesEvent Listener", current value "7.2" + + reserved "InternalHeaderFields"; // "enrichment fields for internal VES Event Listener service use only, not supplied by event sources" + reserved 100; +} |