summaryrefslogtreecommitdiffstats
path: root/policy-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'policy-core/src')
-rw-r--r--policy-core/src/main/java/org/openecomp/policy/drools/core/PolicyContainer.java32
-rw-r--r--policy-core/src/main/java/org/openecomp/policy/drools/core/PolicySession.java141
-rw-r--r--policy-core/src/main/java/org/openecomp/policy/drools/core/PolicySessionFeatureAPI.java (renamed from policy-core/src/main/java/org/openecomp/policy/drools/core/FeatureAPI.java)65
-rw-r--r--policy-core/src/main/java/org/openecomp/policy/drools/properties/PolicyProperties.java17
4 files changed, 131 insertions, 124 deletions
diff --git a/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicyContainer.java b/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicyContainer.java
index ae7cd622..d47ed617 100644
--- a/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicyContainer.java
+++ b/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicyContainer.java
@@ -22,42 +22,26 @@ package org.openecomp.policy.drools.core;
import java.io.IOException;
import java.util.Collection;
-import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-
-import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.kie.api.KieBase;
import org.kie.api.KieServices;
import org.kie.api.builder.KieScanner;
import org.kie.api.builder.Message;
import org.kie.api.builder.ReleaseId;
import org.kie.api.builder.Results;
-import org.kie.api.runtime.Environment;
-import org.kie.api.runtime.EnvironmentName;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
-import org.kie.api.runtime.KieSessionConfiguration;
-
-import bitronix.tm.Configuration;
-import bitronix.tm.TransactionManagerServices;
-import bitronix.tm.resource.jdbc.PoolingDataSource;
-
-import org.openecomp.policy.common.ia.IntegrityAudit;
-import org.openecomp.policy.common.ia.IntegrityAuditProperties;
-import org.openecomp.policy.drools.properties.Startable;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.common.logging.eelf.MessageCodes;
import org.openecomp.policy.common.logging.eelf.PolicyLogger;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.common.logging.flexlogger.PropertyUtil;
+import org.openecomp.policy.drools.properties.Startable;
/**
* This class is a wrapper around 'KieContainer', which adds the ability
@@ -296,7 +280,7 @@ public class PolicyContainer implements Startable
// loop through all of the features, and give each one
// a chance to create the 'KieSession'
- for (FeatureAPI feature : FeatureAPI.impl.getList())
+ for (PolicySessionFeatureAPI feature : PolicySessionFeatureAPI.impl.getList())
{
if ((kieSession = feature.activatePolicySession
(this, name, kieBaseName)) != null)
@@ -453,7 +437,7 @@ public class PolicyContainer implements Startable
// KLUDGE WARNING: this is a temporary workaround -- if there are
// no features, we don't have persistence, and 'activate' is never
// called. In this case, make sure the container is started.
- if (FeatureAPI.impl.getList().size() == 0)
+ if (PolicySessionFeatureAPI.impl.getList().size() == 0)
{
start();
}
@@ -606,7 +590,7 @@ public class PolicyContainer implements Startable
session.getKieSession().dispose();
// notify features
- for (FeatureAPI feature : FeatureAPI.impl.getList())
+ for (PolicySessionFeatureAPI feature : PolicySessionFeatureAPI.impl.getList())
{
feature.disposeKieSession(session);
}
@@ -673,7 +657,7 @@ public class PolicyContainer implements Startable
session.getKieSession().destroy();
// notify features
- for (FeatureAPI feature : FeatureAPI.impl.getList())
+ for (PolicySessionFeatureAPI feature : PolicySessionFeatureAPI.impl.getList())
{
feature.destroyKieSession(session);
}
@@ -766,7 +750,7 @@ public class PolicyContainer implements Startable
logger.info("initlogger returned");
// invoke 'globalInit' on all of the features
- for (FeatureAPI feature : FeatureAPI.impl.getList())
+ for (PolicySessionFeatureAPI feature : PolicySessionFeatureAPI.impl.getList())
{
feature.globalInit(args, configDir);
}
diff --git a/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicySession.java b/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicySession.java
index 89341d6b..2149735a 100644
--- a/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicySession.java
+++ b/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicySession.java
@@ -20,12 +20,6 @@
package org.openecomp.policy.drools.core;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Properties;
-
-import org.kie.api.runtime.KieSession;
import org.kie.api.event.rule.AfterMatchFiredEvent;
import org.kie.api.event.rule.AgendaEventListener;
import org.kie.api.event.rule.AgendaGroupPoppedEvent;
@@ -36,14 +30,14 @@ import org.kie.api.event.rule.MatchCreatedEvent;
import org.kie.api.event.rule.ObjectDeletedEvent;
import org.kie.api.event.rule.ObjectInsertedEvent;
import org.kie.api.event.rule.ObjectUpdatedEvent;
-import org.kie.api.event.rule.RuleRuntimeEventListener;
import org.kie.api.event.rule.RuleFlowGroupActivatedEvent;
import org.kie.api.event.rule.RuleFlowGroupDeactivatedEvent;
-
-import org.openecomp.policy.drools.core.jmx.PdpJmx;
+import org.kie.api.event.rule.RuleRuntimeEventListener;
+import org.kie.api.runtime.KieSession;
+import org.openecomp.policy.common.logging.eelf.MessageCodes;
import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
import org.openecomp.policy.common.logging.flexlogger.Logger;
-import org.openecomp.policy.common.logging.eelf.MessageCodes;
+import org.openecomp.policy.drools.core.jmx.PdpJmx;
/**
* This class is a wrapper around 'KieSession', which adds the following:
@@ -145,6 +139,9 @@ public class PolicySession
// We want to continue, despite any exceptions that occur
// while rules are fired.
boolean repeat = true;
+ long minSleepTime = 100;
+ long maxSleepTime = 5000;
+ long sleepTime = maxSleepTime;
while (repeat)
{
if(this.isInterrupted()){
@@ -152,15 +149,37 @@ public class PolicySession
}
try
{
- kieSession.fireAllRules();
-
+ if (kieSession.fireAllRules() > 0)
+ {
+ // some rules fired -- reduce poll delay
+ if (sleepTime > minSleepTime)
+ {
+ sleepTime /= 2;
+ if (sleepTime < minSleepTime)
+ {
+ sleepTime = minSleepTime;
+ }
+ }
+ }
+ else
+ {
+ // no rules fired -- increase poll delay
+ if (sleepTime < maxSleepTime)
+ {
+ sleepTime *= 2;
+ if (sleepTime > maxSleepTime)
+ {
+ sleepTime = maxSleepTime;
+ }
+ }
+ }
}
catch (Throwable e)
{
logger.error(MessageCodes.EXCEPTION_ERROR, e, "startThread", "kieSession.fireUntilHalt");
}
try {
- Thread.sleep(5000);
+ Thread.sleep(sleepTime);
} catch (InterruptedException e) {
break;
}
@@ -215,8 +234,11 @@ public class PolicySession
@Override
public void afterMatchFired(AfterMatchFiredEvent event)
{
- logger.debug("afterMatchFired: " + getFullName()
- + ": AgendaEventListener.afterMatchFired(" + event + ")");
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("afterMatchFired: " + getFullName()
+ + ": AgendaEventListener.afterMatchFired(" + event + ")");
+ }
PdpJmx.getInstance().ruleFired();
}
@@ -226,8 +248,12 @@ public class PolicySession
@Override
public void afterRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event)
{
+ if (logger.isDebugEnabled())
+ {
logger.debug("afterRuleFlowGroupActivated: " + getFullName()
- + ": AgendaEventListener.afterRuleFlowGroupActivated(" + event + ")");
+ + ": AgendaEventListener.afterRuleFlowGroupActivated("
+ + event + ")");
+ }
}
/**
@@ -237,8 +263,12 @@ public class PolicySession
public void afterRuleFlowGroupDeactivated
(RuleFlowGroupDeactivatedEvent event)
{
- logger.debug("afterRuleFlowGroupDeactivated: " + getFullName()
- + ": AgendaEventListener.afterRuleFlowGroupDeactivated(" + event + ")");
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("afterRuleFlowGroupDeactivated: " + getFullName()
+ + ": AgendaEventListener.afterRuleFlowGroupDeactivated("
+ + event + ")");
+ }
}
/**
@@ -247,8 +277,12 @@ public class PolicySession
@Override
public void agendaGroupPopped(AgendaGroupPoppedEvent event)
{
- logger.debug("agendaGroupPopped: " + getFullName()
- + ": AgendaEventListener.agendaGroupPopped(" + event + ")");
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("agendaGroupPopped: " + getFullName()
+ + ": AgendaEventListener.agendaGroupPopped("
+ + event + ")");
+ }
}
/**
@@ -257,8 +291,12 @@ public class PolicySession
@Override
public void agendaGroupPushed(AgendaGroupPushedEvent event)
{
- logger.debug("agendaGroupPushed: " + getFullName()
- + ": AgendaEventListener.agendaGroupPushed(" + event + ")");
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("agendaGroupPushed: " + getFullName()
+ + ": AgendaEventListener.agendaGroupPushed("
+ + event + ")");
+ }
}
/**
@@ -267,8 +305,12 @@ public class PolicySession
@Override
public void beforeMatchFired(BeforeMatchFiredEvent event)
{
- logger.debug("beforeMatchFired: " + getFullName()
- + ": AgendaEventListener.beforeMatchFired(" + event + ")");
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("beforeMatchFired: " + getFullName()
+ + ": AgendaEventListener.beforeMatchFired("
+ + event + ")");
+ }
}
/**
@@ -278,8 +320,12 @@ public class PolicySession
public void beforeRuleFlowGroupActivated
(RuleFlowGroupActivatedEvent event)
{
- logger.debug("beforeRuleFlowGroupActivated: " + getFullName()
- + ": AgendaEventListener.beforeRuleFlowGroupActivated(" + event + ")");
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("beforeRuleFlowGroupActivated: " + getFullName()
+ + ": AgendaEventListener.beforeRuleFlowGroupActivated("
+ + event + ")");
+ }
}
/**
@@ -289,8 +335,12 @@ public class PolicySession
public void beforeRuleFlowGroupDeactivated
(RuleFlowGroupDeactivatedEvent event)
{
- logger.debug("beforeRuleFlowGroupDeactivated: " + getFullName()
- + ": AgendaEventListener.beforeRuleFlowGroupDeactivated(" + event + ")");
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("beforeRuleFlowGroupDeactivated: " + getFullName()
+ + ": AgendaEventListener.beforeRuleFlowGroupDeactivated("
+ + event + ")");
+ }
}
/**
@@ -299,8 +349,11 @@ public class PolicySession
@Override
public void matchCancelled(MatchCancelledEvent event)
{
- logger.debug("matchCancelled: " + getFullName()
- + ": AgendaEventListener.matchCancelled(" + event + ")");
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("matchCancelled: " + getFullName()
+ + ": AgendaEventListener.matchCancelled(" + event + ")");
+ }
}
/**
@@ -309,8 +362,11 @@ public class PolicySession
@Override
public void matchCreated(MatchCreatedEvent event)
{
- logger.debug("matchCreated: " + getFullName()
- + ": AgendaEventListener.matchCreated(" + event + ")");
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("matchCreated: " + getFullName()
+ + ": AgendaEventListener.matchCreated(" + event + ")");
+ }
}
/****************************************/
@@ -323,8 +379,11 @@ public class PolicySession
@Override
public void objectDeleted(ObjectDeletedEvent event)
{
- logger.debug("objectDeleted: " + getFullName()
- + ": AgendaEventListener.objectDeleted(" + event + ")");
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("objectDeleted: " + getFullName()
+ + ": AgendaEventListener.objectDeleted(" + event + ")");
+ }
}
/**
@@ -333,8 +392,11 @@ public class PolicySession
@Override
public void objectInserted(ObjectInsertedEvent event)
{
- logger.debug("objectInserted: " + getFullName()
- + ": AgendaEventListener.objectInserted(" + event + ")");
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("objectInserted: " + getFullName()
+ + ": AgendaEventListener.objectInserted(" + event + ")");
+ }
}
/**
@@ -343,7 +405,10 @@ public class PolicySession
@Override
public void objectUpdated(ObjectUpdatedEvent event)
{
- logger.debug("objectUpdated: " + getFullName()
- + ": AgendaEventListener.objectUpdated(" + event + ")");
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("objectUpdated: " + getFullName()
+ + ": AgendaEventListener.objectUpdated(" + event + ")");
+ }
}
}
diff --git a/policy-core/src/main/java/org/openecomp/policy/drools/core/FeatureAPI.java b/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicySessionFeatureAPI.java
index a14c6547..d5057696 100644
--- a/policy-core/src/main/java/org/openecomp/policy/drools/core/FeatureAPI.java
+++ b/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicySessionFeatureAPI.java
@@ -20,10 +20,7 @@
package org.openecomp.policy.drools.core;
-import java.util.Properties;
-
import org.kie.api.runtime.KieSession;
-
import org.openecomp.policy.drools.utils.OrderedService;
import org.openecomp.policy.drools.utils.OrderedServiceImpl;
@@ -35,14 +32,14 @@ import org.openecomp.policy.drools.utils.OrderedServiceImpl;
* return a 'void' value. In other cases, such as 'activatePolicySession',
* may
*/
-public interface FeatureAPI extends OrderedService
+public interface PolicySessionFeatureAPI extends OrderedService
{
/**
* 'FeatureAPI.impl.getList()' returns an ordered list of objects
* implementing the 'FeatureAPI' interface.
*/
- static public OrderedServiceImpl<FeatureAPI> impl =
- new OrderedServiceImpl<FeatureAPI>(FeatureAPI.class);
+ static public OrderedServiceImpl<PolicySessionFeatureAPI> impl =
+ new OrderedServiceImpl<PolicySessionFeatureAPI>(PolicySessionFeatureAPI.class);
/**
* This method is called during initialization at a point right after
@@ -86,62 +83,6 @@ public interface FeatureAPI extends OrderedService
* 'KieSession'
*/
public void destroyKieSession(PolicySession policySession);
-
- /**
- * called before the Policy Engine is started
- */
- public void beforeStartEngine() throws IllegalStateException;
-
- /**
- * called immediately after the Policy Engine is started
- */
- public void afterStartEngine();
-
- /**
- * called before the Policy Engine is shut down
- */
- public void beforeShutdownEngine();
-
- /**
- * called after the Policy Engine is shut down
- */
- public void afterShutdownEngine();
-
- /**
- * called before creating a controller with name 'name'
- *
- * @param name name of the the controller
- * @param properties configuration properties
- */
- public void beforeCreateController(String name, Properties properties);
-
- /**
- * NOTE: temporary, should pass the Policy Controller already created
- *
- * called after creating a controller with name 'name'
- *
- * @param name name of the the controller
- * @param properties configuration properties
- */
- public void afterCreateController(String name);
-
- /**
- * NOTE: temporary, should pass the Policy Controller
- *
- * called before starting a controller with name 'name'
- *
- * @param name name of the the controller
- */
- public void beforeStartController(String name);
-
- /**
- * NOTE: temporary, should pass the Policy Controller
- *
- * called after starting a controller with name 'name'
- *
- * @param name name of the the controller
- */
- public void afterStartController(String name);
/**
* NOTE: this method is probably temporary
diff --git a/policy-core/src/main/java/org/openecomp/policy/drools/properties/PolicyProperties.java b/policy-core/src/main/java/org/openecomp/policy/drools/properties/PolicyProperties.java
index 13580219..1274e08c 100644
--- a/policy-core/src/main/java/org/openecomp/policy/drools/properties/PolicyProperties.java
+++ b/policy-core/src/main/java/org/openecomp/policy/drools/properties/PolicyProperties.java
@@ -46,6 +46,8 @@ public interface PolicyProperties {
public static final String PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX =".partitionKey";
+ public static final String PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX = ".selfSignedCertificates";
+
/* UEB Properties */
public static final String PROPERTY_UEB_SOURCE_TOPICS = "ueb.source.topics";
@@ -56,6 +58,21 @@ public interface PolicyProperties {
public static final String PROPERTY_DMAAP_SOURCE_TOPICS = "dmaap.source.topics";
public static final String PROPERTY_DMAAP_SINK_TOPICS = "dmaap.sink.topics";
+ public static final String PROPERTY_DMAAP_DME2_PARTNER_SUFFIX = ".dme2.partner";
+ public static final String PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX = ".dme2.routeOffer";
+ public static final String PROPERTY_DMAAP_DME2_ENVIRONMENT_SUFFIX = ".dme2.environment";
+ public static final String PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX = ".dme2.aft.environment";
+ public static final String PROPERTY_DMAAP_DME2_LATITUDE_SUFFIX = ".dme2.latitude";
+ public static final String PROPERTY_DMAAP_DME2_LONGITUDE_SUFFIX = ".dme2.longitude";
+
+ public static final String PROPERTY_DMAAP_DME2_EP_READ_TIMEOUT_MS_SUFFIX = ".dme2.epReadTimeoutMs";
+ public static final String PROPERTY_DMAAP_DME2_EP_CONN_TIMEOUT_SUFFIX = ".dme2.epConnTimeout";
+ public static final String PROPERTY_DMAAP_DME2_ROUNDTRIP_TIMEOUT_MS_SUFFIX = ".dme2.roundtripTimeoutMs";
+ public static final String PROPERTY_DMAAP_DME2_VERSION_SUFFIX = ".dme2.version";
+ public static final String PROPERTY_DMAAP_DME2_SERVICE_NAME_SUFFIX = ".dme2.serviceName";
+ public static final String PROPERTY_DMAAP_DME2_SUB_CONTEXT_PATH_SUFFIX = ".dme2.subContextPath";
+ public static final String PROPERTY_DMAAP_DME2_SESSION_STICKINESS_REQUIRED_SUFFIX = ".dme2.sessionStickinessRequired";
+
/* HTTP Server Properties */
public static final String PROPERTY_HTTP_SERVER_SERVICES = "http.server.services";