William Kurkian | bde6fc9 | 2018-07-13 17:19:58 -0400 | [diff] [blame] | 1 | /* |
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 2 | * Copyright 2018- Cisco |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
William Kurkian | bde6fc9 | 2018-07-13 17:19:58 -0400 | [diff] [blame] | 16 | package controller; |
| 17 | |
| 18 | import org.springframework.boot.SpringApplication; |
| 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 20 | import org.springframework.web.bind.annotation.RequestMapping; |
| 21 | import org.springframework.web.bind.annotation.RestController; |
| 22 | import kafka.VolthaKafkaConsumer; |
| 23 | |
| 24 | import org.slf4j.Logger; |
| 25 | import org.slf4j.LoggerFactory; |
| 26 | |
| 27 | import java.lang.InterruptedException; |
| 28 | |
| 29 | import config.Config; |
| 30 | |
| 31 | |
| 32 | @SpringBootApplication |
| 33 | @RestController |
| 34 | public class Application { |
| 35 | |
| 36 | @RequestMapping("/") |
| 37 | public String home() { |
| 38 | return "Hello Docker World"; |
| 39 | } |
| 40 | |
| 41 | public static void main(String[] args) { |
| 42 | Config.loadProperties("/opt/ves-agent/config.properties"); |
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 43 | KafkaThread kafka = new KafkaThread(); |
William Kurkian | bde6fc9 | 2018-07-13 17:19:58 -0400 | [diff] [blame] | 44 | kafka.start(); |
| 45 | SpringApplication.run(Application.class, args); |
| 46 | } |
| 47 | |
| 48 | } |
| 49 | class KafkaThread extends Thread { |
| 50 | |
| 51 | private final static Logger logger = LoggerFactory.getLogger("KafkaThread"); |
| 52 | |
| 53 | public void run() { |
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 54 | logger.debug("Start Kafka Consumer Thread"); |
| 55 | try { |
| 56 | VolthaKafkaConsumer consumer = new VolthaKafkaConsumer(); |
| 57 | consumer.runConsumer(); |
| 58 | } catch (InterruptedException e) { |
| 59 | logger.error(e.getMessage()); |
| 60 | } |
William Kurkian | bde6fc9 | 2018-07-13 17:19:58 -0400 | [diff] [blame] | 61 | |
| 62 | } |
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 63 | } |