3b33944544b220bbac21cdcf4e811ebf0e1486ab
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt mountpoint-registrar
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * Copyright (C) 2021 Samsung Electronics Intellectual Property. All rights reserved.
7  * =================================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software distributed under the License
14  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
15  * or implied. See the License for the specific language governing permissions and limitations under
16  * the License.
17  * ============LICENSE_END==========================================================================
18  */
19
20
21 package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.config;
22
23 import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration;
24 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
25
26
27 public abstract class MessageConfig implements Configuration {
28     protected String sectionMarker;
29
30     public static final String PROPERTY_KEY_CONSUMER_TOPIC = "topic";
31
32     public static final String PROPERTY_KEY_CONSUMER_GROUP = "consumerGroup";
33     private static final String DEFAULT_VALUE_CONSUMER_GROUP = "myG";
34
35     public static final String PROPERTY_KEY_CONSUMER_ID = "consumerID";
36     private static final String DEFAULT_VALUE_CONSUMER_ID = "C1";
37
38     public static final String PROPERTY_KEY_CONSUMER_TIMEOUT = "timeout";
39     private static final String DEFAULT_VALUE_CONSUMER_TIMEOUT = "20000";
40
41     public static final String PROPERTY_KEY_CONSUMER_LIMIT = "limit";
42     private static final String DEFAULT_VALUE_CONSUMER_LIMIT = "10000";
43
44     public static final String PROPERTY_KEY_CONSUMER_FETCHPAUSE = "fetchPause";
45     private static final String DEFAULT_VALUE_CONSUMER_FETCHPAUSE = "5000";
46
47     protected ConfigurationFileRepresentation configuration;
48
49     public MessageConfig(ConfigurationFileRepresentation configuration) {
50         this.configuration = configuration;
51     }
52
53     @Override
54     public String getSectionName() {
55         return sectionMarker;
56     }
57
58     @Override
59     public void defaults() {
60         configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_GROUP,
61                 DEFAULT_VALUE_CONSUMER_GROUP);
62         configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_ID, DEFAULT_VALUE_CONSUMER_ID);
63         configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_TIMEOUT,
64                 DEFAULT_VALUE_CONSUMER_TIMEOUT);
65         configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_LIMIT,
66                 DEFAULT_VALUE_CONSUMER_LIMIT);
67         configuration.setPropertyIfNotAvailable(sectionMarker, PROPERTY_KEY_CONSUMER_FETCHPAUSE,
68                 DEFAULT_VALUE_CONSUMER_FETCHPAUSE);
69     }
70
71     public String getTopic() {
72         return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_TOPIC);
73     }
74
75     public String getConsumerGroup() {
76         return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_GROUP);
77     }
78
79     public String getConsumerId() {
80         return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_ID);
81     }
82
83     public String getTimeout() {
84         return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_TIMEOUT);
85     }
86
87     public String getLimit() {
88         return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_LIMIT);
89     }
90
91     public String getFetchPause() {
92         return configuration.getProperty(sectionMarker, PROPERTY_KEY_CONSUMER_FETCHPAUSE);
93     }
94
95 }