aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2020-01-29 17:38:07 +0000
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-02-18 16:06:10 +0000
commit4aa20bc42b7bd98dde15f7594084669eb92412c2 (patch)
tree65e9a29c54a600bb2f81bfd36cb15a606f88993a
parentb2b6accda7c04a5df5029dcf250b8138c231f38e (diff)
Configuration file runtime reload
Reloads the backend configuration file when the file listener catches a change. Forces validations errors when the configuration file could not be parsed. Remove not used configurations. Change-Id: Ic6fcb2b557d52ec53074c38ab8e0fcfa96e9be67 Issue-ID: SDC-2758 Signed-off-by: andre.schmid <andre.schmid@est.tech>
-rw-r--r--asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/configuration.yaml.erb2
-rw-r--r--asdctool/src/main/resources/config/configuration.yaml2
-rw-r--r--catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngine.java3
-rw-r--r--catalog-be/src/main/resources/config/configuration.yaml2
-rw-r--r--catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml2
-rw-r--r--catalog-be/src/test/resources/config/catalog-be/configuration.yaml2
-rw-r--r--catalog-fe/src/test/resources/config/catalog-fe/configuration.yaml7
-rw-r--r--catalog-model/src/test/resources/config/catalog-model/configuration.yaml2
-rw-r--r--catalog-model/src/test/resources/config/configuration.yaml5
-rw-r--r--catalog-ui/src/app/services/configuration-ui-service.ts2
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java31
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java8
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/ConfigurationSource.java4
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/FileChangeCallback.java3
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/exception/LoadConfigurationException.java27
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java100
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java19
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java158
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/YamlConversionException.java27
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/util/YamlToObjectConverterTest.java26
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/fe/config/WorkspaceConfigurationTest.java2
-rw-r--r--common-app-api/src/test/resources/config/fe/workspace-configuration.yaml (renamed from common-app-api/src/test/resources/config/common/workspace-configuration.yaml)0
-rw-r--r--docs/configuration.rst3
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/resources/configuration.yaml6
-rw-r--r--openecomp-be/tools/zusammen-tools/src/test/resources/configuration.yaml6
-rw-r--r--test-apis-ci/src/test/resources/config/test-apis-ci/configuration.yaml5
27 files changed, 190 insertions, 266 deletions
diff --git a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/configuration.yaml.erb b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/configuration.yaml.erb
index badcd6f1ea..5147881bde 100644
--- a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/configuration.yaml.erb
+++ b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/configuration.yaml.erb
@@ -589,8 +589,6 @@ resourceInformationalArtifacts:
- CVFC
- PNF
-resourceInformationalDeployedArtifacts:
-
unLoggedUrls:
- /sdc2/rest/healthCheck
diff --git a/asdctool/src/main/resources/config/configuration.yaml b/asdctool/src/main/resources/config/configuration.yaml
index 93bb2de2be..69f82ac72f 100644
--- a/asdctool/src/main/resources/config/configuration.yaml
+++ b/asdctool/src/main/resources/config/configuration.yaml
@@ -584,8 +584,6 @@ resourceInformationalArtifacts:
- VFC
- CVFC
-resourceInformationalDeployedArtifacts:
-
unLoggedUrls:
- /sdc2/rest/healthCheck
diff --git a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb
index 07f660b39e..1acae3261b 100644
--- a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb
+++ b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb
@@ -624,8 +624,6 @@ resourceInformationalArtifacts:
- CVFC
- PNF
-resourceInformationalDeployedArtifacts:
-
unLoggedUrls:
- /sdc2/rest/monitoring
- /sdc2/rest/healthCheck
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngine.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngine.java
index 3fd8579c2c..f4eb081b99 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngine.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngine.java
@@ -33,6 +33,7 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.common.util.YamlToObjectConverter;
+import org.openecomp.sdc.exception.YamlConversionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -76,7 +77,7 @@ public class DistributionEngine implements IDistributionEngine {
* The main method for testing only
* @param args
*/
- public static void main(String[] args) {
+ public static void main(String[] args) throws YamlConversionException {
List<String> servers = new ArrayList<>();
String server = "uebsb91kcdc.it.att.com:3904";
diff --git a/catalog-be/src/main/resources/config/configuration.yaml b/catalog-be/src/main/resources/config/configuration.yaml
index 3dca45840a..972f625662 100644
--- a/catalog-be/src/main/resources/config/configuration.yaml
+++ b/catalog-be/src/main/resources/config/configuration.yaml
@@ -614,8 +614,6 @@ resourceInformationalArtifacts:
- VFC
- CVFC
-resourceInformationalDeployedArtifacts:
-
unLoggedUrls:
- /sdc2/rest/healthCheck
diff --git a/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml
index 6cbad54ffc..0e68b3294b 100644
--- a/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml
+++ b/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml
@@ -508,8 +508,6 @@ resourceInformationalArtifacts:
- VFC
- CVFC
-resourceInformationalDeployedArtifacts:
-
unLoggedUrls:
- /sdc2/rest/healthCheck
diff --git a/catalog-be/src/test/resources/config/catalog-be/configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/configuration.yaml
index b982c384ef..9bd8849ce4 100644
--- a/catalog-be/src/test/resources/config/catalog-be/configuration.yaml
+++ b/catalog-be/src/test/resources/config/catalog-be/configuration.yaml
@@ -516,8 +516,6 @@ resourceInformationalArtifacts:
validForResourceTypes:
- PNF
-resourceInformationalDeployedArtifacts:
-
unLoggedUrls:
- /sdc2/rest/healthCheck
diff --git a/catalog-fe/src/test/resources/config/catalog-fe/configuration.yaml b/catalog-fe/src/test/resources/config/catalog-fe/configuration.yaml
index 5cc22fde72..0d9f1012e8 100644
--- a/catalog-fe/src/test/resources/config/catalog-fe/configuration.yaml
+++ b/catalog-fe/src/test/resources/config/catalog-fe/configuration.yaml
@@ -22,13 +22,6 @@ threadpoolSize: 50
# request processing timeout (seconds)
requestTimeout: 10
-# a4c hostname
-a4cHost: localhost
-
-# a4c http port
-a4cHttpPort: 8088
-
-
identificationHeaderFields:
-
- &HTTP_IV_USER HTTP_IV_USER
diff --git a/catalog-model/src/test/resources/config/catalog-model/configuration.yaml b/catalog-model/src/test/resources/config/catalog-model/configuration.yaml
index a1aaa3ab1f..052add6a28 100644
--- a/catalog-model/src/test/resources/config/catalog-model/configuration.yaml
+++ b/catalog-model/src/test/resources/config/catalog-model/configuration.yaml
@@ -523,8 +523,6 @@ resourceInformationalArtifacts:
- VFC
- CVFC
-resourceInformationalDeployedArtifacts:
-
unLoggedUrls:
- /sdc2/rest/healthCheck
diff --git a/catalog-model/src/test/resources/config/configuration.yaml b/catalog-model/src/test/resources/config/configuration.yaml
index 767fc424b0..adf065ca41 100644
--- a/catalog-model/src/test/resources/config/configuration.yaml
+++ b/catalog-model/src/test/resources/config/configuration.yaml
@@ -515,8 +515,6 @@ resourceInformationalArtifacts:
- VFC
- CVFC
-resourceInformationalDeployedArtifacts:
-
unLoggedUrls:
- /sdc2/rest/healthCheck
@@ -655,5 +653,4 @@ dmaapConsumerConfiguration:
password: hmXYcznAljMSisdy8zgcag==
dmeConfiguration:
- dme2Search: DME2SEARCH
- dme2Resolve: DME2RESOLVE
+ lookupUriFormat: "http://DME2RESOLVE/service=%s/version=1.0.0/envContext=%s/routeOffer=DEFAULT"
diff --git a/catalog-ui/src/app/services/configuration-ui-service.ts b/catalog-ui/src/app/services/configuration-ui-service.ts
index 766df7a722..463a974ccc 100644
--- a/catalog-ui/src/app/services/configuration-ui-service.ts
+++ b/catalog-ui/src/app/services/configuration-ui-service.ts
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-'use strict'
+'use strict';
import {IAppConfigurtaion, IApi} from "../models/app-config";
interface IConfigurationUiService {
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java
index 5d5afe0c98..711268e6a7 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java
@@ -95,7 +95,6 @@ public class Configuration extends BasicConfiguration {
private Map<String, ArtifactTypeConfig> serviceDeploymentArtifacts;
private Map<String, ArtifactTypeConfig> resourceInstanceDeploymentArtifacts;
private Map<String, ArtifactTypeConfig> resourceInformationalArtifacts;
- private Map<String, ArtifactTypeConfig> resourceInformationalDeployedArtifacts;
private Map<String, Object> serviceApiArtifacts;
private List<String> excludeServiceCategory;
@@ -144,29 +143,23 @@ public class Configuration extends BasicConfiguration {
private CadiFilterParams cadiFilterParams;
private Boolean aafAuthNeeded;
-
private String autoHealingOwner;
private boolean enableAutoHealing;
-
private Map<String, List<String>> resourcesForUpgrade;
private DmaapConsumerConfiguration dmaapConsumerConfiguration;
private DmaapProducerConfiguration dmaapProducerConfiguration;
-
private boolean skipUpgradeFailedVfs;
private boolean skipUpgradeVSPs;
private DmeConfiguration dmeConfiguration;
-
private boolean supportAllottedResourcesAndProxy;
private Integer deleteLockTimeoutInSeconds;
private Integer maxDeleteComponents;
private CookieConfig authCookie;
-
-
private String aafNamespace;
private String workloadContext;
-
private EnvironmentContext environmentContext;
-
+ private List<GabConfig> gabConfig;
+ private EcompPortalConfig ecompPortal;
public String getAutoHealingOwner() {
return autoHealingOwner;
@@ -207,7 +200,6 @@ public class Configuration extends BasicConfiguration {
public void setDmaapConsumerConfiguration(DmaapConsumerConfiguration dmaapConsumerConfiguration) {
this.dmaapConsumerConfiguration = dmaapConsumerConfiguration;
}
-
public DmeConfiguration getDmeConfiguration() {
return dmeConfiguration;
}
@@ -215,6 +207,7 @@ public class Configuration extends BasicConfiguration {
public void setDmeConfiguration(DmeConfiguration dmeConfiguration) {
this.dmeConfiguration = dmeConfiguration;
}
+
public void setSkipUpgradeVSPs(boolean skipUpgradeVSPs) { this.skipUpgradeVSPs = skipUpgradeVSPs; }
public boolean getSkipUpgradeVSPsFlag() { return skipUpgradeVSPs; }
@@ -251,8 +244,6 @@ public class Configuration extends BasicConfiguration {
this.artifactGeneratorConfig = artifactGeneratorConfig;
}
- private List<GabConfig> gabConfig;
-
public Map<String, String> getGenericAssetNodeTypes() {
return genericAssetNodeTypes;
}
@@ -285,8 +276,6 @@ public class Configuration extends BasicConfiguration {
this.applicationL2Cache = applicationL2Cache;
}
- private EcompPortalConfig ecompPortal;
-
public CassandrConfig getCassandraConfig() {
return cassandraConfig;
}
@@ -1212,6 +1201,8 @@ public class Configuration extends BasicConfiguration {
private Integer port;
private String healthCheckUri;
private String defaultFunctionalMenu;
+ private Integer pollingInterval;
+ private Integer timeoutMs;
public void setPollingInterval(Integer pollingInterval) {
this.pollingInterval = pollingInterval;
@@ -1221,9 +1212,6 @@ public class Configuration extends BasicConfiguration {
this.timeoutMs = timeoutMs;
}
- private Integer pollingInterval;
- private Integer timeoutMs;
-
public String getProtocol() {
return protocol;
}
@@ -1583,15 +1571,6 @@ public class Configuration extends BasicConfiguration {
this.artifactsIndex = artifactsIndex;
}
- public Map<String, ArtifactTypeConfig> getResourceInformationalDeployedArtifacts() {
- return resourceInformationalDeployedArtifacts;
- }
-
- public void setResourceInformationalDeployedArtifacts(
- Map<String, ArtifactTypeConfig> resourceInformationalDeployedArtifacts) {
- this.resourceInformationalDeployedArtifacts = resourceInformationalDeployedArtifacts;
- }
-
public List<String> getResourceTypes() {
return resourceTypes;
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java
index 0e9fd24111..101b60e941 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java
@@ -36,6 +36,7 @@ public class ConfigurationManager implements FileChangeCallback, IEcompConfigura
ConfigurationSource configurationSource = null;
private static ConfigurationManager instance;
+ final Map<String, Object> configurations = new HashMap<>();
@VisibleForTesting
public ConfigurationManager() {
@@ -43,7 +44,6 @@ public class ConfigurationManager implements FileChangeCallback, IEcompConfigura
instance = this;
}
- Map<String, Object> configurations = new HashMap<>();
public ConfigurationManager(ConfigurationSource configurationSource) {
super();
this.configurationSource = configurationSource;
@@ -124,7 +124,11 @@ public class ConfigurationManager implements FileChangeCallback, IEcompConfigura
return instance;
}
- public void reconfigure(BasicConfiguration obj) { }
+ public void reconfigure(final BasicConfiguration basicConfiguration) {
+ if (basicConfiguration instanceof Configuration) {
+ configurations.put(getKey(Configuration.class), basicConfiguration);
+ }
+ }
/**
* FOR TEST ONLY
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ConfigurationSource.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ConfigurationSource.java
index 5901d1e267..12982caec0 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ConfigurationSource.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ConfigurationSource.java
@@ -22,7 +22,7 @@ package org.openecomp.sdc.common.api;
public interface ConfigurationSource {
- public <T> T getAndWatchConfiguration(Class<T> className, ConfigurationListener configurationListener);
+ <T> T getAndWatchConfiguration(Class<T> className, ConfigurationListener configurationListener);
- public <T> void addWatchConfiguration(Class<T> className, ConfigurationListener configurationListener);
+ <T> void addWatchConfiguration(Class<T> className, ConfigurationListener configurationListener);
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/FileChangeCallback.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/FileChangeCallback.java
index 5c4d3d5926..9684c98bd3 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/FileChangeCallback.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/FileChangeCallback.java
@@ -20,8 +20,9 @@
package org.openecomp.sdc.common.api;
+@FunctionalInterface
public interface FileChangeCallback {
- public void reconfigure(BasicConfiguration obj);
+ void reconfigure(BasicConfiguration obj);
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/exception/LoadConfigurationException.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/exception/LoadConfigurationException.java
new file mode 100644
index 0000000000..dff83c6d6f
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/exception/LoadConfigurationException.java
@@ -0,0 +1,27 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.common.api.exception;
+
+public class LoadConfigurationException extends RuntimeException {
+
+ public LoadConfigurationException(final String s, final Throwable throwable) {
+ super(s, throwable);
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java
index e243bac730..c94db9a3c9 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java
@@ -20,22 +20,23 @@
package org.openecomp.sdc.common.impl;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.jci.listeners.FileChangeListener;
import org.openecomp.sdc.common.api.BasicConfiguration;
import org.openecomp.sdc.common.api.ConfigurationListener;
import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.common.util.YamlToObjectConverter;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import org.openecomp.sdc.exception.YamlConversionException;
public class ConfigFileChangeListener extends FileChangeListener {
- private static Logger log = Logger.getLogger(ConfigFileChangeListener.class.getName());
+ private static final Logger LOGGER = Logger.getLogger(ConfigFileChangeListener.class.getName());
private Map<String, List<ConfigurationListener>> fileChangeToCallBack = new HashMap<>();
@@ -45,45 +46,46 @@ public class ConfigFileChangeListener extends FileChangeListener {
@Override
public void onFileChange(File pFile) {
-
super.onFileChange(pFile);
- if (pFile != null) {
-
- if (fileChangeToCallBack != null) {
-
- String id = findIdFromFileName(pFile.getName());
-
- if (id != null) {
-
- List<ConfigurationListener> listeners = fileChangeToCallBack.get(id);
- if (listeners != null) {
- for (ConfigurationListener configurationListener : listeners) {
-
- Class<? extends BasicConfiguration> configClass = configurationListener.getType();
-
- BasicConfiguration basicConfiguration = yamlToObjectConverter.convert(pFile.getAbsolutePath(), configClass);
-
- if (basicConfiguration == null) {
- log.warn(EcompLoggerErrorCode.UNKNOWN_ERROR,"","","Cannot update the listeners for file Change since the file content is invalid");
- continue;
- }
- log.debug("Loaded configuration after converting is {}", basicConfiguration);
-
+ if (pFile == null) {
+ LOGGER.debug("Invalid file '{}'.", pFile);
+ return;
+ }
- configurationListener.getCallBack().reconfigure(basicConfiguration);
+ if (fileChangeToCallBack == null) {
+ LOGGER.debug("File '{}' callback is null.", pFile);
+ return;
+ }
- }
- }
- } else {
+ final String id = findIdFromFileName(pFile.getName());
+ if (id == null) {
+ LOGGER.warn(EcompLoggerErrorCode.UNKNOWN_ERROR,"","",
+ "Cannot calculate id from file {}", pFile.getName());
+ return;
+ }
- log.warn(EcompLoggerErrorCode.UNKNOWN_ERROR,"","","Cannot calculate id from file {}", pFile.getName());
- }
+ final List<ConfigurationListener> listeners = fileChangeToCallBack.get(id);
+ if (CollectionUtils.isEmpty(listeners)) {
+ LOGGER.debug("No file listeners for file '{}', id '{}'.", pFile, id);
+ return;
+ }
+ for (final ConfigurationListener configurationListener : listeners) {
+ final Class<? extends BasicConfiguration> configClass = configurationListener.getType();
+ final BasicConfiguration basicConfiguration;
+ try {
+ basicConfiguration = yamlToObjectConverter.convert(pFile.getAbsolutePath(), configClass);
+ } catch (final YamlConversionException e) {
+ LOGGER.warn(EcompLoggerErrorCode.SCHEMA_ERROR,
+ "Configuration", "Configuration",
+ "Cannot update the listeners for file Change since the file content is invalid: {}",
+ e.getLocalizedMessage());
+ continue;
}
-
+ LOGGER.debug("Loaded configuration after converting is {}", basicConfiguration);
+ configurationListener.getCallBack().reconfigure(basicConfiguration);
}
-
- log.debug("File {} was changed.", pFile);
+ LOGGER.debug("File {} was changed.", pFile);
}
private String findIdFromFileName(String name) {
@@ -95,10 +97,6 @@ public class ConfigFileChangeListener extends FileChangeListener {
if (name.contains(File.separator)) {
startIndex = name.lastIndexOf(File.separator);
}
- // String subNameString = name.substring(startIndex, endIndex);
- // if (subNameString.contains(".")) {
- // endIndex = subNameString.indexOf(".");
- // }
result = name.substring(startIndex, endIndex);
@@ -126,20 +124,4 @@ public class ConfigFileChangeListener extends FileChangeListener {
}
- // public void notify(String id, BasicConfiguration object) {
- //
- // if (fileChangeToCallBack != null) {
- // List<ConfigurationListener> listeners = fileChangeToCallBack
- // .get(id);
- // if (listeners != null) {
- // for (ConfigurationListener configurationListener : listeners) {
- //
- // configurationListener.getCallBack().reconfigure(object);
- //
- // }
- // }
- // }
- //
- // }
-
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java
index 8cab431594..3820f2c26c 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java
@@ -27,7 +27,9 @@ import java.util.stream.Collectors;
import org.openecomp.sdc.common.api.ConfigurationListener;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.api.exception.LoadConfigurationException;
import org.openecomp.sdc.common.util.YamlToObjectConverter;
+import org.openecomp.sdc.exception.YamlConversionException;
/**
* Read configuration from file system
@@ -55,16 +57,21 @@ public class FSConfigurationSource implements ConfigurationSource {
*
* @see org.openecomp.sdc.common.api.ConfigurationSource#getAndWatchConfiguration (java.lang.Class, org.openecomp.sdc.common.api.ConfigurationListener)
*/
- public <T> T getAndWatchConfiguration(Class<T> className, ConfigurationListener configurationListener) {
+ public <T> T getAndWatchConfiguration(final Class<T> className, final ConfigurationListener configurationListener) {
- String configFileName = calculateFileName(className);
+ final String configFileName = calculateFileName(className);
- T object = yamlToObjectConverter.convert(this.appConfigDir, className, configFileName);
+ T object;
+ try {
+ object = yamlToObjectConverter.convert(this.appConfigDir, className, configFileName);
+ } catch (final YamlConversionException e) {
+ final String errorMsg =
+ String.format("Could not load '%s' in '%s' for class '%s'", configFileName, appConfigDir, className);
+ throw new LoadConfigurationException(errorMsg, e);
+ }
if (configurationListener != null && changeListener != null) {
- if (object != null) {
- changeListener.register(configFileName, configurationListener);
- }
+ changeListener.register(configFileName, configurationListener);
}
return object;
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java
index b2435de12c..756670c54a 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java
@@ -20,8 +20,23 @@
package org.openecomp.sdc.common.util;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.commons.codec.binary.Base64;
-import org.openecomp.sdc.be.config.Configuration.*;
+import org.openecomp.sdc.be.config.Configuration.ApplicationL1CacheConfig;
+import org.openecomp.sdc.be.config.Configuration.ApplicationL2CacheConfig;
+import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig;
+import org.openecomp.sdc.be.config.Configuration.BeMonitoringConfig;
+import org.openecomp.sdc.be.config.Configuration.EcompPortalConfig;
+import org.openecomp.sdc.be.config.Configuration.OnboardingConfig;
+import org.openecomp.sdc.be.config.Configuration.SwitchoverDetectorConfig;
+import org.openecomp.sdc.be.config.Configuration.ToscaValidatorsConfig;
import org.openecomp.sdc.be.config.DistributionEngineConfiguration;
import org.openecomp.sdc.be.config.DistributionEngineConfiguration.ComponentArtifactTypesConfig;
import org.openecomp.sdc.be.config.DistributionEngineConfiguration.CreateTopicConfig;
@@ -30,21 +45,11 @@ import org.openecomp.sdc.be.config.DistributionEngineConfiguration.DistributionS
import org.openecomp.sdc.be.config.validation.DeploymentArtifactHeatConfiguration;
import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
import org.openecomp.sdc.common.log.wrappers.Logger;
+import org.openecomp.sdc.exception.YamlConversionException;
import org.openecomp.sdc.fe.config.Configuration.FeMonitoringConfig;
import org.yaml.snakeyaml.TypeDescription;
import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.error.YAMLException;
import org.yaml.snakeyaml.introspector.PropertyUtils;
-import org.yaml.snakeyaml.nodes.Node;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.HashMap;
-import java.util.Map;
public class YamlToObjectConverter {
@@ -132,115 +137,51 @@ public class YamlToObjectConverter {
return yaml;
}
- public <T> T convert(String dirPath, Class<T> className, String configFileName) {
-
- T config = null;
-
- try {
-
- String fullFileName = dirPath + File.separator + configFileName;
-
- config = convert(fullFileName, className);
-
- } catch (Exception e) {
- log.error(EcompLoggerErrorCode.UNKNOWN_ERROR,"","","Failed to convert yaml file {} to object.", configFileName,e);
+ public <T> T convert(final String dirPath, final Class<T> className,
+ final String configFileName) throws YamlConversionException {
+ if (className == null) {
+ throw new IllegalArgumentException("className cannot be null");
}
-
- return config;
+ final String fullFileName = dirPath + File.separator + configFileName;
+ return convert(fullFileName, className);
}
- public class MyYamlConstructor extends org.yaml.snakeyaml.constructor.Constructor {
- private HashMap<String, Class<?>> classMap = new HashMap<>();
-
- public MyYamlConstructor(Class<? extends Object> theRoot) {
- super(theRoot);
- classMap.put(DistributionEngineConfiguration.class.getName(), DistributionEngineConfiguration.class);
- classMap.put(DistributionStatusTopicConfig.class.getName(), DistributionStatusTopicConfig.class);
+ public <T> T convert(String fullFileName, Class<T> className) throws YamlConversionException {
+ if (!new File(fullFileName).exists()) {
+ log.warn(EcompLoggerErrorCode.UNKNOWN_ERROR,"","",
+ "The file {} cannot be found. Ignore reading configuration.", fullFileName);
+ return null;
}
- /*
- * This is a modified version of the Constructor. Rather than using a
- * class loader to get external classes, they are already predefined
- * above. This approach works similar to the typeTags structure in the
- * original constructor, except that class information is pre-populated
- * during initialization rather than runtime.
- *
- * @see
- * org.yaml.snakeyaml.constructor.Constructor#getClassForNode(org.yaml.
- * snakeyaml.nodes.Node)
- */
- protected Class<?> getClassForNode(Node node) {
- String name = node.getTag().getClassName();
- Class<?> cl = classMap.get(name);
- if (cl == null)
- throw new YAMLException("Class not found: " + name);
- else
- return cl;
- }
- }
-
- public <T> T convert(String fullFileName, Class<T> className) {
-
- T config = null;
-
- Yaml yaml = getYamlByClassName(className);
-
- InputStream in = null;
- try {
+ final Yaml yaml = getYamlByClassName(className);
- File f = new File(fullFileName);
- if (!f.exists()) {
- log.warn(EcompLoggerErrorCode.UNKNOWN_ERROR,"","","The file {} cannot be found. Ignore reading configuration.",fullFileName);
- return null;
- }
- in = Files.newInputStream(Paths.get(fullFileName));
-
- config = yaml.loadAs(in, className);
-
- // System.out.println(config.toString());
+ try (final InputStream in = Files.newInputStream(Paths.get(fullFileName))) {
+ return yaml.loadAs(in, className);
+ } catch (final IOException e) {
+ log.debug("Failed to open/close input stream", e);
} catch (Exception e) {
- log.error(EcompLoggerErrorCode.UNKNOWN_ERROR,"","","Failed to convert yaml file {} to object.", fullFileName, e);
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- log.debug("Failed to close input stream", e);
- e.printStackTrace();
- }
- }
+ log.error(EcompLoggerErrorCode.UNKNOWN_ERROR,"","",
+ "Failed to convert yaml file {} to object.", fullFileName, e);
+ final String errorMsg = String.format("Could not parse '%s' to class '%s'", fullFileName, className);
+ throw new YamlConversionException(errorMsg, e);
}
- return config;
+ return null;
}
public <T> T convert(byte[] fileContents, Class<T> className) {
-
- T config = null;
-
- Yaml yaml = getYamlByClassName(className);
-
- InputStream in = null;
- try {
-
- in = new ByteArrayInputStream(fileContents);
-
- config = yaml.loadAs(in, className);
-
- } catch (Exception e) {
- log.error(EcompLoggerErrorCode.UNKNOWN_ERROR,"","","Failed to convert yaml file to object", e);
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- log.debug("Failed to close input stream", e);
- e.printStackTrace();
- }
- }
+ final Yaml yaml = getYamlByClassName(className);
+
+ try (final InputStream in = new ByteArrayInputStream(fileContents)){
+ return yaml.loadAs(in, className);
+ } catch (final IOException e) {
+ log.debug("Failed to open or close input stream", e);
+ } catch (final Exception e) {
+ log.error(EcompLoggerErrorCode.UNKNOWN_ERROR,
+ "","","Failed to convert yaml file to object", e);
}
- return config;
+ return null;
}
public boolean isValidYamlEncoded64(byte[] fileContents) {
@@ -261,7 +202,8 @@ public class YamlToObjectConverter {
}
} catch (Exception e) {
- log.error(EcompLoggerErrorCode.UNKNOWN_ERROR,"","","Failed to convert yaml file to object - yaml is invalid", e);
+ log.error(EcompLoggerErrorCode.UNKNOWN_ERROR,"","",
+ "Failed to convert yaml file to object - yaml is invalid", e);
return false;
}
return true;
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/YamlConversionException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/YamlConversionException.java
new file mode 100644
index 0000000000..4d8791f15d
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/YamlConversionException.java
@@ -0,0 +1,27 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.exception;
+
+public class YamlConversionException extends Exception {
+
+ public YamlConversionException(final String s, final Throwable throwable) {
+ super(s, throwable);
+ }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/util/YamlToObjectConverterTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/util/YamlToObjectConverterTest.java
index 49fc553302..35af78bd4e 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/util/YamlToObjectConverterTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/util/YamlToObjectConverterTest.java
@@ -29,6 +29,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
+import org.openecomp.sdc.exception.YamlConversionException;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertFalse;
@@ -81,14 +82,14 @@ public class YamlToObjectConverterTest {
}
@Test
- public void validateConvertWithFullFilePathReturnsValidObjectCreatedFromYaml() {
+ public void validateConvertWithFullFilePathReturnsValidObjectCreatedFromYaml() throws YamlConversionException {
Configuration result = yamlToObjectConverter.convert(filePath+fileName, Configuration.class);
assertThatCreatedObjectIsValid(result);
}
@Test
- public void validateConvertWithFullFilePathReturnsNullIfFileDoesNotExist() {
+ public void validateConvertWithFullFilePathReturnsNullIfFileDoesNotExist() throws YamlConversionException {
final String wrongFileName = "wrong-configuration.yaml";
Configuration result = yamlToObjectConverter.convert(wrongFileName, Configuration.class);
@@ -96,28 +97,23 @@ public class YamlToObjectConverterTest {
assertNull(result);
}
- @Test
- public void validateConvertWithFullFilePathReturnsNullIfClassDoesNotMathYaml() {
-
- HttpClient result = yamlToObjectConverter.convert(filePath+fileName, HttpClient.class);
-
- assertNull(result);
+ @Test(expected = YamlConversionException.class)
+ public void validateConvertWithFullFilePathThrowsExceptionIfClassDoesNotMathYaml() throws YamlConversionException {
+ yamlToObjectConverter.convert(filePath + fileName, HttpClient.class);
}
@Test
- public void validateConvertWithFilePathAndFileNameReturnsValidObjectCreatedFromYaml() {
+ public void validateConvertWithFilePathAndFileNameReturnsValidObjectCreatedFromYaml()
+ throws YamlConversionException {
Configuration result = yamlToObjectConverter.convert(filePath, Configuration.class, fileName);
assertThatCreatedObjectIsValid(result);
}
- @Test
- public void validateConvertWithFilePathAndFileNameReturnsNullIfClassIsNull() {
-
- HttpClient result = yamlToObjectConverter.convert(filePath, null, fileName);
-
- assertNull(result);
+ @Test(expected = IllegalArgumentException.class)
+ public void validateConvertWithFilePathAndFileNameThrowsExceptionIfClassIsNull() throws YamlConversionException {
+ yamlToObjectConverter.convert(filePath, null, fileName);
}
@Test
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/fe/config/WorkspaceConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/fe/config/WorkspaceConfigurationTest.java
index dd1fe8b2be..08e9b34195 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/fe/config/WorkspaceConfigurationTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/fe/config/WorkspaceConfigurationTest.java
@@ -41,7 +41,7 @@ public class WorkspaceConfigurationTest {
@Before
public void setUp() {
- String appConfigDir = "src/test/resources/config/common";
+ String appConfigDir = "src/test/resources/config/fe";
ConfigurationSource configurationSource =
new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
configurationManager = new ConfigurationManager(configurationSource);
diff --git a/common-app-api/src/test/resources/config/common/workspace-configuration.yaml b/common-app-api/src/test/resources/config/fe/workspace-configuration.yaml
index fd382592b7..fd382592b7 100644
--- a/common-app-api/src/test/resources/config/common/workspace-configuration.yaml
+++ b/common-app-api/src/test/resources/config/fe/workspace-configuration.yaml
diff --git a/docs/configuration.rst b/docs/configuration.rst
index 3ce4a5fdf2..1fe26655b7 100644
--- a/docs/configuration.rst
+++ b/docs/configuration.rst
@@ -790,9 +790,6 @@ BE-configuration.yaml
- VFC
- CVFC
- # Resource informational deployment artifact placeholder
- resourceInformationalDeployedArtifacts:
-
# Requirements needed to be fulfilled before certification
requirementsToFulfillBeforeCert:
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/resources/configuration.yaml b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/resources/configuration.yaml
index c5a82d5bc8..81a548dd16 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/resources/configuration.yaml
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/resources/configuration.yaml
@@ -220,12 +220,6 @@ resourceDeploymentArtifacts:
- yaml
- yml
-resourceInformationalDeployedArtifacts:
- YANG_XML:
- acceptedTypes:
- - xml
-
-
unLoggedUrls:
- /sdc2/rest/healthCheck
diff --git a/openecomp-be/tools/zusammen-tools/src/test/resources/configuration.yaml b/openecomp-be/tools/zusammen-tools/src/test/resources/configuration.yaml
index 4dd21e3934..44b2759940 100644
--- a/openecomp-be/tools/zusammen-tools/src/test/resources/configuration.yaml
+++ b/openecomp-be/tools/zusammen-tools/src/test/resources/configuration.yaml
@@ -221,12 +221,6 @@ resourceDeploymentArtifacts:
- yaml
- yml
-resourceInformationalDeployedArtifacts:
- YANG_XML:
- acceptedTypes:
- - xml
-
-
unLoggedUrls:
- /sdc2/rest/healthCheck
diff --git a/test-apis-ci/src/test/resources/config/test-apis-ci/configuration.yaml b/test-apis-ci/src/test/resources/config/test-apis-ci/configuration.yaml
index 897a80bba1..de9f2137f5 100644
--- a/test-apis-ci/src/test/resources/config/test-apis-ci/configuration.yaml
+++ b/test-apis-ci/src/test/resources/config/test-apis-ci/configuration.yaml
@@ -536,8 +536,6 @@ resourceInformationalArtifacts:
- VFC
- CVFC
-resourceInformationalDeployedArtifacts:
-
requirementsToFulfillBeforeCert:
capabilitiesToConsumeBeforeCert:
@@ -680,5 +678,4 @@ dmaapConsumerConfiguration:
password: Pass
dmeConfiguration:
- dme2Search: DME2SEARCH
- dme2Resolve: DME2RESOLVE
+ lookupUriFormat: "http://DME2RESOLVE/service=%s/version=1.0.0/envContext=%s/routeOffer=DEFAULT"