Added Redis Support
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-tca / src / main / java / org / onap / dcae / apod / analytics / cdap / tca / settings / TCAAppPreferences.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
4  * ================================================================================
5  *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.
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
10  *
11  *          http://www.apache.org/licenses/LICENSE-2.0
12  *
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===========================================
19  */
20
21 package org.onap.dcae.apod.analytics.cdap.tca.settings;
22
23 import com.google.common.base.Objects;
24 import org.onap.dcae.apod.analytics.cdap.common.settings.CDAPAppPreferences;
25 import org.onap.dcae.apod.analytics.common.AnalyticsConstants;
26
27 /**
28  * <p>
29  *     App Preferences for Analytics TCA (Threshold Crossing Alert) App
30  * <p>
31  * @author Rajiv Singla . Creation Date: 10/4/2016.
32  */
33 public class TCAAppPreferences implements CDAPAppPreferences {
34
35     private static final long serialVersionUID = 1L;
36
37     // subscriber preferences
38     protected String subscriberHostName;
39
40     protected Integer subscriberHostPort;
41
42     protected String subscriberTopicName;
43
44     protected String subscriberProtocol;
45
46     protected String subscriberUserName;
47
48     protected String subscriberUserPassword;
49
50     protected String subscriberContentType;
51
52     protected String subscriberConsumerId;
53
54     protected String subscriberConsumerGroup;
55
56     protected Integer subscriberTimeoutMS;
57
58     protected Integer subscriberMessageLimit;
59
60     protected Integer subscriberPollingInterval;
61
62     // publisher preferences
63     protected String publisherHostName;
64
65     protected Integer publisherHostPort;
66
67     protected String publisherTopicName;
68
69     protected String publisherProtocol;
70
71     protected String publisherUserName;
72
73     protected String publisherUserPassword;
74
75     protected String publisherContentType;
76
77     protected Integer publisherMaxBatchSize;
78
79     protected Integer publisherMaxRecoveryQueueSize;
80
81     protected Integer publisherPollingInterval;
82
83     protected Boolean enableAlertCEFFormat;
84
85
86     // A&AI Enrichment
87
88     protected Boolean enableAAIEnrichment;
89
90     protected String aaiEnrichmentHost;
91
92     protected Integer aaiEnrichmentPortNumber;
93
94     protected String aaiEnrichmentProtocol;
95
96     protected String aaiEnrichmentUserName;
97
98     protected String aaiEnrichmentUserPassword;
99
100     protected Boolean aaiEnrichmentIgnoreSSLCertificateErrors;
101
102     protected String aaiVNFEnrichmentAPIPath;
103
104     protected String aaiVMEnrichmentAPIPath;
105
106
107     // A&AI Enrichment Proxy
108
109     protected String aaiEnrichmentProxyURL;
110
111
112     // Redis Distributed caching
113     protected Boolean enableRedisCaching;
114
115     protected String redisHosts;
116
117     /**
118      * Default constructor to setup default values for TCA App Preferences
119      */
120     public TCAAppPreferences() {
121
122         // subscriber defaults
123         subscriberPollingInterval = AnalyticsConstants.TCA_DEFAULT_SUBSCRIBER_POLLING_INTERVAL_MS;
124
125         // publisher defaults
126         publisherMaxBatchSize = AnalyticsConstants.TCA_DEFAULT_PUBLISHER_MAX_BATCH_QUEUE_SIZE;
127         publisherMaxRecoveryQueueSize = AnalyticsConstants.TCA_DEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE;
128         publisherPollingInterval = AnalyticsConstants.TCA_DEFAULT_PUBLISHER_POLLING_INTERVAL_MS;
129
130         enableAlertCEFFormat = AnalyticsConstants.TCA_DEFAULT_ENABLE_CEF_FORMATTED_ALERT;
131
132         // aai
133         enableAAIEnrichment = AnalyticsConstants.TCA_DEFAULT_ENABLE_AAI_ENRICHMENT;
134         aaiEnrichmentIgnoreSSLCertificateErrors =
135                 AnalyticsConstants.TCA_DEFAULT_AAI_ENRICHMENT_IGNORE_SSL_CERTIFICATE_ERRORS;
136         aaiEnrichmentProxyURL = AnalyticsConstants.TCA_DEFAULT_AAI_ENRICHMENT_PROXY_URL;
137
138         // redis
139         enableRedisCaching = AnalyticsConstants.TCA_DEFAULT_ENABLE_REDIS_CACHING;
140
141     }
142
143     public String getSubscriberHostName() {
144         return subscriberHostName;
145     }
146
147     public Integer getSubscriberHostPort() {
148         return subscriberHostPort;
149     }
150
151     public String getSubscriberTopicName() {
152         return subscriberTopicName;
153     }
154
155     public String getSubscriberProtocol() {
156         return subscriberProtocol;
157     }
158
159     public String getSubscriberUserName() {
160         return subscriberUserName;
161     }
162
163     public String getSubscriberUserPassword() {
164         return subscriberUserPassword;
165     }
166
167     public String getSubscriberContentType() {
168         return subscriberContentType;
169     }
170
171     public String getSubscriberConsumerId() {
172         return subscriberConsumerId;
173     }
174
175     public String getSubscriberConsumerGroup() {
176         return subscriberConsumerGroup;
177     }
178
179     public Integer getSubscriberTimeoutMS() {
180         return subscriberTimeoutMS;
181     }
182
183     public Integer getSubscriberMessageLimit() {
184         return subscriberMessageLimit;
185     }
186
187     public Integer getSubscriberPollingInterval() {
188         return subscriberPollingInterval;
189     }
190
191     public String getPublisherHostName() {
192         return publisherHostName;
193     }
194
195     public Integer getPublisherHostPort() {
196         return publisherHostPort;
197     }
198
199     public String getPublisherTopicName() {
200         return publisherTopicName;
201     }
202
203     public String getPublisherProtocol() {
204         return publisherProtocol;
205     }
206
207     public String getPublisherUserName() {
208         return publisherUserName;
209     }
210
211     public String getPublisherUserPassword() {
212         return publisherUserPassword;
213     }
214
215     public String getPublisherContentType() {
216         return publisherContentType;
217     }
218
219     public Integer getPublisherMaxBatchSize() {
220         return publisherMaxBatchSize;
221     }
222
223     public Integer getPublisherMaxRecoveryQueueSize() {
224         return publisherMaxRecoveryQueueSize;
225     }
226
227     public Integer getPublisherPollingInterval() {
228         return publisherPollingInterval;
229     }
230
231     public Boolean getEnableAlertCEFFormat() {
232         return enableAlertCEFFormat;
233     }
234
235
236     public void setSubscriberHostName(String subscriberHostName) {
237         this.subscriberHostName = subscriberHostName;
238     }
239
240     public void setSubscriberHostPort(Integer subscriberHostPort) {
241         this.subscriberHostPort = subscriberHostPort;
242     }
243
244     public void setSubscriberTopicName(String subscriberTopicName) {
245         this.subscriberTopicName = subscriberTopicName;
246     }
247
248     public void setSubscriberProtocol(String subscriberProtocol) {
249         this.subscriberProtocol = subscriberProtocol;
250     }
251
252     public void setSubscriberUserName(String subscriberUserName) {
253         this.subscriberUserName = subscriberUserName;
254     }
255
256     public void setSubscriberUserPassword(String subscriberUserPassword) {
257         this.subscriberUserPassword = subscriberUserPassword;
258     }
259
260     public void setPublisherHostName(String publisherHostName) {
261         this.publisherHostName = publisherHostName;
262     }
263
264     public void setPublisherHostPort(Integer publisherHostPort) {
265         this.publisherHostPort = publisherHostPort;
266     }
267
268     public void setPublisherTopicName(String publisherTopicName) {
269         this.publisherTopicName = publisherTopicName;
270     }
271
272     public void setPublisherProtocol(String publisherProtocol) {
273         this.publisherProtocol = publisherProtocol;
274     }
275
276     public void setPublisherUserName(String publisherUserName) {
277         this.publisherUserName = publisherUserName;
278     }
279
280     public void setPublisherUserPassword(String publisherUserPassword) {
281         this.publisherUserPassword = publisherUserPassword;
282     }
283
284     public Boolean getEnableAAIEnrichment() {
285         return enableAAIEnrichment;
286     }
287
288     public String getAaiEnrichmentHost() {
289         return aaiEnrichmentHost;
290     }
291
292     public Integer getAaiEnrichmentPortNumber() {
293         return aaiEnrichmentPortNumber;
294     }
295
296     public String getAaiEnrichmentProtocol() {
297         return aaiEnrichmentProtocol;
298     }
299
300     public String getAaiEnrichmentUserName() {
301         return aaiEnrichmentUserName;
302     }
303
304     public String getAaiEnrichmentUserPassword() {
305         return aaiEnrichmentUserPassword;
306     }
307
308     public Boolean getAaiEnrichmentIgnoreSSLCertificateErrors() {
309         return aaiEnrichmentIgnoreSSLCertificateErrors;
310     }
311
312     public String getAaiVNFEnrichmentAPIPath() {
313         return aaiVNFEnrichmentAPIPath;
314     }
315
316     public String getAaiVMEnrichmentAPIPath() {
317         return aaiVMEnrichmentAPIPath;
318     }
319
320     public String getAaiEnrichmentProxyURL() {
321         return aaiEnrichmentProxyURL;
322     }
323
324     public Boolean getEnableRedisCaching() {
325         return enableRedisCaching;
326     }
327
328     public String getRedisHosts() {
329         return redisHosts;
330     }
331
332     @Override
333     public String toString() {
334         return Objects.toStringHelper(this)
335                 .add("subscriberHostName", subscriberHostName)
336                 .add("subscriberHostPort", subscriberHostPort)
337                 .add("subscriberTopicName", subscriberTopicName)
338                 .add("subscriberProtocol", subscriberProtocol)
339                 .add("subscriberUserName", subscriberUserName)
340                 .add("subscriberContentType", subscriberContentType)
341                 .add("subscriberConsumerId", subscriberConsumerId)
342                 .add("subscriberConsumerGroup", subscriberConsumerGroup)
343                 .add("subscriberTimeoutMS", subscriberTimeoutMS)
344                 .add("subscriberMessageLimit", subscriberMessageLimit)
345                 .add("subscriberPollingInterval", subscriberPollingInterval)
346                 .add("publisherHostName", publisherHostName)
347                 .add("publisherHostPort", publisherHostPort)
348                 .add("publisherTopicName", publisherTopicName)
349                 .add("publisherProtocol", publisherProtocol)
350                 .add("publisherUserName", publisherUserName)
351                 .add("publisherContentType", publisherContentType)
352                 .add("publisherMaxBatchSize", publisherMaxBatchSize)
353                 .add("publisherMaxRecoveryQueueSize", publisherMaxRecoveryQueueSize)
354                 .add("publisherPollingInterval", publisherPollingInterval)
355                 .add("enableAlertCEFFormat", enableAlertCEFFormat)
356                 .add("enableAAIEnrichment", enableAAIEnrichment)
357                 .add("aaiEnrichmentHost", aaiEnrichmentHost)
358                 .add("aaiEnrichmentPortNumber", aaiEnrichmentPortNumber)
359                 .add("aaiEnrichmentProtocol", aaiEnrichmentProtocol)
360                 .add("aaiEnrichmentUserName", aaiEnrichmentUserName)
361                 .add("aaiEnrichmentIgnoreSSLCertificateErrors", aaiEnrichmentIgnoreSSLCertificateErrors)
362                 .add("aaiVNFEnrichmentAPIPath", aaiVNFEnrichmentAPIPath)
363                 .add("aaiVMEnrichmentAPIPath", aaiVMEnrichmentAPIPath)
364                 .add("aaiEnrichmentProxyEnabled", aaiEnrichmentProxyURL == null ? "false" : "true")
365                 .add("enableRedisCaching", enableRedisCaching)
366                 .add("redisHosts", redisHosts)
367                 .toString();
368     }
369 }