From 4b978c9cc115c4f4032d5f3dbc4d3cde002449cc Mon Sep 17 00:00:00 2001 From: vasraz Date: Sat, 26 Feb 2022 17:22:58 +0000 Subject: Implement improved MinIo client Change-Id: Ic9abd6b0bdaa17e9deff2279a64416d81f7ad606 Signed-off-by: Vasyl Razinkov Issue-ID: SDC-3886 --- .../sdc/common/CommonConfigurationManager.java | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'openecomp-be/lib/openecomp-common-lib') diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/CommonConfigurationManager.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/CommonConfigurationManager.java index 46747fb881..92ace445da 100644 --- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/CommonConfigurationManager.java +++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/CommonConfigurationManager.java @@ -19,21 +19,21 @@ */ package org.openecomp.sdc.common; -import org.onap.sdc.tosca.services.YamlUtil; -import org.openecomp.sdc.logging.api.Logger; -import org.openecomp.sdc.logging.api.LoggerFactory; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.LinkedHashMap; import java.util.Map; import java.util.function.BiConsumer; +import org.onap.sdc.tosca.services.YamlUtil; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; /** - * This is a common class that can access the config file given in input to the JVM with the parameter - * -Dconfiguration.yaml=file.yaml. + * This is a common class that can access the config file given in input to the JVM with the parameter -Dconfiguration.yaml=file.yaml. */ public class CommonConfigurationManager { + public static final String JVM_PARAM_CONFIGURATION_FILE = "configuration.yaml"; private static final Logger LOGGER = LoggerFactory.getLogger(CommonConfigurationManager.class); private static CommonConfigurationManager singletonInstance; @@ -57,6 +57,10 @@ public class CommonConfigurationManager { return singletonInstance; } + public void reload() { + initConfiguration(); + } + private void initConfiguration() { YamlUtil yamlUtil = new YamlUtil(); readConfigurationFromStream(yamlUtil, (filename, stream) -> { @@ -106,7 +110,7 @@ public class CommonConfigurationManager { Map section = this.configuration.get(yamlSection); if (section == null) { LOGGER.error("Section " + yamlSection + " is missing in configuration file '" + configFilename + - "'. Using defaults"); + "'. Using defaults"); return defaultValue; } Object value = section.get(name); @@ -114,15 +118,14 @@ public class CommonConfigurationManager { return value == null ? defaultValue : (T) value; } catch (ClassCastException e) { LOGGER.warn( - String.format("Failed to read configuration property '%s' as requested type. Using default '%s'", - name, defaultValue), e); + String.format("Failed to read configuration property '%s' as requested type. Using default '%s'", + name, defaultValue), e); return defaultValue; } } /** - * This method can be used to access a specific configuration parameter in the configuration in the - * yamlSection predefined in the constructor. + * This method can be used to access a specific configuration parameter in the configuration in the yamlSection predefined in the constructor. * * @param name The name of the config * @param defaultValue A default value -- cgit 1.2.3-korg