summaryrefslogtreecommitdiffstats
path: root/policy-management
diff options
context:
space:
mode:
Diffstat (limited to 'policy-management')
-rw-r--r--policy-management/pom.xml5
-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
-rw-r--r--policy-management/src/main/server-gen/bin/telemetry.sh44
-rw-r--r--policy-management/src/main/server/config/logback.xml58
8 files changed, 122 insertions, 95 deletions
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 @@
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </dependency>
<dependency>
<groupId>junit</groupId>
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}
*/
diff --git a/policy-management/src/main/server-gen/bin/telemetry.sh b/policy-management/src/main/server-gen/bin/telemetry.sh
new file mode 100644
index 00000000..397c2508
--- /dev/null
+++ b/policy-management/src/main/server-gen/bin/telemetry.sh
@@ -0,0 +1,44 @@
+#! /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=========================================================
+##
+
+REST_TOOL="http-prompt"
+TELEMETRY_SPEC="${POLICY_HOME}/config/telemetry-spec.json"
+
+if ! type -p "${REST_TOOL}" > /dev/null 2>&1; then
+ echo "error: prerequisite software not found: http-prompt"
+ exit 1
+fi
+
+if ! "${POLICY_HOME}"/bin/policy-management-controller status > /dev/null 2>&1; then
+ echo "error: pdp-d is not running"
+ exit 2
+fi
+
+if [[ ! -r ${TELEMETRY_SPEC} ]]; then
+ echo "generating new spec .."
+ if ! http -a "${ENGINE_MANAGEMENT_USER}:${ENGINE_MANAGEMENT_PASSWORD}" :9696/swagger.json > ${TELEMETRY_SPEC} 2> /dev/null; then
+ echo "error: cannot generate telemetry spec"
+ exit 3
+ fi
+fi
+
+exec http-prompt http://localhost:9696/policy/pdp/engine --auth "${ENGINE_MANAGEMENT_USER}:${ENGINE_MANAGEMENT_PASSWORD}" --spec ${TELEMETRY_SPEC}
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 @@
<property name="logDir" value="logs" />
<property name="errorLog" value="error" />
- <property name="metricLog" value="metric" />
- <property name="auditLog" value="audit" />
<property name="debugLog" value="debug" />
<property name="networkLog" value="network" />
- <property name="metricPattern"
- value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
- <property name="auditPattern"
- 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{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
- <property name="errorPattern"
- 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" />
-
<property name="debugPattern" value="[%date|%level|%logger{0}|%thread] %msg%n" />
+ <property name="errorPattern" value="${debugPattern}" />
<property name="networkPattern" value="[%d|%t]%m%n" />
- <appender name="AuditOut" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDir}/${auditLog}.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDir}/${auditLog}.%i.log.zip</fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${auditPattern}</pattern>
- </encoder>
- </appender>
-
- <appender name="AsyncAuditOut" class="ch.qos.logback.classic.AsyncAppender">
- <appender-ref ref="AuditOut" />
- </appender>
-
- <appender name="MetricOut" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDir}/${metricLog}.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDir}/${metricLog}.%i.log.zip</fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${metricPattern}</pattern>
- </encoder>
- </appender>
-
- <appender name="AsyncMetricOut" class="ch.qos.logback.classic.AsyncAppender">
- <appender-ref ref="MetricOut" />
- </appender>
-
<appender name="ErrorOut" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logDir}/${errorLog}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${logDir}/${errorLog}.%i.log.zip</fileNamePattern>
<minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
+ <maxIndex>5</maxIndex>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
@@ -136,14 +90,6 @@
<appender name="AsyncNetworkOut" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="NetworkOut" />
</appender>
-
- <logger name="com.att.eelf.audit" level="INFO">
- <appender-ref ref="AsyncAuditOut" />
- </logger>
-
- <logger name="com.att.eelf.metrics" level="INFO">
- <appender-ref ref="AsyncMetricOut" />
- </logger>
<logger name="network" level="INFO" additivity="false">
<appender-ref ref="AsyncNetworkOut" />