2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.openecomp.appc.sdc.listener;
27 import com.att.eelf.configuration.EELFLogger;
28 import com.att.eelf.configuration.EELFManager;
29 import org.openecomp.sdc.api.consumer.IConfiguration;
34 public class AsdcConfig implements IConfiguration {
37 private String consumer;
38 private String consumerId;
40 private String keystorePath;
41 private String keystorePass;
42 private int pollingInterval; // Time between listening sessions
43 private int pollingTimeout; // Time to listen for (dmaap timeout url param)/1000
44 private List<String> types = new ArrayList<>(1);
52 private final EELFLogger logger = EELFManager.getInstance().getLogger(AsdcConfig.class);
54 public AsdcConfig(Properties props) throws Exception {
59 private void init() throws Exception {
61 // Keystore for ca cert
62 keystorePath = props.getProperty("appc.asdc.keystore.path");
63 keystorePass = props.getProperty("appc.asdc.keystore.pass");
66 host = props.getProperty("appc.asdc.host");
67 env = props.getProperty("appc.asdc.env");
68 user = props.getProperty("appc.asdc.user");
69 pass = props.getProperty("appc.asdc.pass");
72 consumer = props.getProperty("appc.asdc.consumer");
73 consumerId = props.getProperty("appc.asdc.consumer.id");
75 pollingInterval = Integer.valueOf(props.getProperty("interval", "60"));
77 // Client uses cambriaClient-0.2.4 which throws non relevant (wrong)
78 // exceptions with times > 30s
79 pollingTimeout = Integer.valueOf(props.getProperty("timeout", "25"));
81 // Anything less than 60 and we risk 429 Too Many Requests
82 if (pollingInterval < 60) {
86 if (pollingInterval > pollingInterval) {
87 logger.warn(String.format(
88 "Message acknowledgement may be delayed by %ds in the ADSC listener. [Listening Time: %s, Poll Period: %s]",
89 pollingInterval - pollingTimeout, pollingTimeout, pollingInterval));
95 types.add("APPC_CONFIG");
96 types.add("VF_LICENSE");
98 storeOp = new URI(props.getProperty("appc.asdc.provider.url"));
103 public boolean activateServerTLSAuth() {
108 public boolean isFilterInEmptyResources() {
113 public String getAsdcAddress() {
118 public String getConsumerGroup() {
123 public String getConsumerID() {
128 public String getEnvironmentName() {
133 public String getKeyStorePassword() {
138 public String getKeyStorePath() {
143 public String getPassword() {
148 public int getPollingInterval() {
149 return pollingInterval;
153 public int getPollingTimeout() {
154 return pollingTimeout;
158 public List<String> getRelevantArtifactTypes() {
163 public String getUser() {
167 public URI getStoreOpURI() {
172 * Logs the relevant parameters
174 public void logParams() {
175 Map<String, String> params = new HashMap<String, String>();
176 params.put("ASDC Host", getAsdcAddress());
177 params.put("ASDC Environment", getEnvironmentName());
178 params.put("Consumer Name", getConsumerGroup());
179 params.put("Consumer ID", getConsumerID());
180 params.put("Poll Active Wait", String.valueOf(getPollingInterval()));
181 params.put("Poll Timeout", String.valueOf(getPollingTimeout()));
183 logger.info(String.format("ASDC Params: %s", params));