diff options
author | Jorge Hernandez <jorge.hernandez-herrero@att.com> | 2019-02-28 10:10:49 -0600 |
---|---|---|
committer | Jorge Hernandez <jorge.hernandez-herrero@att.com> | 2019-03-01 09:56:11 -0600 |
commit | b001c1ac5a0b4d938a69adb47f4613f64dc71c1a (patch) | |
tree | a83c2887edc25fd4eb24f3f6d485e8f860069c19 /policy-management/src/main/java/org/onap/policy/drools/system | |
parent | 8e9ddde1bb1e3fc3f7b85af653d6251daf7e77d6 (diff) |
move all hard install config to environment vars
+ support multiple system properties files with variable interpolation
loaded at initialization
+ support of configurable JVM options (-X, etc ..).
+ rearrange aaf configuration to avoid {{}} installation variables
and use dynamic enviroment variables.
+ miscellaneous clean up in areas touched and checkstyle.
Change-Id: I71ad839778e17eb57c098a2c5cc2bf96e468669a
Issue-ID: POLICY-1524
Signed-off-by: Jorge Hernandez <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'policy-management/src/main/java/org/onap/policy/drools/system')
-rw-r--r-- | policy-management/src/main/java/org/onap/policy/drools/system/Main.java | 56 | ||||
-rw-r--r-- | policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java | 8 |
2 files changed, 21 insertions, 43 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/Main.java b/policy-management/src/main/java/org/onap/policy/drools/system/Main.java index 79268b2c..5ebd0490 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/system/Main.java +++ b/policy-management/src/main/java/org/onap/policy/drools/system/Main.java @@ -1,8 +1,8 @@ /*- * ============LICENSE_START======================================================= - * policy-management + * ONAP * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,10 @@ package org.onap.policy.drools.system; -import java.nio.file.Files; -import java.nio.file.Paths; import java.util.Properties; - import org.onap.policy.drools.persistence.SystemPersistence; import org.onap.policy.drools.properties.DroolsProperties; +import org.onap.policy.drools.utils.PropertyUtil; import org.onap.policy.drools.utils.logging.LoggerUtil; import org.onap.policy.drools.utils.logging.MDCTransaction; import org.slf4j.Logger; @@ -36,13 +34,6 @@ import org.slf4j.LoggerFactory; */ public class Main { - /** logback configuration file system property. */ - public static final String LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY = - "logback.configurationFile"; - - /** logback configuration file system property. */ - public static final String LOGBACK_CONFIGURATION_FILE_DEFAULT = "config/logback.xml"; - /** constructor (hides public default one). */ private Main() {} @@ -53,44 +44,27 @@ public class Main { */ public static void main(String[] args) { - /* logging defaults */ - - if (System.getProperty(LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY) == null) { - if (Files.exists(Paths.get(LOGBACK_CONFIGURATION_FILE_DEFAULT))) { - System.setProperty( - LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, LOGBACK_CONFIGURATION_FILE_DEFAULT); - } else { - LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, ch.qos.logback.classic.Level.INFO.toString()); - } - } - - /* make sure the default configuration directory is properly set up */ + /* start logger */ - SystemPersistence.manager.setConfigurationDir(null); + Logger logger = LoggerFactory.getLogger(Main.class); - /* logging defaults */ + /* system properties */ - if (System.getProperty(LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY) == null) { - if (Files.exists(Paths.get(LOGBACK_CONFIGURATION_FILE_DEFAULT))) { - System.setProperty( - LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, LOGBACK_CONFIGURATION_FILE_DEFAULT); - } else { - LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, ch.qos.logback.classic.Level.INFO.toString()); - } + for (Properties systemProperties : SystemPersistence.manager.getSystemProperties()) { + PropertyUtil.setSystemProperties(systemProperties); } /* 0. boot */ PolicyEngine.manager.boot(args); - /* start logger */ + /* 1.a. Configure Engine */ - final Logger logger = LoggerFactory.getLogger(Main.class); - - /* 1.a. Configure the Engine */ - - Properties engineProperties = SystemPersistence.manager.getEngineProperties(); - if (engineProperties == null) { + Properties engineProperties; + try { + engineProperties = SystemPersistence.manager.getEngineProperties(); + } catch (IllegalArgumentException iae) { + logger.warn("Main: engine properties not found. Using default configuration.", iae); engineProperties = PolicyEngine.manager.defaultTelemetryConfig(); } @@ -98,7 +72,7 @@ public class Main { /* 1.b. Load Installation Environment(s) */ - for (final Properties env : SystemPersistence.manager.getEnvironmentProperties()) { + for (Properties env : SystemPersistence.manager.getEnvironmentProperties()) { PolicyEngine.manager.setEnvironment(env); } diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java index 959114a2..bedd8d48 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java +++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java @@ -54,6 +54,7 @@ import org.onap.policy.drools.protocol.configuration.ControllerConfiguration; import org.onap.policy.drools.protocol.configuration.PdpdConfiguration; import org.onap.policy.drools.server.restful.RestManager; import org.onap.policy.drools.server.restful.aaf.AafTelemetryAuthFilter; +import org.onap.policy.drools.utils.PropertyUtil; import org.onap.policy.drools.utils.logging.LoggerUtil; import org.onap.policy.drools.utils.logging.MDCTransaction; import org.slf4j.Logger; @@ -429,7 +430,7 @@ class PolicyEngineManager implements PolicyEngine { @Override public synchronized void setEnvironment(Properties properties) { - this.environment.putAll(properties); + this.environment.putAll(PropertyUtil.getInterpolatedProperties(properties)); } @JsonIgnore @@ -443,7 +444,10 @@ class PolicyEngineManager implements PolicyEngine { public synchronized String getEnvironmentProperty(String envKey) { String value = this.environment.getProperty(envKey); if (value == null) { - value = System.getenv(envKey); + value = System.getProperty(envKey); + if (value == null) { + value = System.getenv(envKey); + } } return value; } |