From: Jorge Hernandez Date: Mon, 26 Jun 2017 13:05:30 +0000 (-0500) Subject: [POLICY-30] optional loadable eelf feature X-Git-Tag: v1.1.0~86 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=9e69cc20f40f8ec89aa8a1487c2f6b3e687ded40;p=policy%2Fdrools-pdp.git [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 --- diff --git a/feature-eelf/pom.xml b/feature-eelf/pom.xml new file mode 100644 index 00000000..3138c8d3 --- /dev/null +++ b/feature-eelf/pom.xml @@ -0,0 +1,125 @@ + + + + + 4.0.0 + + + org.openecomp.policy.drools-pdp + drools-pdp + 1.1.0-SNAPSHOT + + + feature-eelf + + feature-eelf + Loadable module that uses EELF and common module logging infrastructure + + + 1.8 + 1.8 + + + + + + maven-assembly-plugin + 2.6 + + + zipfile + + single + + package + + true + ${project.artifactId}-${project.version} + + src/assembly/assemble_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/lib + false + true + true + false + false + false + runtime + provided + true + + + + + + + + + + ch.qos.logback + logback-classic + test + + + com.att.eelf + eelf-core + 1.0.0 + + + org.openecomp.policy.common + ECOMP-Logging + ${common-modules.version} + + + org.openecomp.policy.drools-pdp + policy-management + ${project.version} + provided + + + junit + junit + 4.12 + test + + + + diff --git a/feature-eelf/src/assembly/assemble_zip.xml b/feature-eelf/src/assembly/assemble_zip.xml new file mode 100644 index 00000000..001d3c66 --- /dev/null +++ b/feature-eelf/src/assembly/assemble_zip.xml @@ -0,0 +1,67 @@ + + + + + + + feature-eelf-package + + zip + + + false + + + + target + lib/opt + + feature-eelf-${project.version}.jar + + + + target/assembly/ + . + + + + . + lib + + *.jar + + + + src/main/install/config + config + + + src/main/install/bin + bin + 0744 + + + + + diff --git a/feature-eelf/src/main/install/config/logback.xml b/feature-eelf/src/main/install/config/logback.xml new file mode 100644 index 00000000..f4295628 --- /dev/null +++ b/feature-eelf/src/main/install/config/logback.xml @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + ${defaultPattern} + + + + + ${logDirectory}/${auditLogName}.log + + ${logDirectory}/${auditLogName}.%i.log.zip + + 1 + 5 + + + 10MB + + + ${defaultAuditPattern} + + + + + + + + + ${logDirectory}/${metricsLogName}.log + + ${logDirectory}/${metricsLogName}.%i.log.zip + + 1 + 5 + + + 15MB + + + ${defaultMetricPattern} + + + + + + + + + + ${logDirectory}/${errorLogName}.log + + ${logDirectory}/${errorLogName}.%i.log.zip + + 1 + 5 + + + ERROR + + + 20MB + + + ${defaultErrorPattern} + + + + + + + + + ${debugLogDirectory}/${debugLogName}.log + + ${debugLogDirectory}/${debugLogName}.%i.log.zip + + 1 + 5 + + + 20MB + + + ${debugPattern} + + + + + + + + + ${logDirectory}/${networkLogName}.log + + logs/network.log.%i.zip + 1 + 5 + + + 15MB + + + ${networkPattern} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/feature-eelf/src/main/install/config/policyLogger.properties b/feature-eelf/src/main/install/config/policyLogger.properties new file mode 100644 index 00000000..d8987252 --- /dev/null +++ b/feature-eelf/src/main/install/config/policyLogger.properties @@ -0,0 +1,49 @@ +### +# ============LICENSE_START======================================================= +# feature-eelf +# ================================================================================ +# Copyright (C) 2017 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +################################### Set concurrentHashMap and timer info ####################### +#Timer initial delay and the delay between in milliseconds before task is to be execute. +timer.delay.time=1000 +#Timer scheduleAtFixedRate period - time in milliseconds between successive task executions. +check.interval= 30000 +#Longest time an event info can be stored in the concurrentHashMap for logging - in seconds. +event.expired.time=86400 +#Size of the concurrentHashMap which stores the event starting time, etc - when its size reaches this limit, the Timer gets executed +#to remove all expired records from this concurrentHashMap. +concurrentHashMap.limit=5000 +#Size of the concurrentHashMap - when its size drops to this point, stop the Timer +stop.check.point=2500 +################################### Set logging format ############################################# +# set EELF for EELF logging format, set LOG4J for using log4j, set SYSTEMOUT for using system.out.println +logger.type=EELF +#################################### Set level for EELF or SYSTEMOUT logging ################################## +# Set level for debug file. Set DEBUG to enable .info, .warn and .debug; set INFO for enable .info and .warn; set OFF to disable all +# Set override flag. Set TRUE for override the level setups in logback.xml. Set FALSE for using the level setups of logback.xml +override.logback.level.setup=FALSE +debugLogger.level=INFO +# Set level for metrics file. Set OFF to disable; set ON to enable +metricsLogger.level=ON +# Set level for error file. Set OFF to disable; set ON to enable +error.level=ON +# Set level for audit file. Set OFF to disable; set ON to enable +audit.level=ON +#################################### Set Policy Component ################################## +# Set DROOLS for drools PDP. Set XACML to xacml PDP +policy.component=DROOLS diff --git a/feature-eelf/src/main/java/org/openecomp/policy/drools/eelf/EelfFeature.java b/feature-eelf/src/main/java/org/openecomp/policy/drools/eelf/EelfFeature.java new file mode 100644 index 00000000..de39f3a3 --- /dev/null +++ b/feature-eelf/src/main/java/org/openecomp/policy/drools/eelf/EelfFeature.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * feature-eelf + * ================================================================================ + * Copyright (C) 2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.drools.eelf; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.openecomp.policy.common.logging.flexlogger.FlexLogger; +import org.openecomp.policy.common.logging.flexlogger.Logger; +import org.openecomp.policy.drools.features.PolicyEngineFeatureAPI; +import org.openecomp.policy.drools.system.Main; +import org.openecomp.policy.drools.system.PolicyEngine; + +public class EelfFeature implements PolicyEngineFeatureAPI { + + /** + * 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 + */ + 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"; + + @Override + public boolean beforeBoot(PolicyEngine engine, String cliArgs[]) { + + String logback = System.getProperty(Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, + Main.LOGBACK_CONFIGURATION_FILE_DEFAULT); + + Path logbackPath = Paths.get(logback); + + if (System.getProperty(EELF_LOGBACK_PATH_SYSTEM_PROPERTY) == null) + System.setProperty(EELF_LOGBACK_PATH_SYSTEM_PROPERTY, logbackPath.getFileName().toString()); + + if (System.getProperty(EELF_LOGBACK_FILE_SYSTEM_PROPERTY) == null) + System.setProperty(EELF_LOGBACK_FILE_SYSTEM_PROPERTY, + logbackPath.toAbsolutePath().getParent().toString()); + + Logger logger = FlexLogger.getLogger(this.getClass(), true); + + logger.warn("EELF/Common Frameworks Logging Enabled"); + if (logger.isInfoEnabled()) { + logger.info("EELFFeature: Property " + Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY + "=" + + System.getProperty(Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY)); + logger.info("EELFFeature: Property " + EELF_LOGBACK_PATH_SYSTEM_PROPERTY + "=" + + System.getProperty(EELF_LOGBACK_PATH_SYSTEM_PROPERTY)); + logger.info("EELFFeature: Property " + EELF_LOGBACK_FILE_SYSTEM_PROPERTY + "=" + + System.getProperty(EELF_LOGBACK_FILE_SYSTEM_PROPERTY)); + } + + return false; + }; + + @Override + public int getSequenceNumber() { + return 0; + } + +} diff --git a/feature-eelf/src/main/resources/META-INF/services/org.openecomp.policy.drools.features.PolicyEngineFeatureAPI b/feature-eelf/src/main/resources/META-INF/services/org.openecomp.policy.drools.features.PolicyEngineFeatureAPI new file mode 100644 index 00000000..70d1bb8e --- /dev/null +++ b/feature-eelf/src/main/resources/META-INF/services/org.openecomp.policy.drools.features.PolicyEngineFeatureAPI @@ -0,0 +1 @@ +org.openecomp.policy.drools.eelf.EelfFeature diff --git a/feature-eelf/src/test/java/org/openecomp/policy/drools/eelf/test/EElfTest.java b/feature-eelf/src/test/java/org/openecomp/policy/drools/eelf/test/EElfTest.java new file mode 100644 index 00000000..2ded0d0d --- /dev/null +++ b/feature-eelf/src/test/java/org/openecomp/policy/drools/eelf/test/EElfTest.java @@ -0,0 +1,138 @@ +/*- + * ============LICENSE_START======================================================= + * feature-eelf + * ================================================================================ + * Copyright (C) 2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.policy.drools.eelf.test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.openecomp.policy.common.logging.flexlogger.FlexLogger; +import org.openecomp.policy.drools.eelf.EelfFeature; +import org.openecomp.policy.drools.system.Main; +import org.openecomp.policy.drools.system.PolicyEngine; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.att.eelf.configuration.Configuration; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFLogger.Level; +import com.att.eelf.configuration.EELFManager; + +import ch.qos.logback.classic.LoggerContext; + +/** + * Logger Tests + */ +public class EElfTest { + + /** + * logback configuration location + */ + public final static String LOGBACK_CONFIGURATION_FILE_DEFAULT = "src/main/install/config/logback.xml"; + + /** + * SLF4J Logger + */ + private final Logger slf4jLogger = LoggerFactory.getLogger(EElfTest.class); + + /** + * get all loggers + * @return list of all loggers + */ + protected List loggers() { + List loggers = new ArrayList(); + LoggerContext context = + (LoggerContext) org.slf4j.LoggerFactory.getILoggerFactory(); + for (org.slf4j.Logger logger: context.getLoggerList()) { + loggers.add(logger.getName()); + } + slf4jLogger.info(loggers.toString()); + return loggers; + } + + /** + * Assert Log Levels are the same between an EELF Logger and an SLF4J Logger + * + * @param eelfAuditLogger + * @param slf4jAuditLogger + */ + protected void assertLogLevels(EELFLogger eelfAuditLogger, Logger slf4jAuditLogger) { + assertTrue(slf4jAuditLogger.isDebugEnabled() == eelfAuditLogger.isDebugEnabled()); + assertTrue(slf4jAuditLogger.isInfoEnabled() == eelfAuditLogger.isInfoEnabled()); + assertTrue(slf4jAuditLogger.isErrorEnabled() == eelfAuditLogger.isErrorEnabled()); + assertTrue(slf4jAuditLogger.isWarnEnabled() == eelfAuditLogger.isWarnEnabled()); + assertTrue(slf4jAuditLogger.isTraceEnabled() == eelfAuditLogger.isTraceEnabled()); + } + + @Test + public void slf4jLog() { + + /* standard slf4j using defaults */ + + slf4jLogger.info("slf4j info"); + + List loggers = loggers(); + + assertFalse(loggers.contains(Configuration.DEBUG_LOGGER_NAME)); + assertFalse(loggers.contains(Configuration.AUDIT_LOGGER_NAME)); + assertFalse(loggers.contains(Configuration.ERROR_LOGGER_NAME)); + assertFalse(loggers.contains(Configuration.METRICS_LOGGER_NAME)); + + /* set logback configuration */ + + System.setProperty(Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, + LOGBACK_CONFIGURATION_FILE_DEFAULT); + + /* set up eelf throuth common loggings library */ + + EelfFeature feature = new EelfFeature(); + feature.beforeBoot(PolicyEngine.manager, null); + + loggers = loggers(); + assertTrue(loggers.contains(Configuration.DEBUG_LOGGER_NAME)); + assertTrue(loggers.contains(Configuration.AUDIT_LOGGER_NAME)); + assertTrue(loggers.contains(Configuration.ERROR_LOGGER_NAME)); + assertTrue(loggers.contains(Configuration.METRICS_LOGGER_NAME)); + + EELFLogger eelfAuditLogger = EELFManager.getInstance().getAuditLogger(); + Logger slf4jAuditLogger = org.slf4j.LoggerFactory.getLogger(Configuration.AUDIT_LOGGER_NAME); + org.openecomp.policy.common.logging.flexlogger.Logger flexLogger = + FlexLogger.getLogger(EElfTest.class); + + /* generate an audit entry through both logs */ + + flexLogger.audit("flexlogger audit"); + eelfAuditLogger.info("eelf audit"); + slf4jAuditLogger.info("slf4j audit"); + + /* check log levels in eelf and standard slf4j change in both directions */ + + /* eelf initiated */ + eelfAuditLogger.setLevel(Level.ERROR); + assertLogLevels(eelfAuditLogger, slf4jAuditLogger); + + /* slf4j initiated */ + ((ch.qos.logback.classic.Logger) slf4jLogger).setLevel((ch.qos.logback.classic.Level.INFO)); + assertLogLevels(eelfAuditLogger, slf4jAuditLogger); + } +} diff --git a/packages/install/pom.xml b/packages/install/pom.xml index 60da88a4..4f9b6cec 100644 --- a/packages/install/pom.xml +++ b/packages/install/pom.xml @@ -77,6 +77,12 @@ ${project.version} zip + + org.openecomp.policy.drools-pdp + feature-eelf + ${project.version} + zip + diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/client/internal/JerseyClient.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/client/internal/JerseyClient.java index f041b079..6cbabb2c 100644 --- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/client/internal/JerseyClient.java +++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/client/internal/JerseyClient.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * policy-healthcheck + * policy-endpoints * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ diff --git a/policy-management/pom.xml b/policy-management/pom.xml index 3ca8bc22..e7d83851 100644 --- a/policy-management/pom.xml +++ b/policy-management/pom.xml @@ -242,6 +242,11 @@ commons-lang3 3.4 + + + ch.qos.logback + logback-classic + junit 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 @@ -32,6 +32,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. * @@ -180,5 +198,5 @@ public interface PolicyEngineFeatureAPI extends OrderedService { * Feature providers implementing this interface */ public static final OrderedServiceImpl providers = - new OrderedServiceImpl(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; @@ -82,6 +83,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 * @@ -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} */ diff --git a/packages/base/src/files/bin/telemetry.sh b/policy-management/src/main/server-gen/bin/telemetry.sh similarity index 100% rename from packages/base/src/files/bin/telemetry.sh rename to policy-management/src/main/server-gen/bin/telemetry.sh diff --git a/policy-management/src/main/server/config/logback.xml b/policy-management/src/main/server/config/logback.xml index 58092cc2..53d73434 100644 --- a/policy-management/src/main/server/config/logback.xml +++ b/policy-management/src/main/server/config/logback.xml @@ -23,65 +23,19 @@ - - - - - - + - - ${logDir}/${auditLog}.log - - ${logDir}/${auditLog}.%i.log.zip - 1 - 9 - - - 5MB - - - ${auditPattern} - - - - - - - - - ${logDir}/${metricLog}.log - - ${logDir}/${metricLog}.%i.log.zip - 1 - 9 - - - 5MB - - - ${metricPattern} - - - - - - - ${logDir}/${errorLog}.log ${logDir}/${errorLog}.%i.log.zip 1 - 9 + 5 WARN @@ -136,14 +90,6 @@ - - - - - - - - diff --git a/pom.xml b/pom.xml index 7edfc1ee..30a0cdcf 100644 --- a/pom.xml +++ b/pom.xml @@ -65,6 +65,7 @@ policy-endpoints policy-management policy-healthcheck + feature-eelf packages