diff options
author | Jorge Hernandez <jh1730@att.com> | 2017-07-18 01:06:39 -0500 |
---|---|---|
committer | Jorge Hernandez <jh1730@att.com> | 2017-07-18 09:18:43 -0500 |
commit | ae4a935b835c0dc588c7a53aef846dd6506b732f (patch) | |
tree | ce2371f6dde3ed453fc0db0affa00038b51ae242 /feature-eelf/src/main | |
parent | 8ce73e2fca0fdadd23e3557108742514af1205c3 (diff) |
[POLICY-66] self-contained features support
installation/enable/disable of self contained package features:
Feature 3rd party dependencies, configuration files, and
custom installation scripts do not need to be packaged within the policy
core base to be used.
Change-Id: I35a472e63bd0f9f7aa6cd0c112d41d2b4604a892
Signed-off-by: Jorge Hernandez <jh1730@att.com>
Diffstat (limited to 'feature-eelf/src/main')
-rw-r--r-- | feature-eelf/src/main/feature/config/logback-eelf.xml (renamed from feature-eelf/src/main/install/config/logback.xml) | 9 | ||||
-rw-r--r-- | feature-eelf/src/main/feature/install/disable | 33 | ||||
-rw-r--r-- | feature-eelf/src/main/feature/install/enable | 35 | ||||
-rw-r--r-- | feature-eelf/src/main/install/config/policyLogger.properties | 49 | ||||
-rw-r--r-- | feature-eelf/src/main/java/org/openecomp/policy/drools/eelf/EelfFeature.java | 51 |
5 files changed, 90 insertions, 87 deletions
diff --git a/feature-eelf/src/main/install/config/logback.xml b/feature-eelf/src/main/feature/config/logback-eelf.xml index f4295628..7c2725d8 100644 --- a/feature-eelf/src/main/install/config/logback.xml +++ b/feature-eelf/src/main/feature/config/logback-eelf.xml @@ -18,7 +18,7 @@ ============LICENSE_END========================================================= --> -<configuration scan="true" scanPeriod="30 seconds" debug="false"> +<configuration scan="true" scanPeriod="60 seconds" debug="false"> <property name="errorLogName" value="error" /> <property name="metricsLogName" value="metrics" /> @@ -33,9 +33,10 @@ <property name="defaultAuditPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" /> <property name="defaultErrorPattern" - value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%X{RequestId}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{ErrorCategory}|%X{ErrorCode}|%X{ErrorDesciption}|%msg%n" /> + value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%X{RequestId}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{ErrorCategory}|%X{ErrorCode}|%X{ErrorDesciption}|%msg%replace(%xException){'\n',' - '}%nopex%n" /> + <property name="networkPattern" value="[%d|%t]%m%n" /> - <property name="debugPattern" value="[%date|%level|%logger{0}|%thread] %msg%n" /> + <property name="debugPattern" value="[%date|%level|%logger{0}|%thread] %replace(%msg){'\n', ' '}%n" /> <property name="logDirectory" value="logs/Policy" /> <property name="debugLogDirectory" value="logs/Policy" /> @@ -169,7 +170,7 @@ <appender-ref ref="asyncEELFError" /> </logger> - <logger name="com.att.eelf.debug" level="info" additivity="false"> + <logger name="com.att.eelf.debug" level="info"> <appender-ref ref="asyncEELFDebug" /> </logger> diff --git a/feature-eelf/src/main/feature/install/disable b/feature-eelf/src/main/feature/install/disable new file mode 100644 index 00000000..1eeb090e --- /dev/null +++ b/feature-eelf/src/main/feature/install/disable @@ -0,0 +1,33 @@ +#! /bin/bash + +### +# ============LICENSE_START======================================================= +# ONAP POLICY +# ================================================================================ +# 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========================================================= +## + +if [[ "${DEBUG}" == "y" ]]; then + set -x +fi + +SYSTEM_PROPS="${POLICY_HOME}"/config/system.properties + +if [[ -f ${SYSTEM_PROPS} && -r ${SYSTEM_PROPS} ]]; then + if grep -q "^logback.configurationFile=.*$" "${SYSTEM_PROPS}"; then + sed -i -e "s|^logback.configurationFile=.*$|logback.configurationFile=config/logback.xml|" "${SYSTEM_PROPS}" + fi +fi
\ No newline at end of file diff --git a/feature-eelf/src/main/feature/install/enable b/feature-eelf/src/main/feature/install/enable new file mode 100644 index 00000000..55a2b99a --- /dev/null +++ b/feature-eelf/src/main/feature/install/enable @@ -0,0 +1,35 @@ +#! /bin/bash + +### +# ============LICENSE_START======================================================= +# ONAP POLICY +# ================================================================================ +# 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========================================================= +## + +if [[ "${DEBUG}" == "y" ]]; then + set -x +fi + +SYSTEM_PROPS="${POLICY_HOME}"/config/system.properties + +if [[ -f ${SYSTEM_PROPS} && -r ${SYSTEM_PROPS} ]]; then + if grep -q "^logback.configurationFile=.*$" "${SYSTEM_PROPS}"; then + sed -i -e "s|^logback.configurationFile=.*$|logback.configurationFile=config/logback-eelf.xml|" "${SYSTEM_PROPS}" + else + echo "logback.configurationFile=config/logback-eelf.xml" >> "${SYSTEM_PROPS}" + fi +fi
\ No newline at end of file diff --git a/feature-eelf/src/main/install/config/policyLogger.properties b/feature-eelf/src/main/install/config/policyLogger.properties deleted file mode 100644 index d8987252..00000000 --- a/feature-eelf/src/main/install/config/policyLogger.properties +++ /dev/null @@ -1,49 +0,0 @@ -### -# ============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 index de39f3a3..83e7a4be 100644 --- 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 @@ -23,63 +23,46 @@ package org.openecomp.policy.drools.eelf; import java.nio.file.Path; import java.nio.file.Paths; +import org.openecomp.policy.common.logging.eelf.Configuration; 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; +/** + * Feature EELF : Enables EELF Logging Libraries + */ 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); - + 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, + if (System.getProperty(Configuration.PROPERTY_LOGGING_FILE_PATH) == null) + System.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, logbackPath.toAbsolutePath().getParent().toString()); + if (System.getProperty(Configuration.PROPERTY_LOGGING_FILE_NAME) == null) + System.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, + logbackPath.getFileName().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 + "=" + + logger.info("eelf-feature: 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)); + logger.info("eelf-feature: Property " + Configuration.PROPERTY_LOGGING_FILE_PATH + "=" + + System.getProperty(Configuration.PROPERTY_LOGGING_FILE_PATH)); + logger.info("eelf-feature: Property " + Configuration.PROPERTY_LOGGING_FILE_NAME + "=" + + System.getProperty(Configuration.PROPERTY_LOGGING_FILE_NAME)); } return false; - }; + } @Override public int getSequenceNumber() { |