2 * ============LICENSE_START=======================================================
3 * dcaegen2-collectors-veshv
4 * ================================================================================
5 * Copyright (C) 2018 NOKIA
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.dcae.collectors.veshv.main
22 import org.onap.dcae.collectors.veshv.boundary.ConfigurationProvider
23 import org.onap.dcae.collectors.veshv.model.CollectorConfiguration
24 import org.onap.dcae.collectors.veshv.model.ServerConfiguration
25 import org.onap.dcae.collectors.veshv.model.routing
26 import org.onap.dcae.collectors.veshv.factory.CollectorFactory
27 import org.onap.dcae.collectors.veshv.factory.ServerFactory
28 import org.onap.dcae.collectors.veshv.impl.adapters.AdapterFactory
29 import org.onap.dcae.collectors.veshv.main.ArgBasedServerConfiguration.WrongArgumentException
30 import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader.Domain
31 import org.slf4j.LoggerFactory
32 import kotlin.system.exitProcess
34 private val logger = LoggerFactory.getLogger("main")
36 fun main(args: Array<String>) {
38 val serverConfiguration = ArgBasedServerConfiguration().parse(args)
40 val collectorProvider = CollectorFactory(
41 resolveConfigurationProvider(serverConfiguration),
42 AdapterFactory.loggingSink()
43 ).createVesHvCollectorProvider()
44 ServerFactory.createNettyTcpServer(serverConfiguration, collectorProvider).start().block()
45 } catch (ex: WrongArgumentException) {
47 ex.printHelp("java org.onap.dcae.collectors.veshv.main.MainKt")
53 private fun resolveConfigurationProvider(serverConfiguration: ServerConfiguration): ConfigurationProvider {
55 if (serverConfiguration.configurationUrl.isEmpty()) {
56 logger.info("Configuration url not specified - using default config")
57 val sampleConfig = CollectorConfiguration(
58 kafkaBootstrapServers = "dmaap.cluster.local:9969",
61 fromDomain(Domain.HVRANMEAS)
62 toTopic("ves_hvRanMeas")
63 withFixedPartitioning()
67 return AdapterFactory.staticConfigurationProvider(sampleConfig)
70 logger.info("Using configuration url: ${serverConfiguration.configurationUrl}")
71 return AdapterFactory.consulConfigurationProvider(serverConfiguration.configurationUrl)