aboutsummaryrefslogtreecommitdiffstats
path: root/common/onap-common-configuration-management/onap-configuration-management-core
diff options
context:
space:
mode:
Diffstat (limited to 'common/onap-common-configuration-management/onap-configuration-management-core')
-rw-r--r--common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/Constants.java21
-rw-r--r--common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/CliConfigurationImpl.java565
-rw-r--r--common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationChangeNotifier.java6
3 files changed, 296 insertions, 296 deletions
diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/Constants.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/Constants.java
index a16607cbc0..9f8e9e5ecc 100644
--- a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/Constants.java
+++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/Constants.java
@@ -2,13 +2,16 @@ package org.onap.config;
public class Constants {
- public static final String DEFAULT_TENANT = "GLOBAL";
- public static final String DEFAULT_NAMESPACE = "COMMON";
- public static final String DB_NAMESPACE = "SYSTEM";
- public static final String KEY_ELEMENTS_DELEMETER = "-";
- public static final String TENANT_NAMESPACE_SAPERATOR = ":";
- public static final String NAMESPACE_KEY = "_config.namespace";
- public static final String MODE_KEY = "_config.mergeStrategy";
- public static final String MBEAN_NAME = "org.openecomp.jmx:name=SystemConfig";
- public final static String LOAD_ORDER_KEY="_config.loadOrder";
+ public static final String DEFAULT_TENANT = "GLOBAL";
+ public static final String DEFAULT_NAMESPACE = "COMMON";
+ public static final String DB_NAMESPACE = "SYSTEM";
+ public static final String KEY_ELEMENTS_DELEMETER = "-";
+ public static final String TENANT_NAMESPACE_SAPERATOR = ":";
+ public static final String NAMESPACE_KEY = "_config.namespace";
+ public static final String MODE_KEY = "_config.mergeStrategy";
+ public static final String MBEAN_NAME = "org.openecomp.jmx:name=SystemConfig";
+ public static final String LOAD_ORDER_KEY = "_config.loadOrder";
+
+ private Constants() {
+ }
}
diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/CliConfigurationImpl.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/CliConfigurationImpl.java
index 3bdebffb48..53ebf2943b 100644
--- a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/CliConfigurationImpl.java
+++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/CliConfigurationImpl.java
@@ -9,18 +9,6 @@ import static org.onap.config.Constants.MBEAN_NAME;
import static org.onap.config.Constants.MODE_KEY;
import static org.onap.config.Constants.NAMESPACE_KEY;
-import org.apache.commons.configuration2.CombinedConfiguration;
-import org.apache.commons.configuration2.CompositeConfiguration;
-import org.apache.commons.configuration2.Configuration;
-import org.apache.commons.configuration2.FileBasedConfiguration;
-import org.apache.commons.configuration2.PropertiesConfiguration;
-import org.onap.config.type.ConfigurationQuery;
-import org.onap.config.ConfigurationUtils;
-import org.onap.config.Constants;
-import org.onap.config.api.ConfigurationManager;
-import org.onap.config.api.Hint;
-import org.onap.config.type.ConfigurationUpdate;
-
import java.io.File;
import java.io.PrintWriter;
import java.lang.management.ManagementFactory;
@@ -39,316 +27,325 @@ import javax.management.MBeanServerNotification;
import javax.management.Notification;
import javax.management.ObjectName;
import javax.management.StandardMBean;
+import org.apache.commons.configuration2.CombinedConfiguration;
+import org.apache.commons.configuration2.CompositeConfiguration;
+import org.apache.commons.configuration2.Configuration;
+import org.apache.commons.configuration2.FileBasedConfiguration;
+import org.apache.commons.configuration2.PropertiesConfiguration;
+import org.onap.config.ConfigurationUtils;
+import org.onap.config.Constants;
+import org.onap.config.api.ConfigurationManager;
+import org.onap.config.api.Hint;
+import org.onap.config.type.ConfigurationQuery;
+import org.onap.config.type.ConfigurationUpdate;
/**
* The type Cli configuration.
*/
public final class CliConfigurationImpl extends ConfigurationImpl implements ConfigurationManager {
- /**
- * Instantiates a new Cli configuration.
- *
- * @throws Exception the exception
- */
- public CliConfigurationImpl() throws Exception {
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- ObjectName name = new ObjectName(MBEAN_NAME);
- if (mbs.isRegistered(name)) {
- mbs.unregisterMBean(name);
+ /**
+ * Instantiates a new Cli configuration.
+ *
+ * @throws Exception the exception
+ */
+ public CliConfigurationImpl() throws Exception {
+ MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+ ObjectName name = new ObjectName(MBEAN_NAME);
+ if (mbs.isRegistered(name)) {
+ mbs.unregisterMBean(name);
+ }
+ mbs.registerMBean(new StandardMBean(this, ConfigurationManager.class), name);
+ mbs.addNotificationListener(MBeanServerDelegate.DELEGATE_NAME,
+ (notification, handback) -> handleNotification(notification), null,
+ null);
}
- mbs.registerMBean(new StandardMBean(this, ConfigurationManager.class), name);
- //mbs.registerMBean(getMBean(), name);
- mbs.addNotificationListener(MBeanServerDelegate.DELEGATE_NAME, this::handleNotification, null,
- null);
- //mbs.addNotificationListener(name, this::handleNotification, null, null);
- }
- /**
- * Handle notification.
- *
- * @param notification the notification
- * @param handback the handback
- */
- public void handleNotification(Notification notification, Object handback) {
- if (notification instanceof MBeanServerNotification) {
- MBeanServerNotification mbs = (MBeanServerNotification) notification;
- if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(mbs.getType())) {
+ /**
+ * Handle notification.
+ *
+ * @param notification the notification
+ */
+ public void handleNotification(Notification notification) {
+ if (notification instanceof MBeanServerNotification) {
+ MBeanServerNotification mbs = (MBeanServerNotification) notification;
+ if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(mbs.getType())) {
+ try {
+ String mbean =
+ ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, DB_NAMESPACE)
+ .getString("shutdown.mbean");
+ if (mbs.getMBeanName()
+ .equals(mbean == null ? new ObjectName(MBEAN_NAME) : new ObjectName(mbean))) {
+ changeNotifier.shutdown();
+ ConfigurationDataSource.lookup().close();
+ }
+ } catch (Exception exception) {
+ //do nothing.
+ }
+ } else if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(mbs.getType())) {
+ mbs.getMBeanName();
+ }
+ }
+ }
+
+ public String getConfigurationValue(Map<String, Object> input) {
+ return getConfigurationValue((ConfigurationQuery) getInput(input));
+ }
+
+ private String getConfigurationValue(ConfigurationQuery queryData) {
try {
- String mbean =
- ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, DB_NAMESPACE)
- .getString("shutdown.mbean");
- if (mbs.getMBeanName()
- .equals(mbean == null ? new ObjectName(MBEAN_NAME) : new ObjectName(mbean))) {
- changeNotifier.shutdown();
- ConfigurationDataSource.lookup().close();
- }
+ if (queryData.isFallback()) {
+ return ConfigurationUtils.getCommaSeparatedList(
+ get(queryData.getTenant(), queryData.getNamespace(), queryData.getKey(), String[].class,
+ queryData.isLatest() ? Hint.LATEST_LOOKUP : Hint.DEFAULT,
+ queryData.isExternalLookup() ? Hint.EXTERNAL_LOOKUP : Hint.DEFAULT,
+ queryData.isNodeSpecific() ? Hint.NODE_SPECIFIC : Hint.DEFAULT));
+ } else {
+ String[] list =
+ getInternal(queryData.getTenant(), queryData.getNamespace(), queryData.getKey(),
+ String[].class, queryData.isLatest() ? Hint.LATEST_LOOKUP : Hint.DEFAULT,
+ queryData.isExternalLookup() ? Hint.EXTERNAL_LOOKUP : Hint.DEFAULT,
+ queryData.isNodeSpecific() ? Hint.NODE_SPECIFIC : Hint.DEFAULT);
+ return ConfigurationUtils
+ .getCommaSeparatedList(list == null ? Arrays.asList() : Arrays.asList(list));
+ }
} catch (Exception exception) {
- //do nothing.
+ exception.printStackTrace();
}
- } else if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(mbs.getType())) {
- mbs.getMBeanName();
- }
+ return null;
}
- }
- public String getConfigurationValue(Map<String, Object> input) {
- return getConfigurationValue((ConfigurationQuery) getInput(input));
- }
-
- private String getConfigurationValue(ConfigurationQuery queryData) {
- try {
- if (queryData.isFallback()) {
- return ConfigurationUtils.getCommaSeparatedList(
- get(queryData.getTenant(), queryData.getNamespace(), queryData.getKey(), String[].class,
- queryData.isLatest() ? Hint.LATEST_LOOKUP : Hint.DEFAULT,
- queryData.isExternalLookup() ? Hint.EXTERNAL_LOOKUP : Hint.DEFAULT,
- queryData.isNodeSpecific() ? Hint.NODE_SPECIFIC : Hint.DEFAULT));
- } else {
- String[] list =
- getInternal(queryData.getTenant(), queryData.getNamespace(), queryData.getKey(),
- String[].class, queryData.isLatest() ? Hint.LATEST_LOOKUP : Hint.DEFAULT,
- queryData.isExternalLookup() ? Hint.EXTERNAL_LOOKUP : Hint.DEFAULT,
- queryData.isNodeSpecific() ? Hint.NODE_SPECIFIC : Hint.DEFAULT);
- return ConfigurationUtils
- .getCommaSeparatedList(list == null ? Arrays.asList() : Arrays.asList(list));
- }
- } catch (Exception exception) {
- exception.printStackTrace();
+ public void updateConfigurationValue(Map<String, Object> input) {
+ updateConfigurationValue((ConfigurationUpdate) getInput(input));
}
- return null;
- }
- public void updateConfigurationValue(Map<String, Object> input) {
- updateConfigurationValue((ConfigurationUpdate) getInput(input));
- }
+ private void updateConfigurationValue(ConfigurationUpdate updateData) {
- private void updateConfigurationValue(ConfigurationUpdate updateData) {
+ try {
+ if (!ConfigurationRepository.lookup().isValidTenant(updateData.getTenant())) {
+ throw new RuntimeException("Invalid tenantId.");
+ }
+ if (!ConfigurationRepository.lookup().isValidNamespace(updateData.getNamespace())) {
+ throw new RuntimeException("Invalid Namespace.");
+ }
+ } catch (NullPointerException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
- try {
- if (!ConfigurationRepository.lookup().isValidTenant(updateData.getTenant())) {
- throw new RuntimeException("Invalid tenantId.");
- }
- if (!ConfigurationRepository.lookup().isValidNamespace(updateData.getNamespace())) {
- throw new RuntimeException("Invalid Namespace.");
- }
- } catch (NullPointerException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
+ try {
+ boolean keyPresent =
+ isKeyExists(updateData.getTenant(), updateData.getNamespace(), updateData.getKey());
+ if (keyPresent) {
+ boolean isUpdated = false;
+ Object[] paramArray = new Object[]{
+ updateData.getTenant() + KEY_ELEMENTS_DELEMETER + updateData.getNamespace(),
+ new Long(System.currentTimeMillis()), updateData.getKey(),
+ getConfigurationValue(updateData), updateData.getValue()};
+ Configuration config = ConfigurationRepository.lookup()
+ .getConfigurationFor(updateData.getTenant(), updateData.getNamespace());
+ if (config instanceof AgglomerateConfiguration || config instanceof CombinedConfiguration) {
+ CompositeConfiguration cc = new CompositeConfiguration();
+ cc.addConfiguration(config);
+ config = cc;
+ }
+ CompositeConfiguration configuration = (CompositeConfiguration) config;
+ int overrideIndex = -1;
+ for (int i = 0; i < configuration.getNumberOfConfigurations(); i++) {
+ if (!updateData.isNodeOverride()
+ && (configuration.getConfiguration(i) instanceof AgglomerateConfiguration
+ || configuration.getConfiguration(i) instanceof CombinedConfiguration)) {
+ configuration.getConfiguration(i)
+ .setProperty(updateData.getKey(), updateData.getValue());
+ isUpdated = true;
+ break;
+ } else if (updateData.isNodeOverride()
+ && configuration.getConfiguration(i) instanceof FileBasedConfiguration) {
+ configuration.getConfiguration(i)
+ .setProperty(updateData.getKey(), updateData.getValue());
+ isUpdated = true;
+ overrideIndex = i;
+ break;
+ }
+ }
+ if (!isUpdated) {
+ if (updateData.isNodeOverride()) {
+ PropertiesConfiguration pc = new PropertiesConfiguration();
+ pc.setProperty(NAMESPACE_KEY,
+ updateData.getTenant() + Constants.TENANT_NAMESPACE_SAPERATOR
+ + updateData.getNamespace());
+ pc.setProperty(MODE_KEY, "OVERRIDE");
+ pc.setProperty(updateData.getKey(), updateData.getValue());
+ if (System.getProperty("node.config.location") != null
+ && System.getProperty("node.config.location").trim().length() > 0) {
+ File file = new File(System.getProperty("node.config.location"),
+ updateData.getTenant() + File.separator + updateData.getNamespace()
+ + File.separator + "config.properties");
+ file.getParentFile().mkdirs();
+ PrintWriter out = new PrintWriter(file);
+ pc.write(out);
+ out.close();
+ ConfigurationRepository.lookup().populateOverrideConfigurtaion(
+ updateData.getTenant() + KEY_ELEMENTS_DELEMETER + updateData.getNamespace(),
+ file);
+ }
+ } else {
+ configuration.getConfiguration(0)
+ .setProperty(updateData.getKey(), updateData.getValue());
+ }
+ }
+ if (!updateData.isNodeOverride()) {
+ ConfigurationUtils.executeInsertSql(
+ ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, DB_NAMESPACE)
+ .getString("insertconfigurationchangecql"), paramArray);
+ } else {
+ ConfigurationRepository.lookup().refreshOverrideConfigurtaionFor(
+ updateData.getTenant() + KEY_ELEMENTS_DELEMETER + updateData.getNamespace(),
+ overrideIndex);
+ }
+ }
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
}
- try {
- boolean keyPresent =
- isKeyExists(updateData.getTenant(), updateData.getNamespace(), updateData.getKey());
- if (keyPresent) {
- boolean isUpdated = false;
- Object[] paramArray = new Object[]{
- updateData.getTenant() + KEY_ELEMENTS_DELEMETER + updateData.getNamespace(),
- new Long(System.currentTimeMillis()), updateData.getKey(),
- getConfigurationValue(updateData), updateData.getValue()};
- Configuration config = ConfigurationRepository.lookup()
- .getConfigurationFor(updateData.getTenant(), updateData.getNamespace());
- if (config instanceof AgglomerateConfiguration || config instanceof CombinedConfiguration) {
- CompositeConfiguration cc = new CompositeConfiguration();
- cc.addConfiguration(config);
- config = cc;
- }
- CompositeConfiguration configuration = (CompositeConfiguration) config;
- int overrideIndex = -1;
- for (int i = 0; i < configuration.getNumberOfConfigurations(); i++) {
- if (!updateData.isNodeOverride()
- && (configuration.getConfiguration(i) instanceof AgglomerateConfiguration
- || configuration.getConfiguration(i) instanceof CombinedConfiguration)) {
- configuration.getConfiguration(i)
- .setProperty(updateData.getKey(), updateData.getValue());
- isUpdated = true;
- break;
- } else if (updateData.isNodeOverride()
- && configuration.getConfiguration(i) instanceof FileBasedConfiguration) {
- configuration.getConfiguration(i)
- .setProperty(updateData.getKey(), updateData.getValue());
- isUpdated = true;
- overrideIndex = i;
- break;
- }
- }
- if (!isUpdated) {
- if (updateData.isNodeOverride()) {
- PropertiesConfiguration pc = new PropertiesConfiguration();
- pc.setProperty(NAMESPACE_KEY,
- updateData.getTenant() + Constants.TENANT_NAMESPACE_SAPERATOR
- + updateData.getNamespace());
- pc.setProperty(MODE_KEY, "OVERRIDE");
- pc.setProperty(updateData.getKey(), updateData.getValue());
- if (System.getProperty("node.config.location") != null
- && System.getProperty("node.config.location").trim().length() > 0) {
- File file = new File(System.getProperty("node.config.location"),
- updateData.getTenant() + File.separator + updateData.getNamespace()
- + File.separator + "config.properties");
- file.getParentFile().mkdirs();
- PrintWriter out = new PrintWriter(file);
- pc.write(out);
- out.close();
- ConfigurationRepository.lookup().populateOverrideConfigurtaion(
- updateData.getTenant() + KEY_ELEMENTS_DELEMETER + updateData.getNamespace(),
- file);
+ private boolean isKeyExists(String tenant, String namespace, String key) {
+ boolean keyExist = false;
+ try {
+ keyExist =
+ ConfigurationRepository.lookup().getConfigurationFor(tenant, namespace).containsKey(key);
+ if (!keyExist && !DEFAULT_TENANT.equals(tenant)) {
+ keyExist = ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, namespace)
+ .containsKey(key);
}
- } else {
- configuration.getConfiguration(0)
- .setProperty(updateData.getKey(), updateData.getValue());
- }
- }
- if (!updateData.isNodeOverride()) {
- ConfigurationUtils.executeInsertSql(
- ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, DB_NAMESPACE)
- .getString("insertconfigurationchangecql"), paramArray);
- } else {
- ConfigurationRepository.lookup().refreshOverrideConfigurtaionFor(
- updateData.getTenant() + KEY_ELEMENTS_DELEMETER + updateData.getNamespace(),
- overrideIndex);
+ if (!keyExist && !DEFAULT_NAMESPACE.equals(namespace)) {
+ keyExist = ConfigurationRepository.lookup().getConfigurationFor(tenant, DEFAULT_NAMESPACE)
+ .containsKey(key);
+ }
+ if (!keyExist && !DEFAULT_TENANT.equals(tenant) && !DEFAULT_NAMESPACE.equals(namespace)) {
+ keyExist =
+ ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, DEFAULT_NAMESPACE)
+ .containsKey(key);
+ }
+ } catch (Exception exception) {
+ exception.printStackTrace();
}
- }
- } catch (Exception exception) {
- exception.printStackTrace();
+ return keyExist;
}
- }
- private boolean isKeyExists(String tenant, String namespace, String key) {
- boolean keyExist = false;
- try {
- keyExist =
- ConfigurationRepository.lookup().getConfigurationFor(tenant, namespace).containsKey(key);
- if (!keyExist && !DEFAULT_TENANT.equals(tenant)) {
- keyExist = ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, namespace)
- .containsKey(key);
- }
- if (!keyExist && !DEFAULT_NAMESPACE.equals(namespace)) {
- keyExist = ConfigurationRepository.lookup().getConfigurationFor(tenant, DEFAULT_NAMESPACE)
- .containsKey(key);
- }
- if (!keyExist && !DEFAULT_TENANT.equals(tenant) && !DEFAULT_NAMESPACE.equals(namespace)) {
- keyExist =
- ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, DEFAULT_NAMESPACE)
- .containsKey(key);
- }
- } catch (Exception exception) {
- exception.printStackTrace();
+ public Map<String, String> listConfiguration(Map<String, Object> input) {
+ return listConfiguration((ConfigurationQuery) getInput(input));
}
- return keyExist;
- }
-
- public Map<String, String> listConfiguration(Map<String, Object> input) {
- return listConfiguration((ConfigurationQuery) getInput(input));
- }
- private Map<String, String> listConfiguration(ConfigurationQuery query) {
- Map<String, String> map = new HashMap<>();
- try {
- Collection<String> keys = getKeys(query.getTenant(), query.getNamespace());
- for (String key : keys) {
- map.put(key, getConfigurationValue(query.key(key)));
- }
- } catch (Exception exception) {
- exception.printStackTrace();
- return null;
+ private Map<String, String> listConfiguration(ConfigurationQuery query) {
+ Map<String, String> map = new HashMap<>();
+ try {
+ Collection<String> keys = getKeys(query.getTenant(), query.getNamespace());
+ for (String key : keys) {
+ map.put(key, getConfigurationValue(query.key(key)));
+ }
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ return null;
+ }
+ return map;
}
- return map;
- }
- @Override
- public boolean updateConfigurationValues(String tenant, String namespace,
- Map configKeyValueStore) {
- boolean valueToReturn = true;
- Iterator<String> keys = configKeyValueStore.keySet().iterator();
- while (keys.hasNext()) {
- try {
- String key = keys.next();
- ConfigurationUpdate updateData = new ConfigurationUpdate();
- updateData.tenant(tenant).namespace(namespace).key(key);
- updateData.value(configKeyValueStore.get(key).toString());
- updateConfigurationValue(updateData);
- } catch (Exception exception) {
- exception.printStackTrace();
- valueToReturn = false;
- }
+ @Override
+ public boolean updateConfigurationValues(String tenant, String namespace,
+ Map configKeyValueStore) {
+ boolean valueToReturn = true;
+ Iterator<String> keys = configKeyValueStore.keySet().iterator();
+ while (keys.hasNext()) {
+ try {
+ String key = keys.next();
+ ConfigurationUpdate updateData = new ConfigurationUpdate();
+ updateData.tenant(tenant).namespace(namespace).key(key);
+ updateData.value(configKeyValueStore.get(key).toString());
+ updateConfigurationValue(updateData);
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ valueToReturn = false;
+ }
+ }
+ return valueToReturn;
}
- return valueToReturn;
- }
- private Object getInput(Map<String, Object> input) {
- Object toReturn = null;
- try {
- toReturn = Class.forName(input.get("ImplClass").toString()).newInstance();
- Method[] methods = toReturn.getClass().getMethods();
- for (Method method : methods) {
- if (input.containsKey(method.getName())) {
- method.invoke(toReturn, input.get(method.getName()));
+ private Object getInput(Map<String, Object> input) {
+ Object toReturn = null;
+ try {
+ toReturn = Class.forName(input.get("ImplClass").toString()).newInstance();
+ Method[] methods = toReturn.getClass().getMethods();
+ for (Method method : methods) {
+ if (input.containsKey(method.getName())) {
+ method.invoke(toReturn, input.get(method.getName()));
+ }
+ }
+ } catch (Exception exception) {
+ exception.printStackTrace();
}
- }
- } catch (Exception exception) {
- exception.printStackTrace();
- }
- return toReturn;
- }
+ return toReturn;
+ }
- @Override
- public Collection<String> getTenants() {
- return ConfigurationRepository.lookup().getTenants();
- }
+ @Override
+ public Collection<String> getTenants() {
+ return ConfigurationRepository.lookup().getTenants();
+ }
- @Override
- public Collection<String> getNamespaces() {
- return ConfigurationRepository.lookup().getNamespaces();
- }
+ @Override
+ public Collection<String> getNamespaces() {
+ return ConfigurationRepository.lookup().getNamespaces();
+ }
- private ArrayList<String> getInMemoryKeys(String tenant, String namespace) {
- ArrayList<String> keys = new ArrayList<>();
+ private ArrayList<String> getInMemoryKeys(String tenant, String namespace) {
+ ArrayList<String> keys = new ArrayList<>();
- try {
- Iterator<String> iter =
- ConfigurationRepository.lookup().getConfigurationFor(tenant, namespace).getKeys();
- while (iter.hasNext()) {
- String key = iter.next();
- if (!(key.equals(NAMESPACE_KEY) || key.equals(MODE_KEY)
- || key.equals(LOAD_ORDER_KEY))) {
- keys.add(key);
+ try {
+ Iterator<String> iter =
+ ConfigurationRepository.lookup().getConfigurationFor(tenant, namespace).getKeys();
+ while (iter.hasNext()) {
+ String key = iter.next();
+ if (!(key.equals(NAMESPACE_KEY) || key.equals(MODE_KEY)
+ || key.equals(LOAD_ORDER_KEY))) {
+ keys.add(key);
+ }
+ }
+ } catch (Exception exception) {
+ //do nothing
}
- }
- } catch (Exception exception) {
- //do nothing
- }
- return keys;
- }
+ return keys;
+ }
- @Override
- public Collection<String> getKeys(String tenant, String namespace) {
- Set<String> keyCollection = new HashSet<>();
- try {
- keyCollection.addAll(ConfigurationUtils.executeSelectSql(
- ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, DB_NAMESPACE)
- .getString("fetchkeysql"),
- new String[]{tenant + KEY_ELEMENTS_DELEMETER + DEFAULT_NAMESPACE}));
- keyCollection.addAll(ConfigurationUtils.executeSelectSql(
- ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, DB_NAMESPACE)
- .getString("fetchkeysql"),
- new String[]{tenant + KEY_ELEMENTS_DELEMETER + namespace}));
- keyCollection.addAll(ConfigurationUtils.executeSelectSql(
- ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, DB_NAMESPACE)
- .getString("fetchkeysql"),
- new String[]{DEFAULT_TENANT + KEY_ELEMENTS_DELEMETER + namespace}));
- keyCollection.addAll(ConfigurationUtils.executeSelectSql(
- ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, DB_NAMESPACE)
- .getString("fetchkeysql"),
- new String[]{DEFAULT_TENANT + KEY_ELEMENTS_DELEMETER + DEFAULT_NAMESPACE}));
- } catch (Exception exception) {
- exception.printStackTrace();
- keyCollection.addAll(getInMemoryKeys(tenant, DEFAULT_NAMESPACE));
- keyCollection.addAll(getInMemoryKeys(tenant, namespace));
- keyCollection.addAll(getInMemoryKeys(DEFAULT_TENANT, namespace));
- keyCollection.addAll(getInMemoryKeys(DEFAULT_TENANT, DEFAULT_NAMESPACE));
+ @Override
+ public Collection<String> getKeys(String tenant, String namespace) {
+ Set<String> keyCollection = new HashSet<>();
+ try {
+ keyCollection.addAll(ConfigurationUtils.executeSelectSql(
+ ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, DB_NAMESPACE)
+ .getString("fetchkeysql"),
+ new String[]{tenant + KEY_ELEMENTS_DELEMETER + DEFAULT_NAMESPACE}));
+ keyCollection.addAll(ConfigurationUtils.executeSelectSql(
+ ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, DB_NAMESPACE)
+ .getString("fetchkeysql"),
+ new String[]{tenant + KEY_ELEMENTS_DELEMETER + namespace}));
+ keyCollection.addAll(ConfigurationUtils.executeSelectSql(
+ ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, DB_NAMESPACE)
+ .getString("fetchkeysql"),
+ new String[]{DEFAULT_TENANT + KEY_ELEMENTS_DELEMETER + namespace}));
+ keyCollection.addAll(ConfigurationUtils.executeSelectSql(
+ ConfigurationRepository.lookup().getConfigurationFor(DEFAULT_TENANT, DB_NAMESPACE)
+ .getString("fetchkeysql"),
+ new String[]{DEFAULT_TENANT + KEY_ELEMENTS_DELEMETER + DEFAULT_NAMESPACE}));
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ keyCollection.addAll(getInMemoryKeys(tenant, DEFAULT_NAMESPACE));
+ keyCollection.addAll(getInMemoryKeys(tenant, namespace));
+ keyCollection.addAll(getInMemoryKeys(DEFAULT_TENANT, namespace));
+ keyCollection.addAll(getInMemoryKeys(DEFAULT_TENANT, DEFAULT_NAMESPACE));
+ }
+ return keyCollection;
}
- return keyCollection;
- }
}
diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationChangeNotifier.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationChangeNotifier.java
index a7c10caae9..015634b1cd 100644
--- a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationChangeNotifier.java
+++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationChangeNotifier.java
@@ -204,7 +204,7 @@ public final class ConfigurationChangeNotifier {
List<NotificationData> notificationList =
store.get(tenant + Constants.KEY_ELEMENTS_DELEMETER + component);
if (notificationList == null) {
- notificationList = Collections.synchronizedList(new ArrayList<NotificationData>());
+ notificationList = Collections.synchronizedList(new ArrayList<>());
store.put(tenant + Constants.KEY_ELEMENTS_DELEMETER + component, notificationList);
executor.scheduleWithFixedDelay(
() -> triggerScanning(tenant + Constants.KEY_ELEMENTS_DELEMETER + component), 1, 30000,
@@ -263,11 +263,11 @@ public final class ConfigurationChangeNotifier {
private Set<Path> watchForChange(String location) throws Exception {
if (location == null || location.trim().length() == 0) {
- return null;
+ return Collections.emptySet();
}
File file = new File(location);
if (!file.exists()) {
- return null;
+ return Collections.emptySet();
}
Path path = file.toPath();
Set<Path> toReturn = new HashSet<>();