diff options
Diffstat (limited to 'hv-collector-core')
5 files changed, 8 insertions, 8 deletions
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 1bde6a12..b52f959f 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 @@ -25,7 +25,6 @@ import org.onap.dcae.collectors.veshv.boundary.ConfigurationProvider import org.onap.dcae.collectors.veshv.boundary.Metrics import org.onap.dcae.collectors.veshv.boundary.SinkProvider import org.onap.dcae.collectors.veshv.domain.WireFrameDecoder -import org.onap.dcae.collectors.veshv.impl.MessageValidator import org.onap.dcae.collectors.veshv.impl.Router import org.onap.dcae.collectors.veshv.impl.VesDecoder import org.onap.dcae.collectors.veshv.impl.VesHvCollector @@ -57,7 +56,6 @@ class CollectorFactory(val configuration: ConfigurationProvider, return VesHvCollector( wireChunkDecoderSupplier = { alloc -> WireChunkDecoder(WireFrameDecoder(), alloc) }, protobufDecoder = VesDecoder(), - messageValidator = MessageValidator(), router = Router(config.routing), sink = sinkProvider(config), metrics = metrics) 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 3f355e34..8d10a407 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 @@ -22,7 +22,7 @@ package org.onap.dcae.collectors.veshv.impl import org.onap.dcae.collectors.veshv.model.VesMessage import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader -internal class MessageValidator { +internal object MessageValidator { val requiredFieldDescriptors = listOf( "version", @@ -35,7 +35,7 @@ internal class MessageValidator { "startEpochMicrosec", "lastEpochMicrosec", "sequence") - .map { fieldName -> CommonEventHeader.getDescriptor().findFieldByName(fieldName)} + .map { fieldName -> CommonEventHeader.getDescriptor().findFieldByName(fieldName) } fun isValid(message: VesMessage): Boolean { return allMandatoryFieldsArePresent(message.header) 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 511ccf30..2a07b9b8 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 @@ -45,7 +45,6 @@ import java.util.function.BiConsumer internal class VesHvCollector( private val wireChunkDecoderSupplier: (ByteBufAllocator) -> WireChunkDecoder, private val protobufDecoder: VesDecoder, - private val messageValidator: MessageValidator, private val router: Router, private val sink: Sink, private val metrics: Metrics) : Collector { @@ -56,7 +55,7 @@ internal class VesHvCollector( .transform { decodeWireFrame(it, wireDecoder) } .filter(PayloadWireFrameMessage::isValid) .transform(::decodePayload) - .filter(messageValidator::isValid) + .filter(VesMessage::isValid) .transform(::routeMessage) .doOnTerminate { releaseBuffersMemory(wireDecoder) } .onErrorResume(::handleErrors) 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 index 03c53e10..03996fd5 100644 --- 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 @@ -20,10 +20,13 @@ package org.onap.dcae.collectors.veshv.model import org.onap.dcae.collectors.veshv.domain.ByteData +import org.onap.dcae.collectors.veshv.impl.MessageValidator import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader /** * @author Piotr Jaszczyk <piotr.jaszczyk@nokia.com> * @since May 2018 */ -data class VesMessage(val header: CommonEventHeader, val rawMessage: ByteData) +data class VesMessage(val header: CommonEventHeader, val rawMessage: ByteData) { + fun isValid(): Boolean = MessageValidator.isValid(this) +} 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 4d1b879a..a2a26b31 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 @@ -46,7 +46,7 @@ internal object MessageValidatorTest : Spek({ } given("Message validator") { - val cut = MessageValidator() + val cut = MessageValidator on("ves hv message including header with fully initialized fields") { val commonHeader = newBuilder() |