diff options
Diffstat (limited to 'policy-management/src/main/java')
5 files changed, 71 insertions, 39 deletions
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java b/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java index 06d2aaf7..bc577649 100644 --- a/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java +++ b/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java @@ -521,8 +521,8 @@ public class MavenDroolsController implements DroolsController { topic, event); } catch (UnsupportedOperationException uoe) { - logger.info("{}: DECODE FAILED: {} <- {} because of {}", this, topic, - event, uoe.getMessage(), uoe); + logger.debug("{}: DECODE FAILED: {} <- {} because of {}", this, topic, + event, uoe.getMessage(), uoe); return true; } catch (Exception e) { logger.warn("{}: DECODE FAILED: {} <- {} because of {}", this, topic, diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/features/PolicyEngineFeatureAPI.java b/policy-management/src/main/java/org/openecomp/policy/drools/features/PolicyEngineFeatureAPI.java index 30e3a14c..df2ddd6f 100644 --- a/policy-management/src/main/java/org/openecomp/policy/drools/features/PolicyEngineFeatureAPI.java +++ b/policy-management/src/main/java/org/openecomp/policy/drools/features/PolicyEngineFeatureAPI.java @@ -33,6 +33,24 @@ import org.openecomp.policy.drools.utils.OrderedServiceImpl; public interface PolicyEngineFeatureAPI extends OrderedService { /** + * intercept before the Policy Engine is commanded to boot. + * + * @return true if this feature intercepts and takes ownership + * of the operation preventing the invocation of + * lower priority features. False, otherwise. + */ + public default boolean beforeBoot(PolicyEngine engine, String cliArgs[]) {return false;}; + + /** + * intercept after the Policy Engine is booted. + * + * @return true if this feature intercepts and takes ownership + * of the operation preventing the invocation of + * lower priority features. False, otherwise. + */ + public default boolean afterBoot(PolicyEngine engine) {return false;}; + + /** * intercept before the Policy Engine is configured. * * @return true if this feature intercepts and takes ownership @@ -180,5 +198,5 @@ public interface PolicyEngineFeatureAPI extends OrderedService { * Feature providers implementing this interface */ public static final OrderedServiceImpl<PolicyEngineFeatureAPI> providers = - new OrderedServiceImpl<PolicyEngineFeatureAPI>(PolicyEngineFeatureAPI.class); + new OrderedServiceImpl<>(PolicyEngineFeatureAPI.class); } diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/EventProtocolCoder.java b/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/EventProtocolCoder.java index 1030186b..819ee812 100644 --- a/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/EventProtocolCoder.java +++ b/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/EventProtocolCoder.java @@ -937,7 +937,7 @@ abstract class GenericEventProtocolCoder { if (event != null) return event; } catch (Exception e) { - logger.info("{}, cannot decode {}", this, json, e); + logger.debug("{}, cannot decode {}", this, json, e); } if (multipleToolsetRetries) { diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/system/Main.java b/policy-management/src/main/java/org/openecomp/policy/drools/system/Main.java index 3b12514c..1bb9a320 100644 --- a/policy-management/src/main/java/org/openecomp/policy/drools/system/Main.java +++ b/policy-management/src/main/java/org/openecomp/policy/drools/system/Main.java @@ -25,11 +25,10 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Properties; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.openecomp.policy.drools.core.PolicyContainer; import org.openecomp.policy.drools.persistence.SystemPersistence; import org.openecomp.policy.drools.utils.PropertyUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Programmatic entry point to the management layer @@ -47,25 +46,9 @@ public class Main { public static final String LOGBACK_CONFIGURATION_FILE_DEFAULT = "config/logback.xml"; /** - * EELF logback configuration path system property - */ - public static final String EELF_LOGBACK_PATH_SYSTEM_PROPERTY = "com.att.eelf.logging.file"; - - /** - * EELF logback configuration path value - */ - public static final String EELF_LOGBACK_PATH_DEFAULT = "config"; - - /** - * EELF logback configuration file system property + * constructor (hides public default one) */ - public static final String EELF_LOGBACK_FILE_SYSTEM_PROPERTY = "com.att.eelf.logging.path"; - - /** - * EELF logback configuration file default value - */ - public static final String EELF_LOGBACK_FILE_DEFAULT = "logback.xml"; - + private Main() {} /** * main @@ -79,11 +62,9 @@ public class Main { if (System.getProperty(LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY) == null) System.setProperty(LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, LOGBACK_CONFIGURATION_FILE_DEFAULT); - if (System.getProperty(EELF_LOGBACK_PATH_SYSTEM_PROPERTY) == null) - System.setProperty(EELF_LOGBACK_PATH_SYSTEM_PROPERTY, EELF_LOGBACK_PATH_DEFAULT); + /* 0. boot */ - if (System.getProperty(EELF_LOGBACK_FILE_SYSTEM_PROPERTY) == null) - System.setProperty(EELF_LOGBACK_FILE_SYSTEM_PROPERTY, EELF_LOGBACK_FILE_DEFAULT); + PolicyEngine.manager.boot(args); Logger logger = LoggerFactory.getLogger(Main.class); @@ -95,15 +76,6 @@ public class Main { " not found"); } - - /* 0. Start the CORE layer first */ - - try { - PolicyContainer.globalInit(args); - } catch (Exception e) { - logger.warn("Main: cannot init policy-container because of {}", e.getMessage(), e); - } - /* 1. Configure the Engine */ try { diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java index 974a7260..633d2379 100644 --- a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java +++ b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java @@ -27,6 +27,7 @@ import java.util.Properties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.openecomp.policy.drools.controller.DroolsController; +import org.openecomp.policy.drools.core.PolicyContainer; import org.openecomp.policy.drools.core.jmx.PdpJmxListener; import org.openecomp.policy.drools.event.comm.Topic; import org.openecomp.policy.drools.event.comm.Topic.CommInfrastructure; @@ -83,6 +84,13 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener { public static final String CONFIG_SERVER_DEFAULT_HOST = "localhost"; /** + * Boot the engine + * + * @param cliArgs command line arguments + */ + public void boot(String cliArgs[]); + + /** * configure the policy engine according to the given properties * * @param properties Policy Engine properties @@ -318,7 +326,7 @@ class PolicyEngineManager implements PolicyEngine { /** * logger */ - private static Logger logger = LoggerFactory.getLogger(PolicyEngineManager.class); + private static Logger logger = LoggerFactory.getLogger(PolicyEngineManager.class); /** * Is the Policy Engine running? @@ -355,6 +363,40 @@ class PolicyEngineManager implements PolicyEngine { */ protected Gson decoder = new GsonBuilder().disableHtmlEscaping().create(); + + /** + * {@inheritDoc} + */ + @Override + public synchronized void boot(String cliArgs[]) { + + for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) { + try { + if (feature.beforeBoot(this, cliArgs)) + return; + } catch (Exception e) { + logger.error("{}: feature {} before-boot failure because of {}", + this, feature.getClass().getName(), e.getMessage(), e); + } + } + + try { + PolicyContainer.globalInit(cliArgs); + } catch (Exception e) { + logger.error("{}: cannot init policy-container because of {}", this, e.getMessage(), e); + } + + for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) { + try { + if (feature.afterBoot(this)) + return; + } catch (Exception e) { + logger.error("{}: feature {} after-boot failure because of {}", + this, feature.getClass().getName(), e.getMessage(), e); + } + } + } + /** * {@inheritDoc} */ |