From 89ec57e95480fad586b86b8545cec5dd690eae4c Mon Sep 17 00:00:00 2001 From: Filip Krzywka Date: Thu, 17 Jan 2019 13:30:32 +0100 Subject: 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 --- pom.xml | 17 ++++ services/hv-ves-client/pom.xml | 2 +- services/hv-ves-client/producer/api/pom.xml | 6 ++ .../hvves/client/producer/api/HvVesProducer.java | 2 +- .../hvves/client/producer/domain/VesEvent.java | 34 -------- services/hv-ves-client/producer/ct/pom.xml | 15 ++-- .../hvves/client/producer/ct/HvVesProducerIT.java | 5 +- .../client/producer/ct/SystemUnderTestWrapper.java | 4 +- .../client/producer/impl/HvVesProducerImpl.java | 5 +- services/hv-ves-client/producer/pom.xml | 1 - services/hv-ves-client/protobuf/pom.xml | 97 ++++++++++++++++++++++ .../src/main/proto/MeasDataCollection.proto | 78 +++++++++++++++++ .../protobuf/src/main/proto/Perf3gppFields.proto | 37 +++++++++ .../protobuf/src/main/proto/VesEvent.proto | 75 +++++++++++++++++ 14 files changed, 330 insertions(+), 48 deletions(-) delete mode 100644 services/hv-ves-client/producer/api/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/domain/VesEvent.java create mode 100644 services/hv-ves-client/protobuf/pom.xml create mode 100644 services/hv-ves-client/protobuf/src/main/proto/MeasDataCollection.proto create mode 100644 services/hv-ves-client/protobuf/src/main/proto/Perf3gppFields.proto create mode 100644 services/hv-ves-client/protobuf/src/main/proto/VesEvent.proto diff --git a/pom.xml b/pom.xml index b52d203f..fe2684ed 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,8 @@ 1.7.25 1.2.3 2.23.4 + 3.6.1 + 3.6.0.2 @@ -80,6 +82,16 @@ maven-project-info-reports-plugin 2.9 + + org.codehaus.mojo + build-helper-maven-plugin + 1.7 + + + com.github.os72 + protoc-jar-maven-plugin + ${protoc-jar-maven-plugin.version} + @@ -157,6 +169,11 @@ spring-boot-starter-web ${spring.boot.version} + + com.google.protobuf + protobuf-java + ${protobuf.version} + org.immutables 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 @@ dcaegen2-services-sdk-services-hvvesclient - 1.1.1-SNAPSHOT High Volume VES Collector Client @@ -39,5 +38,6 @@ producer + protobuf 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 @@ -38,6 +38,12 @@ jar + + ${project.parent.groupId} + hvvesclient-protobuf + ${project.parent.version} + compile + org.reactivestreams reactive-streams 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/api/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/domain/VesEvent.java b/services/hv-ves-client/producer/api/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/domain/VesEvent.java deleted file mode 100644 index 23b093f3..00000000 --- a/services/hv-ves-client/producer/api/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/domain/VesEvent.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * DCAEGEN2-SERVICES-SDK - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * 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========================================================= - */ -package org.onap.dcaegen2.services.sdk.services.hvves.client.producer.domain; - -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; - } -} 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 @@ hvvesclient-producer-ct - 1.1.1-SNAPSHOT High Volume VES Collector Client :: Producer :: Component Tests @@ -40,16 +39,22 @@ - org.onap.dcaegen2.services.sdk + ${project.parent.groupId} hvvesclient-producer-api - ${project.version} + ${project.parent.version} - org.onap.dcaegen2.services.sdk + ${project.parent.groupId} hvvesclient-producer-impl - ${project.version} + ${project.parent.version} runtime + + ${project.parent.groupId} + hvvesclient-protobuf + ${project.parent.version} + compile + io.projectreactor.netty reactor-netty 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 input = Flux.just("hello", "world") - .map(VesEvent::new); + final Flux 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 Piotr Jaszczyk */ @@ -37,7 +38,7 @@ public class HvVesProducerImpl implements HvVesProducer { @Override public @NotNull Mono send(Publisher 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 @@ hvvesclient-producer - 1.1.1-SNAPSHOT High Volume VES Collector Client :: Producer 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 @@ + + + + 4.0.0 + + + dcaegen2-services-sdk-services-hvvesclient + org.onap.dcaegen2.services.sdk + 1.1.1-SNAPSHOT + .. + + + High Volume VES Collector Client :: Protobuf + hvvesclient-protobuf + Module for generating java classes from Google Protocol Buffers files + + + ${project.build.directory}/generated-sources/proto/main/java/ + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${protobuf-generated-files.directory} + + + + + + + com.github.os72 + protoc-jar-maven-plugin + + + generate-sources + + run + + + com.google.protobuf:protoc:${protobuf.version} + + ${project.basedir}/src/main/proto + + + + java + none + ${protobuf-generated-files.directory} + + + + + + + + + + + + com.google.protobuf + protobuf-java + + + + \ 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 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/protobuf/src/main/proto/Perf3gppFields.proto b/services/hv-ves-client/protobuf/src/main/proto/Perf3gppFields.proto new file mode 100644 index 00000000..453d1062 --- /dev/null +++ b/services/hv-ves-client/protobuf/src/main/proto/Perf3gppFields.proto @@ -0,0 +1,37 @@ +/* + * ============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; +import "MeasDataCollection.proto"; // for 3GPP PM format + +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 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; +} -- cgit 1.2.3-korg