2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.openecomp.appc.sdc.listener;
24 import com.att.eelf.configuration.EELFLogger;
25 import com.att.eelf.configuration.EELFManager;
26 import org.openecomp.sdc.api.consumer.IConfiguration;
31 public class AsdcConfig implements IConfiguration {
34 private String consumer;
35 private String consumerId;
37 private String keystorePath;
38 private String keystorePass;
39 private int pollingInterval; // Time between listening sessions
40 private int pollingTimeout; // Time to listen for (dmaap timeout url param)/1000
41 private List<String> types = new ArrayList<>(1);
49 private final EELFLogger logger = EELFManager.getInstance().getLogger(AsdcConfig.class);
51 public AsdcConfig(Properties props) throws Exception {
56 private void init() throws Exception {
58 // Keystore for ca cert
59 keystorePath = props.getProperty("appc.asdc.keystore.path");
60 keystorePass = props.getProperty("appc.asdc.keystore.pass");
63 host = props.getProperty("appc.asdc.host");
64 env = props.getProperty("appc.asdc.env");
65 user = props.getProperty("appc.asdc.user");
66 pass = props.getProperty("appc.asdc.pass");
69 consumer = props.getProperty("appc.asdc.consumer");
70 consumerId = props.getProperty("appc.asdc.consumer.id");
72 pollingInterval = Integer.valueOf(props.getProperty("interval", "60"));
74 // Client uses cambriaClient-0.2.4 which throws non relevant (wrong)
75 // exceptions with times > 30s
76 pollingTimeout = Integer.valueOf(props.getProperty("timeout", "25"));
78 // Anything less than 60 and we risk 429 Too Many Requests
79 if (pollingInterval < 60) {
83 if (pollingInterval > pollingInterval) {
84 logger.warn(String.format(
85 "Message acknowledgement may be delayed by %ds in the ADSC listener. [Listening Time: %s, Poll Period: %s]",
86 pollingInterval - pollingTimeout, pollingTimeout, pollingInterval));
92 types.add("APPC_CONFIG");
93 types.add("VF_LICENSE");
95 storeOp = new URI(props.getProperty("appc.asdc.provider.url"));
100 public boolean activateServerTLSAuth() {
105 public boolean isFilterInEmptyResources() {
110 public String getAsdcAddress() {
115 public String getConsumerGroup() {
120 public String getConsumerID() {
125 public String getEnvironmentName() {
130 public String getKeyStorePassword() {
135 public String getKeyStorePath() {
140 public String getPassword() {
145 public int getPollingInterval() {
146 return pollingInterval;
150 public int getPollingTimeout() {
151 return pollingTimeout;
155 public List<String> getRelevantArtifactTypes() {
160 public String getUser() {
164 public URI getStoreOpURI() {
169 * Logs the relevant parameters
171 public void logParams() {
172 Map<String, String> params = new HashMap<String, String>();
173 params.put("ASDC Host", getAsdcAddress());
174 params.put("ASDC Environment", getEnvironmentName());
175 params.put("Consumer Name", getConsumerGroup());
176 params.put("Consumer ID", getConsumerID());
177 params.put("Poll Active Wait", String.valueOf(getPollingInterval()));
178 params.put("Poll Timeout", String.valueOf(getPollingTimeout()));
180 logger.info(String.format("ASDC Params: %s", params));