aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/ApexEngine.java9
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineConstants.java43
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java7
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/Executor.java7
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/TaskExecutor.java44
5 files changed, 78 insertions, 32 deletions
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/ApexEngine.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/ApexEngine.java
index b2978a0c0..2c5167d1b 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/ApexEngine.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/ApexEngine.java
@@ -43,15 +43,6 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
*/
public interface ApexEngine {
/**
- * The amount of milliseconds to wait for the current Apex engine to timeout on engine stop
- * requests. If the timeout is exceeded, the stop aborts.
- */
- int STOP_EXECUTION_WAIT_TIMEOUT = 3000;
-
- /** The wait increment (or pause time) when waiting for the Apex engine to stop. */
- int APEX_ENGINE_STOP_EXECUTION_WAIT_INCREMENT = 100;
-
- /**
* Update the Apex model to be used by the Apex engine. The engine must be in state "STOPPED"
* when the model is updated. The engine will replace the current model with the incoming model
* if the model of the engine was previously updated and the value of common context is
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineConstants.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineConstants.java
new file mode 100644
index 000000000..e01feb730
--- /dev/null
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineConstants.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.engine.engine.impl;
+
+/**
+ * Constants for the Apex engine.
+ *
+ */
+public abstract class ApexEngineConstants {
+ /**
+ * The amount of milliseconds to wait for the current Apex engine to timeout on engine stop
+ * requests. If the timeout is exceeded, the stop aborts.
+ */
+ public static final int STOP_EXECUTION_WAIT_TIMEOUT = 3000;
+
+ /** The wait increment (or pause time) when waiting for the Apex engine to stop. */
+ public static final int APEX_ENGINE_STOP_EXECUTION_WAIT_INCREMENT = 100;
+
+ /**
+ * Private constructor to prevent subclassing.
+ */
+ private ApexEngineConstants() {
+ // Constructor to avoid subclassing
+ }
+}
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java
index 6f2bab0b9..022617864 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImpl.java
@@ -161,8 +161,7 @@ public class ApexEngineImpl implements ApexEngine {
LOGGER.entry("start()" + key);
if (state != AxEngineState.STOPPED) {
- String message = START + key.getId() + "," + state
- + ", cannot start engine, engine not in state STOPPED";
+ String message = START + key.getId() + "," + state + ", cannot start engine, engine not in state STOPPED";
LOGGER.warn(message);
throw new ApexException(message);
}
@@ -203,7 +202,9 @@ public class ApexEngineImpl implements ApexEngine {
LOGGER.entry("stop()->" + key);
// Stop the engine if it is in state READY, if it is in state EXECUTING, wait for execution to finish
- for (int increment = STOP_EXECUTION_WAIT_TIMEOUT; increment > 0; increment = STOP_EXECUTION_WAIT_TIMEOUT) {
+ for (int increment = ApexEngineConstants.STOP_EXECUTION_WAIT_TIMEOUT;
+ increment > 0;
+ increment = ApexEngineConstants.STOP_EXECUTION_WAIT_TIMEOUT) {
synchronized (state) {
switch (state) {
// Already stopped
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/Executor.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/Executor.java
index 9941c6de8..22a23d062 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/Executor.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/Executor.java
@@ -23,6 +23,7 @@ package org.onap.policy.apex.core.engine.executor;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.executor.exception.StateMachineException;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
/**
@@ -70,7 +71,7 @@ public interface Executor<I, O, S, C> {
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
- O execute(long executionId, I incomingEntity) throws StateMachineException, ContextException;
+ O execute(long executionId, I incomingEntity) throws ApexException;
/**
* Carry out the preparatory work for execution.
@@ -80,7 +81,7 @@ public interface Executor<I, O, S, C> {
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
- void executePre(long executionId, I incomingEntity) throws StateMachineException, ContextException;
+ void executePre(long executionId, I incomingEntity) throws ApexException;
/**
* Carry out the post work for execution, the returning entity should be set by the child
@@ -91,7 +92,7 @@ public interface Executor<I, O, S, C> {
* @throws StateMachineException on an execution error
* @throws ContextException On context errors
*/
- void executePost(boolean returnValue) throws StateMachineException, ContextException;
+ void executePost(boolean returnValue) throws ApexException;
/**
* Cleans up after processing.
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/TaskExecutor.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/TaskExecutor.java
index 814f257f7..2a62f3ae2 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/TaskExecutor.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/TaskExecutor.java
@@ -181,23 +181,7 @@ public abstract class TaskExecutor
// Copy any unset fields from the input to the output if their data type and names are
// identical
for (final String field : axTask.getOutputFields().keySet()) {
- // Check if the field exists and is not set on the output
- if (!getOutgoing().containsKey(field) || getOutgoing().get(field) != null) {
- continue;
- }
-
- // This field is not in the output, check if it's on the input and is the same type
- // (Note here, the output
- // field definition has to exist so it's not
- // null checked)
- final AxInputField inputFieldDef = axTask.getInputFields().get(field);
- final AxOutputField outputFieldDef = axTask.getOutputFields().get(field);
- if (inputFieldDef == null || !inputFieldDef.getSchema().equals(outputFieldDef.getSchema())) {
- continue;
- }
-
- // We have an input field that matches our output field, copy the value across
- getOutgoing().put(field, getIncoming().get(field));
+ copyInputField2Output(field);
}
// Finally, check that the outgoing fields have all the output fields defined for this state
@@ -233,6 +217,32 @@ public abstract class TaskExecutor
LOGGER.debug(message);
}
+ /**
+ * If the input field exists on the output and it is not set in the task, then it should
+ * be copied to the output.
+ *
+ * @param field the input field
+ */
+ private void copyInputField2Output(String field) {
+ // Check if the field exists and is not set on the output
+ if (!getOutgoing().containsKey(field) || getOutgoing().get(field) != null) {
+ return;
+ }
+
+ // This field is not in the output, check if it's on the input and is the same type
+ // (Note here, the output
+ // field definition has to exist so it's not
+ // null checked)
+ final AxInputField inputFieldDef = axTask.getInputFields().get(field);
+ final AxOutputField outputFieldDef = axTask.getOutputFields().get(field);
+ if (inputFieldDef == null || !inputFieldDef.getSchema().equals(outputFieldDef.getSchema())) {
+ return;
+ }
+
+ // We have an input field that matches our output field, copy the value across
+ getOutgoing().put(field, getIncoming().get(field));
+ }
+
/*
* (non-Javadoc)
*