From 23438166832778b36f3aac7b3cc0b81ab6e8da1e Mon Sep 17 00:00:00 2001 From: fkrzywka Date: Tue, 5 Jun 2018 12:55:06 +0200 Subject: Extract domain module WireFrame extracted to domain module Domain package name in collector-core changed to avoid collision Merged Protobuf module with new domain module Closes ONAP-253. Change-Id: Ie7ac0bb877eae018a7520b4f3ceebe9fd51dbf65 Signed-off-by: fkrzywka Issue-ID: DCAEGEN2-601 --- hv-collector-client-simulator/pom.xml | 2 +- hv-collector-core/pom.xml | 5 +- .../dcae/collectors/veshv/boundary/adapters.kt | 6 +- .../org/onap/dcae/collectors/veshv/boundary/api.kt | 2 +- .../veshv/domain/CollectorConfiguration.kt | 26 ----- .../dcae/collectors/veshv/domain/RoutedMessage.kt | 22 ---- .../veshv/domain/SecurityConfiguration.kt | 31 ----- .../collectors/veshv/domain/ServerConfiguration.kt | 29 ----- .../dcae/collectors/veshv/domain/VesMessage.kt | 29 ----- .../onap/dcae/collectors/veshv/domain/WireFrame.kt | 93 --------------- .../onap/dcae/collectors/veshv/domain/routing.kt | 82 ------------- .../collectors/veshv/factory/CollectorFactory.kt | 2 +- .../dcae/collectors/veshv/factory/ServerFactory.kt | 2 +- .../dcae/collectors/veshv/impl/MessageValidator.kt | 2 +- .../org/onap/dcae/collectors/veshv/impl/Router.kt | 6 +- .../onap/dcae/collectors/veshv/impl/VesDecoder.kt | 4 +- .../dcae/collectors/veshv/impl/VesHvCollector.kt | 4 +- .../veshv/impl/adapters/AdapterFactory.kt | 2 +- .../impl/adapters/ConsulConfigurationProvider.kt | 4 +- .../collectors/veshv/impl/adapters/KafkaSink.kt | 4 +- .../collectors/veshv/impl/socket/NettyTcpServer.kt | 2 +- .../veshv/impl/socket/SslContextFactory.kt | 2 +- .../veshv/model/CollectorConfiguration.kt | 26 +++++ .../dcae/collectors/veshv/model/RoutedMessage.kt | 22 ++++ .../veshv/model/SecurityConfiguration.kt | 31 +++++ .../collectors/veshv/model/ServerConfiguration.kt | 29 +++++ .../onap/dcae/collectors/veshv/model/VesMessage.kt | 29 +++++ .../onap/dcae/collectors/veshv/model/routing.kt | 82 +++++++++++++ .../dcae/collectors/veshv/domain/WireFrameTest.kt | 55 --------- .../collectors/veshv/impl/MessageValidatorTest.kt | 2 +- .../onap/dcae/collectors/veshv/impl/RouterTest.kt | 4 +- .../dcae/collectors/veshv/impl/VesDecoderTest.kt | 3 +- .../dcae/collectors/veshv/impl/WireDecoderTest.kt | 4 +- .../veshv/impl/socket/SslContextFactoryTest.kt | 3 +- .../dcae/collectors/veshv/tests/component/Sut.kt | 2 +- .../collectors/veshv/tests/fakes/configuration.kt | 4 +- .../onap/dcae/collectors/veshv/tests/fakes/sink.kt | 5 +- hv-collector-domain/pom.xml | 128 +++++++++++++++++++++ .../onap/dcae/collectors/veshv/domain/WireFrame.kt | 93 +++++++++++++++ .../src/main/proto/HVRanMeasFields-v5.proto | 54 +++++++++ .../src/main/proto/VesEvent-v5.proto | 86 ++++++++++++++ .../dcae/collectors/veshv/domain/WireFrameTest.kt | 55 +++++++++ hv-collector-domain/src/test/resources/logback.xml | 54 +++++++++ .../veshv/main/ArgBasedServerConfiguration.kt | 4 +- .../org/onap/dcae/collectors/veshv/main/main.kt | 6 +- .../veshv/main/ArgBasedServerConfigurationTest.kt | 4 +- pom.xml | 20 ++-- protobuf/pom.xml | 96 ---------------- protobuf/src/main/proto/HVRanMeasFields-v5.proto | 54 --------- protobuf/src/main/proto/VesEvent-v5.proto | 86 -------------- 50 files changed, 742 insertions(+), 660 deletions(-) delete mode 100644 hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/CollectorConfiguration.kt delete mode 100644 hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/RoutedMessage.kt delete mode 100644 hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/SecurityConfiguration.kt delete mode 100644 hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/ServerConfiguration.kt delete mode 100644 hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/VesMessage.kt delete mode 100644 hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrame.kt delete mode 100644 hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/routing.kt create mode 100644 hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/CollectorConfiguration.kt create mode 100644 hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/RoutedMessage.kt create mode 100644 hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/SecurityConfiguration.kt create mode 100644 hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/ServerConfiguration.kt create mode 100644 hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/VesMessage.kt create mode 100644 hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/routing.kt delete mode 100644 hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrameTest.kt create mode 100644 hv-collector-domain/pom.xml create mode 100644 hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrame.kt create mode 100644 hv-collector-domain/src/main/proto/HVRanMeasFields-v5.proto create mode 100644 hv-collector-domain/src/main/proto/VesEvent-v5.proto create mode 100644 hv-collector-domain/src/test/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrameTest.kt create mode 100644 hv-collector-domain/src/test/resources/logback.xml delete mode 100644 protobuf/pom.xml delete mode 100644 protobuf/src/main/proto/HVRanMeasFields-v5.proto delete mode 100644 protobuf/src/main/proto/VesEvent-v5.proto diff --git a/hv-collector-client-simulator/pom.xml b/hv-collector-client-simulator/pom.xml index 6b106373..869d17d6 100644 --- a/hv-collector-client-simulator/pom.xml +++ b/hv-collector-client-simulator/pom.xml @@ -60,7 +60,7 @@ ${project.parent.groupId} - protobuf + hv-collector-domain ${project.parent.version} diff --git a/hv-collector-core/pom.xml b/hv-collector-core/pom.xml index 8155b14b..ed9f1ad5 100644 --- a/hv-collector-core/pom.xml +++ b/hv-collector-core/pom.xml @@ -64,13 +64,14 @@ ${project.parent.groupId} - protobuf + hv-collector-utils ${project.parent.version} ${project.parent.groupId} - hv-collector-utils + hv-collector-domain ${project.parent.version} + compile diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/boundary/adapters.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/boundary/adapters.kt index 53539a99..53fd7c3a 100644 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/boundary/adapters.kt +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/boundary/adapters.kt @@ -19,9 +19,9 @@ */ package org.onap.dcae.collectors.veshv.boundary -import org.onap.dcae.collectors.veshv.domain.CollectorConfiguration -import org.onap.dcae.collectors.veshv.domain.RoutedMessage -import org.onap.dcae.collectors.veshv.domain.VesMessage +import org.onap.dcae.collectors.veshv.model.CollectorConfiguration +import org.onap.dcae.collectors.veshv.model.RoutedMessage +import org.onap.dcae.collectors.veshv.model.VesMessage import reactor.core.publisher.Flux interface Sink { diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/boundary/api.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/boundary/api.kt index 0a10996b..dfbbdb56 100644 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/boundary/api.kt +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/boundary/api.kt @@ -20,7 +20,7 @@ package org.onap.dcae.collectors.veshv.boundary import io.netty.buffer.ByteBuf -import org.onap.dcae.collectors.veshv.domain.ServerConfiguration +import org.onap.dcae.collectors.veshv.model.ServerConfiguration import reactor.core.publisher.Flux import reactor.core.publisher.Mono diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/CollectorConfiguration.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/CollectorConfiguration.kt deleted file mode 100644 index 3e1623ad..00000000 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/CollectorConfiguration.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * ============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========================================================= - */ -package org.onap.dcae.collectors.veshv.domain - -/** - * @author Piotr Jaszczyk - * @since May 2018 - */ -data class CollectorConfiguration(val kafkaBootstrapServers: String, val routing: Routing) diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/RoutedMessage.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/RoutedMessage.kt deleted file mode 100644 index e4d147b1..00000000 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/RoutedMessage.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * ============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========================================================= - */ -package org.onap.dcae.collectors.veshv.domain - -data class RoutedMessage(val topic: String, val partition: Int, val message: VesMessage) diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/SecurityConfiguration.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/SecurityConfiguration.kt deleted file mode 100644 index 6f28b6e9..00000000 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/SecurityConfiguration.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * ============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========================================================= - */ -package org.onap.dcae.collectors.veshv.domain - -import java.nio.file.Path - -/** - * @author Piotr Jaszczyk - * @since May 2018 - */ -data class SecurityConfiguration( - val privateKey: Path, - val cert: Path, - val trustedCert: Path) diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/ServerConfiguration.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/ServerConfiguration.kt deleted file mode 100644 index 7e6bb13f..00000000 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/ServerConfiguration.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * ============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========================================================= - */ -package org.onap.dcae.collectors.veshv.domain - -/** - * @author Piotr Jaszczyk - * @since May 2018 - */ -data class ServerConfiguration( - val port: Int, - val configurationUrl: String, - val securityConfiguration: SecurityConfiguration) diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/VesMessage.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/VesMessage.kt deleted file mode 100644 index 107c5af5..00000000 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/VesMessage.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * ============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========================================================= - */ -package org.onap.dcae.collectors.veshv.domain - -import io.netty.buffer.ByteBuf -import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader - -/** - * @author Piotr Jaszczyk - * @since May 2018 - */ -data class VesMessage(val header: CommonEventHeader, val rawMessage: ByteBuf) diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrame.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrame.kt deleted file mode 100644 index 92870d34..00000000 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrame.kt +++ /dev/null @@ -1,93 +0,0 @@ -/* - * ============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========================================================= - */ -package org.onap.dcae.collectors.veshv.domain - -import io.netty.buffer.ByteBuf -import io.netty.buffer.ByteBufAllocator - -/** - * Wire frame structure is presented bellow. All fields are in network byte order (big-endian). - * - * ``` - * ┌─────┬───────────────────────┬───────────────────────┬───────────────────────┐ - * │octet│ 0 │ 1 │ 2 │ - * ├─────┼──┬──┬──┬──┬──┬──┬──┬──┼──┬──┬──┬──┬──┬──┬──┬──┼──┬──┬──┬──┬──┬──┬──┬──┤ - * │ bit │ 0│ │ │ │ │ │ │ │ 8│ │ │ │ │ │ │ │16│ │ │ │ │ │ │ │ ... - * ├─────┼──┴──┴──┴──┴──┴──┴──┴──┼──┴──┴──┴──┴──┴──┴──┴──┼──┴──┴──┴──┴──┴──┴──┴──┤ - * │field│ 0xFF │ major version │ minor version │ - * └─────┴───────────────────────┴───────────────────────┴───────────────────────┘ - * ┌─────┬───────────────────────┬───────────────────────┬───────────────────────┬───────────────────────┐ - * │octet│ 3 │ 4 │ 5 │ 6 │ - * ├─────┼──┬──┬──┬──┬──┬──┬──┬──┼──┬──┬──┬──┬──┬──┬──┬──┼──┬──┬──┬──┬──┬──┬──┬──┼──┬──┬──┬──┬──┬──┬──┬──┤ - * ... │ bit │24│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ... - * ├─────┼──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┤ - * │field│ payload size │ - * └─────┴───────────────────────────────────────────────────────────────────────────────────────────────┘ - * ┌─────┬─────────────────────── - * │octet│ 7 ... - * ├─────┼──┬──┬──┬──┬──┬──┬──┬── - * ... │ bit │56│ │ │ │ │ │ │... - * ├─────┼──┴──┴──┴──┴──┴──┴──┴── - * │field│ protobuf payload - * └─────┴─────────────────────── - * ``` - * - * @author Piotr Jaszczyk - * @since May 2018 - */ -data class WireFrame(val payload: ByteBuf, - val mark: Short, - val majorVersion: Short, - val minorVersion: Short, - val payloadSize: Int) { - fun isValid(): Boolean { - return mark == FF_BYTE - && majorVersion == SUPPORTED_MAJOR_VERSION - && payload.readableBytes() == payloadSize - } - - fun encode(allocator: ByteBufAllocator): ByteBuf { - val bb = allocator.buffer(HEADER_SIZE + payload.readableBytes()) - - bb.writeByte(mark.toInt()) - bb.writeByte(majorVersion.toInt()) - bb.writeByte(minorVersion.toInt()) - bb.writeInt(payloadSize) - bb.writeBytes(payload) - - return bb - } - - companion object { - fun decode(byteBuf: ByteBuf): WireFrame { - val mark = byteBuf.readUnsignedByte() - val majorVersion = byteBuf.readUnsignedByte() - val minorVersion = byteBuf.readUnsignedByte() - val payloadSize = byteBuf.readInt() - val payload = byteBuf.retainedSlice() - - return WireFrame(payload, mark, majorVersion, minorVersion, payloadSize) - } - - private const val HEADER_SIZE = 3 + java.lang.Integer.BYTES - private const val FF_BYTE: Short = 0xFF - private const val SUPPORTED_MAJOR_VERSION: Short = 1 - } -} diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/routing.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/routing.kt deleted file mode 100644 index 4b39bcd4..00000000 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/routing.kt +++ /dev/null @@ -1,82 +0,0 @@ -/* - * ============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========================================================= - */ -package org.onap.dcae.collectors.veshv.domain - -import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader -import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader.Domain - -data class Routing(val routes: List) { - - fun routeFor(commonHeader: CommonEventHeader): Route? = routes.find { it.applies(commonHeader) } -} - -data class Route(val domain: Domain, val targetTopic: String, val partitioning: (CommonEventHeader) -> Int) { - - fun applies(commonHeader: CommonEventHeader) = commonHeader.domain == domain - - operator fun invoke(message: VesMessage): RoutedMessage = - RoutedMessage(targetTopic, partitioning(message.header), message) -} - - -/* -Configuration DSL - */ - -fun routing(init: RoutingBuilder.() -> Unit): RoutingBuilder { - val conf = RoutingBuilder() - conf.init() - return conf -} - -class RoutingBuilder { - private val routes: MutableList = mutableListOf() - - fun defineRoute(init: RouteBuilder.() -> Unit): RouteBuilder { - val rule = RouteBuilder() - rule.init() - routes.add(rule) - return rule - } - - fun build() = Routing(routes.map { it.build() }.toList()) -} - -class RouteBuilder { - - private lateinit var domain: Domain - private lateinit var targetTopic: String - private lateinit var partitioning: (CommonEventHeader) -> Int - - fun fromDomain(domain: Domain) { - this.domain = domain - } - - fun toTopic(targetTopic: String) { - this.targetTopic = targetTopic - } - - fun withFixedPartitioning(num: Int = 1) { - partitioning = { _ -> num } - } - - fun build() = Route(domain, targetTopic, partitioning) - -} diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/factory/CollectorFactory.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/factory/CollectorFactory.kt index 30b2e9c1..850d3a84 100644 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/factory/CollectorFactory.kt +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/factory/CollectorFactory.kt @@ -23,7 +23,7 @@ import org.onap.dcae.collectors.veshv.boundary.Collector import org.onap.dcae.collectors.veshv.boundary.CollectorProvider import org.onap.dcae.collectors.veshv.boundary.ConfigurationProvider import org.onap.dcae.collectors.veshv.boundary.SinkProvider -import org.onap.dcae.collectors.veshv.domain.CollectorConfiguration +import org.onap.dcae.collectors.veshv.model.CollectorConfiguration import org.onap.dcae.collectors.veshv.impl.MessageValidator import org.onap.dcae.collectors.veshv.impl.Router import org.onap.dcae.collectors.veshv.impl.VesDecoder diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/factory/ServerFactory.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/factory/ServerFactory.kt index 67ba0d40..32fe6eb6 100644 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/factory/ServerFactory.kt +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/factory/ServerFactory.kt @@ -21,7 +21,7 @@ package org.onap.dcae.collectors.veshv.factory import org.onap.dcae.collectors.veshv.boundary.CollectorProvider import org.onap.dcae.collectors.veshv.boundary.Server -import org.onap.dcae.collectors.veshv.domain.ServerConfiguration +import org.onap.dcae.collectors.veshv.model.ServerConfiguration import org.onap.dcae.collectors.veshv.impl.socket.NettyTcpServer import org.onap.dcae.collectors.veshv.impl.socket.SslContextFactory diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidator.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidator.kt index 8d009c27..b0a9da81 100644 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidator.kt +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidator.kt @@ -19,7 +19,7 @@ */ package org.onap.dcae.collectors.veshv.impl -import org.onap.dcae.collectors.veshv.domain.VesMessage +import org.onap.dcae.collectors.veshv.model.VesMessage import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader internal class MessageValidator { diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/Router.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/Router.kt index 8c005d42..e66336dc 100644 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/Router.kt +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/Router.kt @@ -1,8 +1,8 @@ package org.onap.dcae.collectors.veshv.impl -import org.onap.dcae.collectors.veshv.domain.RoutedMessage -import org.onap.dcae.collectors.veshv.domain.Routing -import org.onap.dcae.collectors.veshv.domain.VesMessage +import org.onap.dcae.collectors.veshv.model.RoutedMessage +import org.onap.dcae.collectors.veshv.model.Routing +import org.onap.dcae.collectors.veshv.model.VesMessage class Router(private val routing: Routing) { fun findDestination(message: VesMessage): RoutedMessage? = routing.routeFor(message.header)?.invoke(message) diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesDecoder.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesDecoder.kt index c5b40ecb..cdc70f82 100644 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesDecoder.kt +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesDecoder.kt @@ -21,11 +21,9 @@ package org.onap.dcae.collectors.veshv.impl import com.google.protobuf.InvalidProtocolBufferException import io.netty.buffer.ByteBuf -import org.onap.dcae.collectors.veshv.domain.VesMessage +import org.onap.dcae.collectors.veshv.model.VesMessage import org.onap.dcae.collectors.veshv.utils.logging.Logger import org.onap.ves.VesEventV5.VesEvent -import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader -import reactor.core.publisher.Mono /** * @author Piotr Jaszczyk diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt index ef192f04..b0f877f0 100644 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt @@ -22,8 +22,8 @@ package org.onap.dcae.collectors.veshv.impl import io.netty.buffer.ByteBuf import org.onap.dcae.collectors.veshv.boundary.Collector import org.onap.dcae.collectors.veshv.boundary.Sink -import org.onap.dcae.collectors.veshv.domain.RoutedMessage -import org.onap.dcae.collectors.veshv.domain.VesMessage +import org.onap.dcae.collectors.veshv.model.RoutedMessage +import org.onap.dcae.collectors.veshv.model.VesMessage import reactor.core.publisher.Flux import reactor.core.publisher.Mono diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/AdapterFactory.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/AdapterFactory.kt index 0f5406e1..8a34185f 100644 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/AdapterFactory.kt +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/AdapterFactory.kt @@ -27,7 +27,7 @@ import org.apache.kafka.common.serialization.StringSerializer import org.onap.dcae.collectors.veshv.boundary.ConfigurationProvider import org.onap.dcae.collectors.veshv.boundary.Sink import org.onap.dcae.collectors.veshv.boundary.SinkProvider -import org.onap.dcae.collectors.veshv.domain.CollectorConfiguration +import org.onap.dcae.collectors.veshv.model.CollectorConfiguration import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader import reactor.core.publisher.Flux import reactor.ipc.netty.http.client.HttpClient diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/ConsulConfigurationProvider.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/ConsulConfigurationProvider.kt index ef6c2f76..263e7d44 100644 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/ConsulConfigurationProvider.kt +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/ConsulConfigurationProvider.kt @@ -1,7 +1,7 @@ package org.onap.dcae.collectors.veshv.impl.adapters import org.onap.dcae.collectors.veshv.boundary.ConfigurationProvider -import org.onap.dcae.collectors.veshv.domain.CollectorConfiguration +import org.onap.dcae.collectors.veshv.model.CollectorConfiguration import org.onap.ves.VesEventV5 import org.slf4j.LoggerFactory import reactor.core.publisher.Flux @@ -46,7 +46,7 @@ internal class ConsulConfigurationProvider(private val url: String, private val return CollectorConfiguration( kafkaBootstrapServers = configuration.getString("kafkaBootstrapServers"), - routing = org.onap.dcae.collectors.veshv.domain.routing { + routing = org.onap.dcae.collectors.veshv.model.routing { defineRoute { fromDomain(VesEventV5.VesEvent.CommonEventHeader.Domain.forNumber(routing.getInt("fromDomain"))) toTopic(routing.getString("toTopic")) diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/KafkaSink.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/KafkaSink.kt index fd02aa98..db7845c7 100644 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/KafkaSink.kt +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/KafkaSink.kt @@ -20,8 +20,8 @@ package org.onap.dcae.collectors.veshv.impl.adapters import org.onap.dcae.collectors.veshv.boundary.Sink -import org.onap.dcae.collectors.veshv.domain.RoutedMessage -import org.onap.dcae.collectors.veshv.domain.VesMessage +import org.onap.dcae.collectors.veshv.model.RoutedMessage +import org.onap.dcae.collectors.veshv.model.VesMessage import org.onap.dcae.collectors.veshv.utils.logging.Logger import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader import reactor.core.publisher.Flux diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/socket/NettyTcpServer.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/socket/NettyTcpServer.kt index b9faf6d0..415aa217 100644 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/socket/NettyTcpServer.kt +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/socket/NettyTcpServer.kt @@ -21,7 +21,7 @@ package org.onap.dcae.collectors.veshv.impl.socket import org.onap.dcae.collectors.veshv.boundary.CollectorProvider import org.onap.dcae.collectors.veshv.boundary.Server -import org.onap.dcae.collectors.veshv.domain.ServerConfiguration +import org.onap.dcae.collectors.veshv.model.ServerConfiguration import org.onap.dcae.collectors.veshv.utils.logging.Logger import org.reactivestreams.Publisher import reactor.core.publisher.Mono diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/socket/SslContextFactory.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/socket/SslContextFactory.kt index b6fb1cf8..950e2c86 100644 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/socket/SslContextFactory.kt +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/socket/SslContextFactory.kt @@ -23,7 +23,7 @@ import io.netty.handler.ssl.ClientAuth import io.netty.handler.ssl.SslContext import io.netty.handler.ssl.SslContextBuilder import io.netty.handler.ssl.SslProvider -import org.onap.dcae.collectors.veshv.domain.SecurityConfiguration +import org.onap.dcae.collectors.veshv.model.SecurityConfiguration internal open class SslContextFactory { diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/CollectorConfiguration.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/CollectorConfiguration.kt new file mode 100644 index 00000000..ec546c7d --- /dev/null +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/CollectorConfiguration.kt @@ -0,0 +1,26 @@ +/* + * ============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========================================================= + */ +package org.onap.dcae.collectors.veshv.model + +/** + * @author Piotr Jaszczyk + * @since May 2018 + */ +data class CollectorConfiguration(val kafkaBootstrapServers: String, val routing: Routing) diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/RoutedMessage.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/RoutedMessage.kt new file mode 100644 index 00000000..782877e3 --- /dev/null +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/RoutedMessage.kt @@ -0,0 +1,22 @@ +/* + * ============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========================================================= + */ +package org.onap.dcae.collectors.veshv.model + +data class RoutedMessage(val topic: String, val partition: Int, val message: VesMessage) diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/SecurityConfiguration.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/SecurityConfiguration.kt new file mode 100644 index 00000000..9a10801a --- /dev/null +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/SecurityConfiguration.kt @@ -0,0 +1,31 @@ +/* + * ============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========================================================= + */ +package org.onap.dcae.collectors.veshv.model + +import java.nio.file.Path + +/** + * @author Piotr Jaszczyk + * @since May 2018 + */ +data class SecurityConfiguration( + val privateKey: Path, + val cert: Path, + val trustedCert: Path) diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/ServerConfiguration.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/ServerConfiguration.kt new file mode 100644 index 00000000..f612cc75 --- /dev/null +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/ServerConfiguration.kt @@ -0,0 +1,29 @@ +/* + * ============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========================================================= + */ +package org.onap.dcae.collectors.veshv.model + +/** + * @author Piotr Jaszczyk + * @since May 2018 + */ +data class ServerConfiguration( + val port: Int, + val configurationUrl: String, + val securityConfiguration: SecurityConfiguration) diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/VesMessage.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/VesMessage.kt new file mode 100644 index 00000000..38256896 --- /dev/null +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/VesMessage.kt @@ -0,0 +1,29 @@ +/* + * ============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========================================================= + */ +package org.onap.dcae.collectors.veshv.model + +import io.netty.buffer.ByteBuf +import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader + +/** + * @author Piotr Jaszczyk + * @since May 2018 + */ +data class VesMessage(val header: CommonEventHeader, val rawMessage: ByteBuf) diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/routing.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/routing.kt new file mode 100644 index 00000000..10e79156 --- /dev/null +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/model/routing.kt @@ -0,0 +1,82 @@ +/* + * ============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========================================================= + */ +package org.onap.dcae.collectors.veshv.model + +import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader +import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader.Domain + +data class Routing(val routes: List) { + + fun routeFor(commonHeader: CommonEventHeader): Route? = routes.find { it.applies(commonHeader) } +} + +data class Route(val domain: Domain, val targetTopic: String, val partitioning: (CommonEventHeader) -> Int) { + + fun applies(commonHeader: CommonEventHeader) = commonHeader.domain == domain + + operator fun invoke(message: VesMessage): RoutedMessage = + RoutedMessage(targetTopic, partitioning(message.header), message) +} + + +/* +Configuration DSL + */ + +fun routing(init: RoutingBuilder.() -> Unit): RoutingBuilder { + val conf = RoutingBuilder() + conf.init() + return conf +} + +class RoutingBuilder { + private val routes: MutableList = mutableListOf() + + fun defineRoute(init: RouteBuilder.() -> Unit): RouteBuilder { + val rule = RouteBuilder() + rule.init() + routes.add(rule) + return rule + } + + fun build() = Routing(routes.map { it.build() }.toList()) +} + +class RouteBuilder { + + private lateinit var domain: Domain + private lateinit var targetTopic: String + private lateinit var partitioning: (CommonEventHeader) -> Int + + fun fromDomain(domain: Domain) { + this.domain = domain + } + + fun toTopic(targetTopic: String) { + this.targetTopic = targetTopic + } + + fun withFixedPartitioning(num: Int = 1) { + partitioning = { _ -> num } + } + + fun build() = Route(domain, targetTopic, partitioning) + +} diff --git a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrameTest.kt b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrameTest.kt deleted file mode 100644 index 5a923c4e..00000000 --- a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrameTest.kt +++ /dev/null @@ -1,55 +0,0 @@ -package org.onap.dcae.collectors.veshv.domain - -import io.netty.buffer.ByteBufAllocator -import io.netty.buffer.Unpooled -import org.assertj.core.api.Assertions.assertThat -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.describe -import org.jetbrains.spek.api.dsl.it - -/** - * @author Piotr Jaszczyk - * @since June 2018 - */ -object WireFrameTest : Spek({ - describe("Wire Frame codec") { - describe("encode-decode methods' compatibility") { - val payloadContent = "test" - val payload = Unpooled.wrappedBuffer(payloadContent.toByteArray(Charsets.US_ASCII)) - val frame = WireFrame(payload = payload, - majorVersion = 1, - minorVersion = 2, - mark = 0xFF, - payloadSize = payload.readableBytes()) - - val encoded = frame.encode(ByteBufAllocator.DEFAULT) - val decoded = WireFrame.decode(encoded) - - it("should decode major version") { - assertThat(decoded.majorVersion).isEqualTo(frame.majorVersion) - } - - it("should decode minor version") { - assertThat(decoded.minorVersion).isEqualTo(frame.minorVersion) - } - - it("should decode mark") { - assertThat(decoded.mark).isEqualTo(frame.mark) - } - - it("should decode payload size") { - assertThat(decoded.payloadSize).isEqualTo(frame.payloadSize) - } - - it("should decode payload") { - assertThat(decoded.payload.toString(Charsets.US_ASCII)) - .isEqualTo(payloadContent) - } - - it("should retain decoded payload") { - encoded.release() - assertThat(decoded.payload.refCnt()).isEqualTo(1) - } - } - } -}) \ No newline at end of file diff --git a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidatorTest.kt b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidatorTest.kt index 4f893307..df2840b9 100644 --- a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidatorTest.kt +++ b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidatorTest.kt @@ -27,7 +27,7 @@ import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.dsl.given import org.jetbrains.spek.api.dsl.it import org.jetbrains.spek.api.dsl.on -import org.onap.dcae.collectors.veshv.domain.VesMessage +import org.onap.dcae.collectors.veshv.model.VesMessage import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader import org.onap.ves.VesEventV5.VesEvent import org.assertj.core.api.Assertions.assertThat diff --git a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/RouterTest.kt b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/RouterTest.kt index ac91aaeb..3812db58 100644 --- a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/RouterTest.kt +++ b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/RouterTest.kt @@ -6,8 +6,8 @@ import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.dsl.given import org.jetbrains.spek.api.dsl.it import org.jetbrains.spek.api.dsl.on -import org.onap.dcae.collectors.veshv.domain.VesMessage -import org.onap.dcae.collectors.veshv.domain.routing +import org.onap.dcae.collectors.veshv.model.VesMessage +import org.onap.dcae.collectors.veshv.model.routing import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader.Domain diff --git a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/VesDecoderTest.kt b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/VesDecoderTest.kt index 1aae8540..8d9e4962 100644 --- a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/VesDecoderTest.kt +++ b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/VesDecoderTest.kt @@ -26,10 +26,9 @@ import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.dsl.given import org.jetbrains.spek.api.dsl.it import org.jetbrains.spek.api.dsl.on -import org.onap.dcae.collectors.veshv.domain.VesMessage +import org.onap.dcae.collectors.veshv.model.VesMessage import org.onap.ves.VesEventV5.VesEvent import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader -import reactor.test.StepVerifier import java.nio.charset.Charset diff --git a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/WireDecoderTest.kt b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/WireDecoderTest.kt index 3563bf6d..81706ce4 100644 --- a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/WireDecoderTest.kt +++ b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/WireDecoderTest.kt @@ -57,7 +57,7 @@ internal object WireDecoderTest : Spek({ given("input with too small payload size") { val input = WireFrame( - payload = Unpooled.wrappedBuffer(byteArrayOf(1, 2 ,3)), + payload = Unpooled.wrappedBuffer(byteArrayOf(1, 2, 3)), mark = 0xFF, majorVersion = 1, minorVersion = 0, @@ -70,7 +70,7 @@ internal object WireDecoderTest : Spek({ given("input with too big payload size") { val input = WireFrame( - payload = Unpooled.wrappedBuffer(byteArrayOf(1, 2 ,3)), + payload = Unpooled.wrappedBuffer(byteArrayOf(1, 2, 3)), mark = 0xFF, majorVersion = 1, minorVersion = 0, diff --git a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/socket/SslContextFactoryTest.kt b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/socket/SslContextFactoryTest.kt index 227e9b9c..dcd4f412 100644 --- a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/socket/SslContextFactoryTest.kt +++ b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/socket/SslContextFactoryTest.kt @@ -27,8 +27,7 @@ import org.assertj.core.api.Assertions.assertThat import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.it -import org.jetbrains.spek.api.dsl.xit -import org.onap.dcae.collectors.veshv.domain.SecurityConfiguration +import org.onap.dcae.collectors.veshv.model.SecurityConfiguration import java.nio.file.Paths /** diff --git a/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/Sut.kt b/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/Sut.kt index d1711b67..1826bcd0 100644 --- a/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/Sut.kt +++ b/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/Sut.kt @@ -22,7 +22,7 @@ package org.onap.dcae.collectors.veshv.tests.component import io.netty.buffer.ByteBuf import org.onap.dcae.collectors.veshv.boundary.Collector import org.onap.dcae.collectors.veshv.boundary.SinkProvider -import org.onap.dcae.collectors.veshv.domain.RoutedMessage +import org.onap.dcae.collectors.veshv.model.RoutedMessage import org.onap.dcae.collectors.veshv.factory.CollectorFactory import org.onap.dcae.collectors.veshv.tests.fakes.FakeConfigurationProvider import org.onap.dcae.collectors.veshv.tests.fakes.FakeSink diff --git a/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/fakes/configuration.kt b/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/fakes/configuration.kt index b82faf3b..82226dc2 100644 --- a/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/fakes/configuration.kt +++ b/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/fakes/configuration.kt @@ -20,8 +20,8 @@ package org.onap.dcae.collectors.veshv.tests.fakes import org.onap.dcae.collectors.veshv.boundary.ConfigurationProvider -import org.onap.dcae.collectors.veshv.domain.CollectorConfiguration -import org.onap.dcae.collectors.veshv.domain.routing +import org.onap.dcae.collectors.veshv.model.CollectorConfiguration +import org.onap.dcae.collectors.veshv.model.routing import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader.Domain import reactor.core.publisher.FluxProcessor import reactor.core.publisher.UnicastProcessor diff --git a/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/fakes/sink.kt b/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/fakes/sink.kt index 80fb3473..5d592e42 100644 --- a/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/fakes/sink.kt +++ b/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/fakes/sink.kt @@ -20,9 +20,8 @@ package org.onap.dcae.collectors.veshv.tests.fakes import org.onap.dcae.collectors.veshv.boundary.Sink -import org.onap.dcae.collectors.veshv.domain.RoutedMessage -import org.onap.dcae.collectors.veshv.domain.VesMessage -import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader +import org.onap.dcae.collectors.veshv.model.RoutedMessage +import org.onap.dcae.collectors.veshv.model.VesMessage import reactor.core.publisher.Flux import java.util.* import java.util.concurrent.ConcurrentLinkedDeque diff --git a/hv-collector-domain/pom.xml b/hv-collector-domain/pom.xml new file mode 100644 index 00000000..de9004a8 --- /dev/null +++ b/hv-collector-domain/pom.xml @@ -0,0 +1,128 @@ + + + + 4.0.0 + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + org.onap.dcaegen2.collectors.veshv + ves-hv-collector + 1.0.0-SNAPSHOT + .. + + + hv-collector-domain + VES HighVolume Collector :: Domain + + + false + + + + + + kotlin-maven-plugin + org.jetbrains.kotlin + + + org.apache.maven.plugins + maven-compiler-plugin + + + maven-surefire-plugin + org.apache.maven.plugins + + + org.codehaus.mojo + build-helper-maven-plugin + + + 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} + + + + + + + + + + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + + + io.projectreactor.ipc + reactor-netty + + + com.google.protobuf + protobuf-java + + + + org.assertj + assertj-core + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + + + org.jetbrains.spek + spek-api + + + org.jetbrains.spek + spek-junit-platform-engine + + + + + diff --git a/hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrame.kt b/hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrame.kt new file mode 100644 index 00000000..906441b9 --- /dev/null +++ b/hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrame.kt @@ -0,0 +1,93 @@ +/* + * ============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========================================================= + */ +package org.onap.dcae.collectors.veshv.domain + +import io.netty.buffer.ByteBuf +import io.netty.buffer.ByteBufAllocator + +/** + * Wire frame structure is presented bellow. All fields are in network byte order (big-endian). + * + * ``` + * ┌─────┬───────────────────────┬───────────────────────┬───────────────────────┐ + * │octet│ 0 │ 1 │ 2 │ + * ├─────┼──┬──┬──┬──┬──┬──┬──┬──┼──┬──┬──┬──┬──┬──┬──┬──┼──┬──┬──┬──┬──┬──┬──┬──┤ + * │ bit │ 0│ │ │ │ │ │ │ │ 8│ │ │ │ │ │ │ │16│ │ │ │ │ │ │ │ ... + * ├─────┼──┴──┴──┴──┴──┴──┴──┴──┼──┴──┴──┴──┴──┴──┴──┴──┼──┴──┴──┴──┴──┴──┴──┴──┤ + * │field│ 0xFF │ major version │ minor version │ + * └─────┴───────────────────────┴───────────────────────┴───────────────────────┘ + * ┌─────┬───────────────────────┬───────────────────────┬───────────────────────┬───────────────────────┐ + * │octet│ 3 │ 4 │ 5 │ 6 │ + * ├─────┼──┬──┬──┬──┬──┬──┬──┬──┼──┬──┬──┬──┬──┬──┬──┬──┼──┬──┬──┬──┬──┬──┬──┬──┼──┬──┬──┬──┬──┬──┬──┬──┤ + * ... │ bit │24│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ... + * ├─────┼──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┤ + * │field│ payload size │ + * └─────┴───────────────────────────────────────────────────────────────────────────────────────────────┘ + * ┌─────┬─────────────────────── + * │octet│ 7 ... + * ├─────┼──┬──┬──┬──┬──┬──┬──┬── + * ... │ bit │56│ │ │ │ │ │ │... + * ├─────┼──┴──┴──┴──┴──┴──┴──┴── + * │field│ protobuf payload + * └─────┴─────────────────────── + * ``` + * + * @author Piotr Jaszczyk + * @since May 2018 + */ +data class WireFrame(val payload: ByteBuf, + val mark: Short, + val majorVersion: Short, + val minorVersion: Short, + val payloadSize: Int) { + + fun isValid(): Boolean = + mark == FF_BYTE + && majorVersion == SUPPORTED_MAJOR_VERSION + && payload.readableBytes() == payloadSize + + fun encode(allocator: ByteBufAllocator): ByteBuf { + val bb = allocator.buffer(HEADER_SIZE + payload.readableBytes()) + + bb.writeByte(mark.toInt()) + bb.writeByte(majorVersion.toInt()) + bb.writeByte(minorVersion.toInt()) + bb.writeInt(payloadSize) + bb.writeBytes(payload) + + return bb + } + + companion object { + fun decode(byteBuf: ByteBuf): WireFrame { + val mark = byteBuf.readUnsignedByte() + val majorVersion = byteBuf.readUnsignedByte() + val minorVersion = byteBuf.readUnsignedByte() + val payloadSize = byteBuf.readInt() + val payload = byteBuf.retainedSlice() + + return WireFrame(payload, mark, majorVersion, minorVersion, payloadSize) + } + + private const val HEADER_SIZE = 3 + java.lang.Integer.BYTES + private const val FF_BYTE: Short = 0xFF + private const val SUPPORTED_MAJOR_VERSION: Short = 1 + } +} diff --git a/hv-collector-domain/src/main/proto/HVRanMeasFields-v5.proto b/hv-collector-domain/src/main/proto/HVRanMeasFields-v5.proto new file mode 100644 index 00000000..5121f0eb --- /dev/null +++ b/hv-collector-domain/src/main/proto/HVRanMeasFields-v5.proto @@ -0,0 +1,54 @@ +/* + * ============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 + +message HVRanMeasFields { + message HVRanMeasPayload { + message PMObject { + message HVRanMeas { + uint32 measurement_id = 1; + repeated uint32 counter_subid = 2; + repeated sint64 counter_value = 3; + repeated uint32 missing_counter_subid = 4; + bool suspectFlagIncomplete = 5; // (some is data missing due to internal error) + bool suspectFlagOutOfSync = 6; // (source time not aligned) + } + + string uri = 1; // monitored object URI + repeated HVRanMeas hvRanMeas = 2; // performance counters grouped by measurement types + } + repeated PMObject pmObject = 1; + } + + message AdditionalField { + string name = 1; + string value = 2; + } + + string hvRanMeasFieldsVersion = 1; // version of HVRanMeasFields message + uint32 period_ms = 2; // period configured for reporting the data in milliseconds + string timezone = 3; // timezone of Network Function sending the data + string pmDictionaryVsn = 4; // vendor name + schema version E.g. NOKIA_LN7.0, uniquely identify the relevant PM dictionary + HVRanMeasPayload hvRanMeasPayload = 5; // objects being monitored + repeated AdditionalField additionalFields = 6; // array of name-value pairs if needed +} \ No newline at end of file diff --git a/hv-collector-domain/src/main/proto/VesEvent-v5.proto b/hv-collector-domain/src/main/proto/VesEvent-v5.proto new file mode 100644 index 00000000..022cce4e --- /dev/null +++ b/hv-collector-domain/src/main/proto/VesEvent-v5.proto @@ -0,0 +1,86 @@ +/* + * ============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 { + + // VES CommonEventHeader adapted to GPB (Google Protocol Buffers) + // Source: https://git.opnfv.org/ves/tree/tests/docs/ves_data_model.json + // 2017-05-13 Align with VES 5.0 schema. + // blob: ca948ff67e8a2de4e2a47cffc4d4d2893170ab76 + + message CommonEventHeader { + string version = 1; // required, "version of the event header" + enum Domain { + FAULT = 0; + HEARTBEAT = 1; + MEASUREMENTS_FOR_VF_SCALING = 2; + MOBILE_FLOW = 3; + SIP_SIGNALING = 4; + STATE_CHANGE = 5; + SYSLOG = 6; + THRESHOLD_CROSSING_ALERT = 7; + VOICE_QUALITY = 8; + OTHER = 9; + HVRANMEAS = 10; + } + Domain domain = 2; // required, "the eventing domain associated with the event" [map to string] + + uint32 sequence = 3; // required, "ordering of events communicated by an event source instance or 0 if not needed" + + enum Priority { + HIGH = 0; + MEDIUM = 1; + NORMAL = 2; + LOW = 3; + } + 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 - applicationVnf, guestOS, hostOS, 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 reportingEntityId = 12; // "UUID identifying the entity reporting the event, for example an OAM VM; must be populated by the ATT enrichment process" + bytes reportingEntityName = 13; // required, "name of the entity reporting the event, for example, an EMS name; may be the same as sourceName" + bytes sourceId = 14; // "UUID identifying the entity experiencing the event issue; must be populated by the ATT enrichment process" + string sourceName = 15; // required, "name of the entity experiencing the event issue" + + reserved "InternalHeaderFields"; // "enrichment fields for internal VES Event Listener service use only, not supplied by event sources" + reserved 100; + } + + CommonEventHeader commonEventHeader = 1; + + oneof eventFields // required, payload, each high-volume domain has its specific GPB schema + { + bytes hvRanMeasFields = 2; // if domain==HVRANMEAS, GPB schema: HVRanMeasFields.proto + } +} + +message VesEventList { + repeated VesEvent vesEvent = 1; +} diff --git a/hv-collector-domain/src/test/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrameTest.kt b/hv-collector-domain/src/test/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrameTest.kt new file mode 100644 index 00000000..5a923c4e --- /dev/null +++ b/hv-collector-domain/src/test/kotlin/org/onap/dcae/collectors/veshv/domain/WireFrameTest.kt @@ -0,0 +1,55 @@ +package org.onap.dcae.collectors.veshv.domain + +import io.netty.buffer.ByteBufAllocator +import io.netty.buffer.Unpooled +import org.assertj.core.api.Assertions.assertThat +import org.jetbrains.spek.api.Spek +import org.jetbrains.spek.api.dsl.describe +import org.jetbrains.spek.api.dsl.it + +/** + * @author Piotr Jaszczyk + * @since June 2018 + */ +object WireFrameTest : Spek({ + describe("Wire Frame codec") { + describe("encode-decode methods' compatibility") { + val payloadContent = "test" + val payload = Unpooled.wrappedBuffer(payloadContent.toByteArray(Charsets.US_ASCII)) + val frame = WireFrame(payload = payload, + majorVersion = 1, + minorVersion = 2, + mark = 0xFF, + payloadSize = payload.readableBytes()) + + val encoded = frame.encode(ByteBufAllocator.DEFAULT) + val decoded = WireFrame.decode(encoded) + + it("should decode major version") { + assertThat(decoded.majorVersion).isEqualTo(frame.majorVersion) + } + + it("should decode minor version") { + assertThat(decoded.minorVersion).isEqualTo(frame.minorVersion) + } + + it("should decode mark") { + assertThat(decoded.mark).isEqualTo(frame.mark) + } + + it("should decode payload size") { + assertThat(decoded.payloadSize).isEqualTo(frame.payloadSize) + } + + it("should decode payload") { + assertThat(decoded.payload.toString(Charsets.US_ASCII)) + .isEqualTo(payloadContent) + } + + it("should retain decoded payload") { + encoded.release() + assertThat(decoded.payload.refCnt()).isEqualTo(1) + } + } + } +}) \ No newline at end of file diff --git a/hv-collector-domain/src/test/resources/logback.xml b/hv-collector-domain/src/test/resources/logback.xml new file mode 100644 index 00000000..0bf2cb02 --- /dev/null +++ b/hv-collector-domain/src/test/resources/logback.xml @@ -0,0 +1,54 @@ + + + + + + + + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC} %highlight(%-5level) [%-40.40logger{10}] - %msg%n + + + + + + + ${FILE_LOG_PATTERN} + + ${LOG_FILE} + + ${LOG_FILE}.%d{yyyy-MM-dd}.log + 50MB + 30 + 10GB + + + + + + + + + + \ No newline at end of file diff --git a/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/ArgBasedServerConfiguration.kt b/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/ArgBasedServerConfiguration.kt index 9ba368eb..91d29106 100644 --- a/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/ArgBasedServerConfiguration.kt +++ b/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/ArgBasedServerConfiguration.kt @@ -20,8 +20,8 @@ package org.onap.dcae.collectors.veshv.main import org.apache.commons.cli.* -import org.onap.dcae.collectors.veshv.domain.SecurityConfiguration -import org.onap.dcae.collectors.veshv.domain.ServerConfiguration +import org.onap.dcae.collectors.veshv.model.ServerConfiguration +import org.onap.dcae.collectors.veshv.model.SecurityConfiguration import java.io.File import java.nio.file.Paths diff --git a/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/main.kt b/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/main.kt index 49739a80..89b31b59 100644 --- a/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/main.kt +++ b/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/main.kt @@ -20,9 +20,9 @@ package org.onap.dcae.collectors.veshv.main import org.onap.dcae.collectors.veshv.boundary.ConfigurationProvider -import org.onap.dcae.collectors.veshv.domain.CollectorConfiguration -import org.onap.dcae.collectors.veshv.domain.ServerConfiguration -import org.onap.dcae.collectors.veshv.domain.routing +import org.onap.dcae.collectors.veshv.model.CollectorConfiguration +import org.onap.dcae.collectors.veshv.model.ServerConfiguration +import org.onap.dcae.collectors.veshv.model.routing import org.onap.dcae.collectors.veshv.factory.CollectorFactory import org.onap.dcae.collectors.veshv.factory.ServerFactory import org.onap.dcae.collectors.veshv.impl.adapters.AdapterFactory diff --git a/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgBasedServerConfigurationTest.kt b/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgBasedServerConfigurationTest.kt index b10e3597..38845945 100644 --- a/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgBasedServerConfigurationTest.kt +++ b/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgBasedServerConfigurationTest.kt @@ -25,8 +25,8 @@ import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.given import org.jetbrains.spek.api.dsl.it import org.jetbrains.spek.api.dsl.on -import org.onap.dcae.collectors.veshv.domain.SecurityConfiguration -import org.onap.dcae.collectors.veshv.domain.ServerConfiguration +import org.onap.dcae.collectors.veshv.model.SecurityConfiguration +import org.onap.dcae.collectors.veshv.model.ServerConfiguration import java.nio.file.Paths /** diff --git a/pom.xml b/pom.xml index aba7059b..2fc094e0 100644 --- a/pom.xml +++ b/pom.xml @@ -37,16 +37,16 @@ VES HighVolume Collector pom - - hv-collector-core - hv-collector-main - hv-collector-ct - protobuf - hv-collector-utils - hv-collector-coverage - hv-collector-analysis - hv-collector-client-simulator - + + hv-collector-analysis + hv-collector-client-simulator + hv-collector-core + hv-collector-coverage + hv-collector-ct + hv-collector-domain + hv-collector-main + hv-collector-utils + 1.2.41 diff --git a/protobuf/pom.xml b/protobuf/pom.xml deleted file mode 100644 index 55db3f46..00000000 --- a/protobuf/pom.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - 4.0.0 - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - - - - - org.onap.dcaegen2.collectors.veshv - ves-hv-collector - 1.0.0-SNAPSHOT - .. - - - protobuf - Google Protocol Buffers schemas for VES-HV-Collector - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - org.apache.maven.plugins - maven-compiler-plugin - - - 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} - - - - - - - - maven-surefire-plugin - org.apache.maven.plugins - - true - - - - - - - - - com.google.protobuf - protobuf-java - - - - \ No newline at end of file diff --git a/protobuf/src/main/proto/HVRanMeasFields-v5.proto b/protobuf/src/main/proto/HVRanMeasFields-v5.proto deleted file mode 100644 index 5121f0eb..00000000 --- a/protobuf/src/main/proto/HVRanMeasFields-v5.proto +++ /dev/null @@ -1,54 +0,0 @@ -/* - * ============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 - -message HVRanMeasFields { - message HVRanMeasPayload { - message PMObject { - message HVRanMeas { - uint32 measurement_id = 1; - repeated uint32 counter_subid = 2; - repeated sint64 counter_value = 3; - repeated uint32 missing_counter_subid = 4; - bool suspectFlagIncomplete = 5; // (some is data missing due to internal error) - bool suspectFlagOutOfSync = 6; // (source time not aligned) - } - - string uri = 1; // monitored object URI - repeated HVRanMeas hvRanMeas = 2; // performance counters grouped by measurement types - } - repeated PMObject pmObject = 1; - } - - message AdditionalField { - string name = 1; - string value = 2; - } - - string hvRanMeasFieldsVersion = 1; // version of HVRanMeasFields message - uint32 period_ms = 2; // period configured for reporting the data in milliseconds - string timezone = 3; // timezone of Network Function sending the data - string pmDictionaryVsn = 4; // vendor name + schema version E.g. NOKIA_LN7.0, uniquely identify the relevant PM dictionary - HVRanMeasPayload hvRanMeasPayload = 5; // objects being monitored - repeated AdditionalField additionalFields = 6; // array of name-value pairs if needed -} \ No newline at end of file diff --git a/protobuf/src/main/proto/VesEvent-v5.proto b/protobuf/src/main/proto/VesEvent-v5.proto deleted file mode 100644 index 022cce4e..00000000 --- a/protobuf/src/main/proto/VesEvent-v5.proto +++ /dev/null @@ -1,86 +0,0 @@ -/* - * ============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 { - - // VES CommonEventHeader adapted to GPB (Google Protocol Buffers) - // Source: https://git.opnfv.org/ves/tree/tests/docs/ves_data_model.json - // 2017-05-13 Align with VES 5.0 schema. - // blob: ca948ff67e8a2de4e2a47cffc4d4d2893170ab76 - - message CommonEventHeader { - string version = 1; // required, "version of the event header" - enum Domain { - FAULT = 0; - HEARTBEAT = 1; - MEASUREMENTS_FOR_VF_SCALING = 2; - MOBILE_FLOW = 3; - SIP_SIGNALING = 4; - STATE_CHANGE = 5; - SYSLOG = 6; - THRESHOLD_CROSSING_ALERT = 7; - VOICE_QUALITY = 8; - OTHER = 9; - HVRANMEAS = 10; - } - Domain domain = 2; // required, "the eventing domain associated with the event" [map to string] - - uint32 sequence = 3; // required, "ordering of events communicated by an event source instance or 0 if not needed" - - enum Priority { - HIGH = 0; - MEDIUM = 1; - NORMAL = 2; - LOW = 3; - } - 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 - applicationVnf, guestOS, hostOS, 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 reportingEntityId = 12; // "UUID identifying the entity reporting the event, for example an OAM VM; must be populated by the ATT enrichment process" - bytes reportingEntityName = 13; // required, "name of the entity reporting the event, for example, an EMS name; may be the same as sourceName" - bytes sourceId = 14; // "UUID identifying the entity experiencing the event issue; must be populated by the ATT enrichment process" - string sourceName = 15; // required, "name of the entity experiencing the event issue" - - reserved "InternalHeaderFields"; // "enrichment fields for internal VES Event Listener service use only, not supplied by event sources" - reserved 100; - } - - CommonEventHeader commonEventHeader = 1; - - oneof eventFields // required, payload, each high-volume domain has its specific GPB schema - { - bytes hvRanMeasFields = 2; // if domain==HVRANMEAS, GPB schema: HVRanMeasFields.proto - } -} - -message VesEventList { - repeated VesEvent vesEvent = 1; -} -- cgit 1.2.3-korg