summaryrefslogtreecommitdiffstats
path: root/policy-management/src/main/java/org
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-06-26 08:05:30 -0500
committerJorge Hernandez <jh1730@att.com>2017-06-26 08:16:10 -0500
commit9e69cc20f40f8ec89aa8a1487c2f6b3e687ded40 (patch)
treeb8851c6243f09575132e4a1a99bc0ad5233c4263 /policy-management/src/main/java/org
parentb61e46ab34a649b29f788e9e0e0db3fb018b6fcd (diff)
[POLICY-30] optional loadable eelf feature
for backwards compatibility purposes or if desired to use EELF and common-framework (from policy-common) for logging purposes in miscellaneous environments. It supports EELF/Common Framework style logging at the same time than traditional logging. This functionality is an optional loadable module. policy-docker changes need to be made to optionally unpack to make it active (in a different submission). started marking feature projects with feature prefix in project name to give a clear picture to the community which modules are features vs. code base. Change-Id: I5076c462409f03415ce54f0c9b5f50b78abb18f9 Signed-off-by: Jorge Hernandez <jh1730@att.com>
Diffstat (limited to 'policy-management/src/main/java/org')
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java4
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/features/PolicyEngineFeatureAPI.java20
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/EventProtocolCoder.java2
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/system/Main.java40
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java44
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}
*/