2 * ================================================================================
3 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ============LICENSE_END=========================================================
20 package org.onap.dcae.analytics.web.dmaap;
22 import lombok.EqualsAndHashCode;
24 import lombok.ToString;
27 import java.util.List;
29 import javax.annotation.Nonnull;
30 import javax.annotation.Nullable;
32 import org.onap.dcae.analytics.model.DmaapMrConstants;
33 import org.onap.dcae.analytics.web.http.BaseHttpClientPreferences;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
36 import org.springframework.http.HttpHeaders;
39 * DMaaP MR Subscriber config
41 * @author Rajiv Singla
44 @ToString(callSuper = true)
45 @EqualsAndHashCode(callSuper = true)
46 public class MrSubscriberPreferences extends BaseHttpClientPreferences {
48 private static final long serialVersionUID = 1L;
50 private static final Logger logger = LoggerFactory.getLogger(MrSubscriberPreferences.class);
52 private String consumerGroup;
53 private List<String> consumerIds;
54 private Integer messageLimit;
55 private Integer timeout;
56 private MrSubscriberPollingPreferences pollingPreferences;
58 public MrSubscriberPreferences(@Nonnull final String requestURL) {
62 public MrSubscriberPreferences(@Nonnull final String requestURL,
63 @Nullable final String httpClientId,
64 @Nullable final HttpHeaders httpHeaders,
65 @Nullable final String username,
66 @Nullable final String password,
67 @Nullable final URL proxyURL,
68 @Nullable final Boolean ignoreSSLValidation,
69 @Nullable final Boolean enableEcompAuditLogging,
70 @Nullable final String consumerGroup,
71 @Nullable final List<String> consumerIds,
72 @Nullable final Integer messageLimit,
73 @Nullable final Integer timeout,
74 @Nullable final MrSubscriberPollingPreferences pollingPreferences) {
75 super(requestURL, httpClientId, httpHeaders, username, password, proxyURL,
76 ignoreSSLValidation, enableEcompAuditLogging);
77 this.consumerGroup = consumerGroup;
78 this.consumerIds = consumerIds;
79 this.messageLimit = messageLimit;
80 this.timeout = timeout;
81 this.pollingPreferences = pollingPreferences;
85 public MrSubscriberPollingPreferences getPollingPreferences() {
86 if (pollingPreferences == null) {
87 logger.warn("DMaaP MR Subscriber Polling details are missing. " +
88 "Fixed polling rate will be used by default with polling interval: {}",
89 DmaapMrConstants.SUBSCRIBER_DEFAULT_FIXED_POLLING_INTERVAL);
90 setFixedPollingRate(DmaapMrConstants.SUBSCRIBER_DEFAULT_FIXED_POLLING_INTERVAL);
92 return pollingPreferences;
95 private void setFixedPollingRate(final int fixedPollingInterval) {
96 this.pollingPreferences =
97 new MrSubscriberPollingPreferences(fixedPollingInterval, 0, fixedPollingInterval, 0);