summaryrefslogtreecommitdiffstats
path: root/services/services-engine/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'services/services-engine/src/main/java')
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java22
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java2
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java2
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java34
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java16
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java18
6 files changed, 61 insertions, 33 deletions
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
index 5a0d11d4c..368305efa 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
@@ -102,7 +102,7 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
public static final String SOURCE_REGEXP = "^$|[A-Za-z0-9\\.\\-_:]+";
/** The target of an Apex event must match this regular expression. */
- public static final String TARGET_REGEXP = "^$|[A-Za-z0-9\\.\\-_:]+";
+ public static final String TARGET_REGEXP = SOURCE_REGEXP;
// The fields of the event
// @formatter:off
@@ -121,16 +121,6 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
private String exceptionMessage;
/**
- * Private utility to get the next candidate value for a Execution ID. This value will always be
- * unique in a single JVM
- *
- * @return the next candidate value for a Execution ID
- */
- private static synchronized long getNextExecutionId() {
- return nextExecutionID.getAndIncrement();
- }
-
- /**
* Instantiates a new apex event.
*
* @param name the name of the event
@@ -152,6 +142,16 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
}
/**
+ * Private utility to get the next candidate value for a Execution ID. This value will always be
+ * unique in a single JVM
+ *
+ * @return the next candidate value for a Execution ID
+ */
+ private static synchronized long getNextExecutionId() {
+ return nextExecutionID.getAndIncrement();
+ }
+
+ /**
* Check that a field of the event is valid.
*
* @param fieldName the name of the field to check
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java
index 32f87a7cc..fbb1ec053 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java
@@ -51,7 +51,7 @@ public class ApexPeriodicEventGenerator extends TimerTask {
public static final String PERIODIC_EVENT_SOURCE = "internal";
/** The target of the periodic event. */
- public static final String PERIODIC_EVENT_TARGET = "internal";
+ public static final String PERIODIC_EVENT_TARGET = PERIODIC_EVENT_SOURCE;
/**
* The field name in the periodic event for the delay between occurrences of the periodic event.
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java
index 532fdb9c7..77be038e5 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java
@@ -94,7 +94,7 @@ public class ApexEventMarshaller implements ApexEventListener, Runnable {
* @throws ApexActivatorException on errors initializing the producer
* @throws ApexEventException on errors initializing event handling
*/
- public void init() throws ApexActivatorException, ApexEventException {
+ public void init() throws ApexEventException {
// Create the producer for sending events and the converter for transforming events
producer = new EventProducerFactory().createProducer(name, producerParameters);
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java
index 1d1b64e37..97aa25fbe 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java
@@ -216,15 +216,10 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable {
try {
final List<ApexEvent> apexEventList = converter.toApexEvent(consumerParameters.getEventName(), event);
for (final ApexEvent apexEvent : apexEventList) {
- // Check if we are filtering events on this unmarshaler, if so check the event name
- // against the filter
- if (consumerParameters.isSetEventNameFilter()
- && !apexEvent.getName().matches(consumerParameters.getEventNameFilter())) {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("onMessage(): event {} not processed, filtered out by filter", apexEvent,
- consumerParameters.getEventNameFilter());
- }
+ isEventFilteredOut(apexEvent);
+ // Check if this event is filtered out by the incoming filter
+ if (isEventFilteredOut(apexEvent)) {
// Ignore this event
continue;
}
@@ -252,6 +247,29 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable {
}
/**
+ * Check if an event is filtered out and ignored.
+ *
+ * @param apexEvent the event to check
+ */
+ private boolean isEventFilteredOut(final ApexEvent apexEvent) {
+ // Check if we are filtering events on this unmarshaler, if so check the event name
+ // against the filter
+ if (consumerParameters.isSetEventNameFilter()
+ && !apexEvent.getName().matches(consumerParameters.getEventNameFilter())) {
+
+ if (LOGGER.isTraceEnabled()) {
+ LOGGER.trace("onMessage(): event {} not processed, filtered out by filter", apexEvent,
+ consumerParameters.getEventNameFilter());
+ }
+
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
* Run a thread that runs forever (well until system termination anyway) and listens for incoming events on the
* queue.
*/
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java
index dc5e91979..56b3b84c4 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java
@@ -714,9 +714,8 @@ final class EngineWorker implements EngineService {
try {
if (event != null) {
- if (debugEnabled) {
- LOGGER.debug("Trigger Event {} forwarded to the Apex engine", event);
- }
+ debugEventIfDebugEnabled(event);
+
final EnEvent enevent = apexEnEventConverter.fromApexEvent(event);
engine.handleEvent(enevent);
}
@@ -729,5 +728,16 @@ final class EngineWorker implements EngineService {
}
LOGGER.debug("Engine {} completed processing", engineWorkerKey);
}
+
+ /**
+ * Debug the event if debug is enabled.
+ *
+ * @param event the event to debug
+ */
+ private void debugEventIfDebugEnabled(ApexEvent event) {
+ if (debugEnabled) {
+ LOGGER.debug("Trigger Event {} forwarded to the Apex engine", event);
+ }
+ }
}
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java
index 907baad40..4bbc5fc85 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java
@@ -55,6 +55,15 @@ public class ApexParameters implements ParameterGroup {
private static final String EVENT_OUTPUT_PARAMETERS_STRING = "eventOutputParameters";
private static final String FOR_PEERED_MODE_STRING = " for peered mode ";
+ // Parameters for the engine service and the engine threads in the engine service
+ private EngineServiceParameters engineServiceParameters;
+
+ // Parameters for the event outputs that Apex will use to send events on its outputs
+ private Map<String, EventHandlerParameters> eventOutputParameters = new LinkedHashMap<>();
+
+ // Parameters for the event inputs that Apex will use to receive events on its inputs
+ private Map<String, EventHandlerParameters> eventInputParameters = new LinkedHashMap<>();
+
/**
* Constructor to create an apex parameters instance and register the instance with the parameter service.
*/
@@ -65,15 +74,6 @@ public class ApexParameters implements ParameterGroup {
this.name = ApexParameterConstants.MAIN_GROUP_NAME;
}
- // Parameters for the engine service and the engine threads in the engine service
- private EngineServiceParameters engineServiceParameters;
-
- // Parameters for the event outputs that Apex will use to send events on its outputs
- private Map<String, EventHandlerParameters> eventOutputParameters = new LinkedHashMap<>();
-
- // Parameters for the event inputs that Apex will use to receive events on its inputs
- private Map<String, EventHandlerParameters> eventInputParameters = new LinkedHashMap<>();
-
/**
* Gets the parameters for the Apex engine service.
*