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;
32 import java.util.ArrayList;
33 import java.util.HashMap;
34 import java.util.List;
36 import java.util.Properties;
38 public class SdcConfig implements IConfiguration {
41 private String consumer;
42 private String consumerId;
44 private String keystorePath;
45 private String keystorePass;
46 /** Polling internal is time between listening sessions */
47 private int pollingInterval;
48 /** Polling timeout is the time to listen for (dmaap timeout url param)/1000 */
49 private int pollingTimeout;
50 private List<String> types = new ArrayList<>();
56 private Properties props;
58 private final EELFLogger logger = EELFManager.getInstance().getLogger(SdcConfig.class);
60 SdcConfig(Properties props) throws Exception {
65 private void init() throws Exception {
67 logger.error("SdcConfig init is skipped due to properties is null");
71 // Keystore for ca cert
72 keystorePath = props.getProperty("appc.sdc.keystore.path");
73 keystorePass = props.getProperty("appc.sdc.keystore.pass");
76 host = props.getProperty("appc.sdc.host");
77 env = props.getProperty("appc.sdc.env");
78 user = props.getProperty("appc.sdc.user");
79 pass = props.getProperty("appc.sdc.pass");
82 consumer = props.getProperty("appc.sdc.consumer");
83 consumerId = props.getProperty("appc.sdc.consumer.id");
85 pollingInterval = Integer.valueOf(props.getProperty("interval", "60"));
87 // Client uses cambriaClient-0.2.4 which throws non relevant (wrong)
88 // exceptions with times > 30s
89 pollingTimeout = Integer.valueOf(props.getProperty("timeout", "25"));
91 // Anything less than 60 and we risk 429 Too Many Requests
92 if (pollingInterval < 60) {
96 if (pollingInterval > pollingTimeout) {
97 logger.warn(String.format(
98 "Message acknowledgement may be delayed by %ds in the ADSC listener. [Listening Time: %s, Poll Period: %s]",
99 pollingInterval - pollingTimeout, pollingTimeout, pollingInterval));
106 This types seems redundant, as it looks from the code that they are not being used anywhere
108 types.add("APPC_CONFIG");
109 types.add("VF_LICENSE");
110 types.add("TOSCA_CSAR");
112 storeOp = new URI(props.getProperty("appc.sdc.provider.url"));
116 public boolean activateServerTLSAuth() {
120 public boolean isFilterInEmptyResources() {
125 public String getAsdcAddress() {
130 public String getConsumerGroup() {
135 public String getConsumerID() {
140 public String getEnvironmentName() {
145 public String getKeyStorePassword() {
150 public String getKeyStorePath() {
155 public String getPassword() {
160 public int getPollingInterval() {
161 return pollingInterval;
165 public int getPollingTimeout() {
166 return pollingTimeout;
170 public List<String> getRelevantArtifactTypes() {
175 public String getUser() {
180 public Boolean isUseHttpsWithDmaap(){
184 URI getStoreOpURI() {
189 * Logs the relevant parameters
191 private void logParams() {
192 Map<String, String> params = new HashMap<>();
193 params.put("SDC Host", getAsdcAddress());
194 params.put("SDC Environment", getEnvironmentName());
195 params.put("Consumer Name", getConsumerGroup());
196 params.put("Consumer ID", getConsumerID());
197 params.put("Poll Active Wait", String.valueOf(getPollingInterval()));
198 params.put("Poll Timeout", String.valueOf(getPollingTimeout()));
200 logger.info(String.format("SDC Params: %s", params));