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 config;
|
| 17 |
|
| 18 | import java.util.Properties;
|
| 19 | import java.io.FileInputStream;
|
| 20 |
|
| 21 | import org.slf4j.Logger;
|
| 22 | import org.slf4j.LoggerFactory;
|
| 23 |
|
| 24 | public class Config {
|
| 25 |
|
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 26 | private static Properties properties;
|
William Kurkian | bde6fc9 | 2018-07-13 17:19:58 -0400 | [diff] [blame] | 27 |
|
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 28 | private final static Logger logger = LoggerFactory.getLogger("VolthaKafkaConsumer");
|
William Kurkian | bde6fc9 | 2018-07-13 17:19:58 -0400 | [diff] [blame] | 29 |
|
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 30 | public static void loadProperties(String file) {
|
| 31 | // create application properties with default
|
| 32 | try {
|
| 33 | properties = new Properties();
|
William Kurkian | bde6fc9 | 2018-07-13 17:19:58 -0400 | [diff] [blame] | 34 |
|
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 35 | // now load properties
|
| 36 | // from last invocation
|
| 37 | FileInputStream in = new FileInputStream(file);
|
| 38 | properties.load(in);
|
| 39 | in.close();
|
| 40 | } catch (Exception e) {
|
| 41 | logger.error(e.getMessage());
|
| 42 | }
|
William Kurkian | bde6fc9 | 2018-07-13 17:19:58 -0400 | [diff] [blame] | 43 | }
|
William Kurkian | bde6fc9 | 2018-07-13 17:19:58 -0400 | [diff] [blame] | 44 |
|
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 45 | public static String get(String key) {
|
| 46 | return (String)properties.get(key);
|
| 47 | }
|
William Kurkian | bde6fc9 | 2018-07-13 17:19:58 -0400 | [diff] [blame] | 48 |
|
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 49 | public static String getVesAddress() {
|
| 50 | return get("onap_ves_address");
|
| 51 | }
|
William Kurkian | bde6fc9 | 2018-07-13 17:19:58 -0400 | [diff] [blame] | 52 |
|
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 53 | public static String getVesPort() {
|
| 54 | return get("onap_ves_port");
|
| 55 | }
|
William Kurkian | bde6fc9 | 2018-07-13 17:19:58 -0400 | [diff] [blame] | 56 |
|
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 57 | public static String getKafkaAddress() {
|
| 58 | return get("kafka_address");
|
| 59 | }
|
William Kurkian | bde6fc9 | 2018-07-13 17:19:58 -0400 | [diff] [blame] | 60 |
|
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 61 | public static String getKafkaPort() {
|
| 62 | return get("kafka_port");
|
William Kurkian | 18ec344 | 2018-09-10 16:27:37 -0400 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | public static String getKafkaAlarmsTopic() {
|
| 66 | return get("kafka_alarms_topic");
|
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 67 | }
|
William Kurkian | bde6fc9 | 2018-07-13 17:19:58 -0400 | [diff] [blame] | 68 |
|
William Kurkian | 18ec344 | 2018-09-10 16:27:37 -0400 | [diff] [blame] | 69 | public static String getKafkaKpisTopic() {
|
| 70 | return get("kafka_kpis_topic");
|
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 71 | }
|
William Kurkian | 7180b94 | 2018-08-15 15:26:17 -0400 | [diff] [blame] | 72 |
|
| 73 | public static String getCoId() {
|
| 74 | return get("co_id");
|
| 75 | }
|
| 76 |
|
| 77 | public static String getPodId() {
|
| 78 | return get("pod_id");
|
| 79 | }
|
William Kurkian | 18ec344 | 2018-09-10 16:27:37 -0400 | [diff] [blame] | 80 | } |