import org.slf4j.ext.XLoggerFactory;
/**
- * This handler holds and manages state machines for each policy in an Apex engine. When the class
- * is instantiated, an executor {@link StateMachineExecutor} is created for each policy in the
- * policy model the state machine handler will execute. The executors for each policy are held in a
- * map indexed by event.
+ * This handler holds and manages state machines for each policy in an Apex engine. When the class is instantiated, an
+ * executor {@link StateMachineExecutor} is created for each policy in the policy model the state machine handler will
+ * execute. The executors for each policy are held in a map indexed by event.
*
- * <p>When an event is received on the policy, the state machine executor to execute that event is
- * looked up on the executor map and the event is passed to the executor for execution.
+ * <p>When an event is received on the policy, the state machine executor to execute that event is looked up on the
+ * executor map and the event is passed to the executor for execution.
*
* @author Liam Fallon
*
}
/**
- * This constructor starts the state machines for each policy, carrying out whatever
- * initialization executors need.
+ * This constructor starts the state machines for each policy, carrying out whatever initialization executors need.
*
* @throws StateMachineException On state machine initiation errors
*/
final String stateMachineId = smExecutor.getContext().getKey().getId();
String message = "start()<-" + key.getId() + ", start failed, state machine \"" + stateMachineId + "\"";
LOGGER.warn(message, e);
- throw new StateMachineException(
- message, e);
+ throw new StateMachineException(message, e);
}
}
// Run the state machine
try {
LOGGER.debug("execute(): state machine \"{}\" execution starting . . .", stateMachineExecutor);
- final EnEvent outputObject = stateMachineExecutor.execute(event.getExecutionId(), event);
+ final EnEvent outputObject =
+ stateMachineExecutor.execute(event.getExecutionId(), event.getExecutionProperties(), event);
LOGGER.debug("execute()<-: state machine \"{}\" execution completed", stateMachineExecutor);
return outputObject;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.Properties;
import java.util.Random;
import java.util.Set;
// be reset
private long executionId = rand.nextLong();
+ // Event related properties used during processing of this event
+ private Properties executionProperties;
+
// A string holding a message that indicates why processing of this event threw an exception
private String exceptionMessage;
*/
public EnEvent(final AxEvent axEvent) {
super();
-
+
if (axEvent == null) {
throw new EnException("event definition is null or was not found in model service");
}
this.executionId = executionId;
}
+ /**
+ * Get the event execution properties.
+ *
+ * @return the event execution properties
+ */
+ public Properties getExecutionProperties() {
+ return executionProperties;
+ }
+
+ /**
+ * Set the event execution properties.
+ *
+ * @param executionProperties the execution properties to set
+ */
+ public void setExecutionProperties(Properties executionProperties) {
+ this.executionProperties = executionProperties;
+ }
+
/**
* Gets the exception message explaining why processing of this event to fail.
*
this.exceptionMessage = exceptionMessage;
}
-
/**
* Get the user artifact stack of the event.
*
package org.onap.policy.apex.core.engine.executor;
+import java.util.Properties;
+
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;
* Executes the executor, running through its context in its natural order.
*
* @param executionId the execution ID of the current APEX execution policy thread
+ * @param executionProperties the execution properties to set
* @param incomingEntity the incoming entity that triggers execution
* @return The outgoing entity that is the result of execution
* @throws ApexException on an execution error
*/
- O execute(long executionId, I incomingEntity) throws ApexException;
+ O execute(long executionId, Properties executionProperties, I incomingEntity) throws ApexException;
/**
* Carry out the preparatory work for execution.
*
* @param executionId the execution ID of the current APEX execution policy thread
+ * @param executionProperties the execution properties to set
* @param incomingEntity the incoming entity that triggers execution
* @throws ApexException on an execution error
*/
- void executePre(long executionId, I incomingEntity) throws ApexException;
+ void executePre(long executionId, Properties executionProperties, I incomingEntity) throws ApexException;
/**
* Carry out the post work for execution, the returning entity should be set by the child
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Properties;
import java.util.TreeMap;
import org.onap.policy.apex.context.ContextException;
/**
* Constructor, save the executor factory.
*
- * @param executorFactory the executor factory to use for getting executors for task selection
- * logic
+ * @param executorFactory the executor factory to use for getting executors for task selection logic
*/
public StateExecutor(final ExecutorFactory executorFactory) {
this.executorFactory = executorFactory;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#setContext(org.onap.policy.apex.core.
- * engine.executor.Executor, java.lang.Object, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
public void setContext(final Executor<?, ?, ?, ?> incomingParent, final AxState incomingAxState,
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#prepare()
+ /**
+ * {@inheritDoc}
*/
@Override
public void prepare() throws StateMachineException {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#execute(java.lang.long,
- * java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public StateOutput execute(final long executionId, final EnEvent incomingEvent)
- throws StateMachineException, ContextException {
+ public StateOutput execute(final long executionId, final Properties executionProperties,
+ final EnEvent incomingEvent) throws StateMachineException, ContextException {
this.lastIncomingEvent = incomingEvent;
// Check that the incoming event matches the trigger for this state
// There may be no task selection logic, in which case just return the default task
if (taskSelectExecutor != null) {
// Fire the task selector to find the task to run
- taskKey = taskSelectExecutor.execute(executionId, incomingEvent);
+ taskKey = taskSelectExecutor.execute(executionId, executionProperties, incomingEvent);
}
// If there's no task selection logic or the TSL returned no task, just use the default
final TreeMap<String, Object> incomingValues = new TreeMap<>();
incomingValues.putAll(incomingEvent);
final Map<String, Object> taskExecutionResultMap =
- taskExecutorMap.get(taskKey).execute(executionId, incomingValues);
+ taskExecutorMap.get(taskKey).execute(executionId, executionProperties, incomingValues);
final AxTask task = taskExecutorMap.get(taskKey).getSubject();
// Check if this task has direct output
// Execute the state finalizer logic to select a state output and to adjust the
// taskExecutionResultMap
stateOutputName =
- finalizerLogicExecutor.execute(incomingEvent.getExecutionId(), taskExecutionResultMap);
+ finalizerLogicExecutor.execute(executionId, executionProperties, taskExecutionResultMap);
}
// Now look up the the actual state output
// Set the ExecutionID for the outgoing event to the value in the incoming event.
if (stateOutput.getOutputEvent() != null) {
stateOutput.getOutputEvent().setExecutionId(incomingEvent.getExecutionId());
+ stateOutput.getOutputEvent().setExecutionProperties(incomingEvent.getExecutionProperties());
}
// That's it, the state execution is complete
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#executePre(java.lang.long,
- * java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public final void executePre(final long executionId, final EnEvent incomingEntity) throws StateMachineException {
+ public final void executePre(final long executionId, final Properties executionProperties,
+ final EnEvent incomingEntity) throws StateMachineException {
throw new StateMachineException("execution pre work not implemented on class");
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#executePost(boolean)
- */
@Override
public final void executePost(final boolean returnValue) throws StateMachineException {
throw new StateMachineException("execution post work not implemented on class");
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp()
+ /**
+ * {@inheritDoc}
*/
@Override
public void cleanUp() throws StateMachineException {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getKey()
+ /**
+ * {@inheritDoc}
*/
@Override
public AxReferenceKey getKey() {
return axState.getKey();
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getParent()
+ /**
+ * {@inheritDoc}
*/
@Override
public Executor<?, ?, ?, ?> getParent() {
return parent;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getSubject()
+ /**
+ * {@inheritDoc}
*/
@Override
public AxState getSubject() {
return axState;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getContext()
+ /**
+ * {@inheritDoc}
*/
@Override
public final ApexInternalContext getContext() {
return context;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getIncoming()
+ /**
+ * {@inheritDoc}
*/
@Override
public final EnEvent getIncoming() {
return lastIncomingEvent;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getOutgoing()
+ /**
+ * {@inheritDoc}
*/
@Override
public final StateOutput getOutgoing() {
return lastStateOutput;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.onap.policy.apex.core.engine.executor.Executor#setNext(org.onap.policy.apex.core.engine.
- * executor.Executor)
+ /**
+ * {@inheritDoc}
*/
@Override
public final void setNext(final Executor<EnEvent, StateOutput, AxState, ApexInternalContext> incomingNextExecutor) {
this.nextExecutor = incomingNextExecutor;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getNext()
+ /**
+ * {@inheritDoc}
*/
@Override
public final Executor<EnEvent, StateOutput, AxState, ApexInternalContext> getNext() {
return nextExecutor;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.onap.policy.apex.core.engine.executor.Executor#setParameters(org.onap.policy.apex.core.
- * engine. ExecutorParameters)
+ /**
+ * {@inheritDoc}
*/
@Override
public void setParameters(final ExecutorParameters parameters) {
import static org.onap.policy.common.utils.validation.Assertions.argumentOfClassNotNull;
import java.util.Map;
+import java.util.Properties;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public abstract class StateFinalizerExecutor
- implements Executor<Map<String, Object>, String, AxStateFinalizerLogic, ApexInternalContext> {
+ implements Executor<Map<String, Object>, String, AxStateFinalizerLogic, ApexInternalContext> {
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(StateFinalizerExecutor.class);
return executionContext;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#setContext(org.onap.policy.apex.core.
- * engine.executor.Executor, java.lang.Object, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
public void setContext(final Executor<?, ?, ?, ?> incomingParent,
- final AxStateFinalizerLogic incomingFinalizerLogic,
- final ApexInternalContext incomingInternalContext) {
+ final AxStateFinalizerLogic incomingFinalizerLogic, final ApexInternalContext incomingInternalContext) {
this.parent = incomingParent;
axState = (AxState) parent.getSubject();
this.finalizerLogic = incomingFinalizerLogic;
this.internalContext = incomingInternalContext;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#prepare()
+ /**
+ * {@inheritDoc}
*/
@Override
public void prepare() throws StateMachineException {
LOGGER.debug("prepare:" + finalizerLogic.getId() + "," + finalizerLogic.getLogicFlavour() + ","
- + finalizerLogic.getLogic());
+ + finalizerLogic.getLogic());
argumentOfClassNotNull(finalizerLogic.getLogic(), StateMachineException.class,
- "state finalizer logic cannot be null.");
+ "state finalizer logic cannot be null.");
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#execute(java.lang.long, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public String execute(final long executionId, final Map<String, Object> newIncomingFields)
- throws StateMachineException, ContextException {
+ public String execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException {
throw new StateMachineException("execute() not implemented on abstract StateFinalizerExecutionContext class, "
- + "only on its subclasses");
+ + "only on its subclasses");
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#executePre(java.lang.long, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public final void executePre(final long executionId, final Map<String, Object> newIncomingFields)
- throws StateMachineException, ContextException {
+ public final void executePre(final long executionId, final Properties executionProperties,
+ final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException {
LOGGER.debug("execute-pre:" + finalizerLogic.getLogicFlavour() + "," + getSubject().getId() + ","
- + finalizerLogic.getLogic());
+ + finalizerLogic.getLogic());
// Record the incoming fields
this.incomingFields = newIncomingFields;
// Get state finalizer context object
- executionContext = new StateFinalizerExecutionContext(this, executionId, axState, getIncoming(),
- axState.getStateOutputs().keySet(), getContext());
+ executionContext = new StateFinalizerExecutionContext(this, executionId, executionProperties, axState,
+ getIncoming(), axState.getStateOutputs().keySet(), getContext());
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#executePost(boolean)
+ /**
+ * {@inheritDoc}
*/
@Override
public final void executePost(final boolean returnValue) throws StateMachineException, ContextException {
if (!returnValue) {
String errorMessage = "execute-post: state finalizer logic execution failure on state \"" + axState.getId()
- + "\" on finalizer logic " + finalizerLogic.getId();
+ + "\" on finalizer logic " + finalizerLogic.getId();
if (executionContext.getMessage() != null) {
errorMessage += ", user message: " + executionContext.getMessage();
}
if (!axState.getStateOutputs().keySet().contains(getOutgoing())) {
LOGGER.warn(EXECUTE_POST_SFL + finalizerLogic.getId() + "\" selected output state \"" + getOutgoing()
- + "\" that does not exsist on state \"" + axState.getId() + "\"");
+ + "\" that does not exsist on state \"" + axState.getId() + "\"");
throw new StateMachineException(EXECUTE_POST_SFL + finalizerLogic.getId() + "\" selected output state \""
- + getOutgoing() + "\" that does not exsist on state \"" + axState.getId() + "\"");
+ + getOutgoing() + "\" that does not exsist on state \"" + axState.getId() + "\"");
}
LOGGER.debug("execute-post:{}, returning state output \"{}\" and fields {}", finalizerLogic.getId(),
- getOutgoing(), incomingFields);
+ getOutgoing(), incomingFields);
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp()
+ /**
+ * {@inheritDoc}
*/
@Override
public void cleanUp() throws StateMachineException {
throw new StateMachineException("cleanUp() not implemented on class");
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getKey()
+ /**
+ * {@inheritDoc}
*/
@Override
public AxReferenceKey getKey() {
return finalizerLogic.getKey();
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getParent()
+ /**
+ * {@inheritDoc}
*/
@Override
public Executor<?, ?, ?, ?> getParent() {
return parent;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getSubject()
+ /**
+ * {@inheritDoc}
*/
@Override
public AxStateFinalizerLogic getSubject() {
return finalizerLogic;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getContext()
+ /**
+ * {@inheritDoc}
*/
@Override
public ApexInternalContext getContext() {
return internalContext;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getIncoming()
+ /**
+ * {@inheritDoc}
*/
@Override
public Map<String, Object> getIncoming() {
return incomingFields;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getOutgoing()
+ /**
+ * {@inheritDoc}
*/
@Override
public String getOutgoing() {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#setNext(org.onap.policy.apex.core.engine.
- * executor.Executor)
+ /**
+ * {@inheritDoc}
*/
@Override
public void setNext(
- final Executor<Map<String, Object>, String, AxStateFinalizerLogic, ApexInternalContext> inNextEx) {
+ final Executor<Map<String, Object>, String, AxStateFinalizerLogic, ApexInternalContext> inNextEx) {
this.nextExecutor = inNextEx;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getNext()
+ /**
+ * {@inheritDoc}
*/
@Override
public Executor<Map<String, Object>, String, AxStateFinalizerLogic, ApexInternalContext> getNext() {
return nextExecutor;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#setParameters(org.onap.policy.apex.core. engine.
- * ExecutorParameters)
+ /**
+ * {@inheritDoc}
*/
@Override
- public void setParameters(final ExecutorParameters parameters) {
- }
+ public void setParameters(final ExecutorParameters parameters) {}
}
package org.onap.policy.apex.core.engine.executor;
import java.util.Map;
+import java.util.Properties;
import java.util.TreeMap;
import org.onap.policy.apex.context.ContextException;
private ExecutorFactory executorFactory = null;
/**
- * Constructor, save the executor factory that will give us executors for task selection logic
- * and task logic.
+ * Constructor, save the executor factory that will give us executors for task selection logic and task logic.
*
* @param executorFactory the executor factory
* @param owner the artifact key of the owner of this state machine
this.executorFactory = executorFactory;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#setContext(org.onap.policy.apex.core.
- * engine.executor.Executor, java.lang.Object, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
public void setContext(final Executor<?, ?, ?, ?> newParent, final AxPolicy newAxPolicy,
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#prepare()
+ /**
+ * {@inheritDoc}
*/
@Override
public void prepare() throws StateMachineException {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#executeDirected(java.lang.long,
- * java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public EnEvent execute(final long executionId, final EnEvent incomingEvent)
+ public EnEvent execute(final long executionId, final Properties executionProperties, final EnEvent incomingEvent)
throws StateMachineException, ContextException {
// Check if there are any states on the state machine
if (stateExecutorMap.size() == 0) {
StateExecutor stateExecutor = firstExecutor;
StateOutput stateOutput = new StateOutput(new AxStateOutput(firstExecutor.getSubject().getKey(),
incomingEvent.getKey(), firstExecutor.getSubject().getKey()), incomingEvent);
+
while (true) {
// Execute the state, it returns an output or throws an exception
- stateOutput = stateExecutor.execute(executionId, stateOutput.getOutputEvent());
+ stateOutput = stateExecutor.execute(executionId, executionProperties, stateOutput.getOutputEvent());
// Use the next state of the state output to find if all the states have executed
if (stateOutput.getNextState().equals(AxReferenceKey.getNullKey())) {
return stateOutput.getOutputEvent();
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#executePre(java.lang.long,
- * java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public final void executePre(final long executionId, final EnEvent incomingEntity) throws StateMachineException {
+ public final void executePre(final long executionId, final Properties executionProperties,
+ final EnEvent incomingEntity) throws StateMachineException {
throw new StateMachineException("execution pre work not implemented on class");
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#executePost(boolean)
+ /**
+ * {@inheritDoc}
*/
@Override
public final void executePost(final boolean returnValue) throws StateMachineException {
throw new StateMachineException("execution post work not implemented on class");
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp()
+ /**
+ * {@inheritDoc}
*/
@Override
public void cleanUp() throws StateMachineException {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getKey()
+ /**
+ * {@inheritDoc}
*/
@Override
public AxArtifactKey getKey() {
return axPolicy.getKey();
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getParent()
+ /**
+ * {@inheritDoc}
*/
@Override
public final Executor<?, ?, ?, ?> getParent() {
return parent;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getSubject()
+ /**
+ * {@inheritDoc}
*/
@Override
public final AxPolicy getSubject() {
return axPolicy;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getContext()
+ /**
+ * {@inheritDoc}
*/
@Override
public final ApexInternalContext getContext() {
return internalContext;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getIncoming()
+ /**
+ * {@inheritDoc}
*/
@Override
public final EnEvent getIncoming() {
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getOutgoing()
+ /**
+ * {@inheritDoc}
*/
@Override
public final EnEvent getOutgoing() {
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.onap.policy.apex.core.engine.executor.Executor#setNext(org.onap.policy.apex.core.engine.
- * executor.Executor)
+ /**
+ * {@inheritDoc}
*/
@Override
public final void setNext(final Executor<EnEvent, EnEvent, AxPolicy, ApexInternalContext> newNextExecutor) {
this.nextExecutor = newNextExecutor;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getNext()
+ /**
+ * {@inheritDoc}
*/
@Override
public final Executor<EnEvent, EnEvent, AxPolicy, ApexInternalContext> getNext() {
return nextExecutor;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.onap.policy.apex.core.engine.executor.Executor#setParameters(org.onap.policy.apex.core.
- * engine. ExecutorParameters)
+ /**
+ * {@inheritDoc}
*/
@Override
public void setParameters(final ExecutorParameters parameters) {
import java.util.Iterator;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public abstract class TaskExecutor
- implements Executor<Map<String, Object>, Map<String, Object>, AxTask, ApexInternalContext> {
+ implements Executor<Map<String, Object>, Map<String, Object>, AxTask, ApexInternalContext> {
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(TaskExecutor.class);
return executionContext;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#setContext(org.onap.policy.apex.core.
- * engine.executor.Executor, java.lang.Object, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
public void setContext(final Executor<?, ?, ?, ?> newParent, final AxTask newAxTask,
- final ApexInternalContext newInternalContext) {
+ final ApexInternalContext newInternalContext) {
this.parent = newParent;
this.axTask = newAxTask;
this.internalContext = newInternalContext;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#prepare()
+ /**
+ * {@inheritDoc}
*/
@Override
public void prepare() throws StateMachineException {
LOGGER.debug("prepare:" + axTask.getKey().getId() + "," + axTask.getTaskLogic().getLogicFlavour() + ","
- + axTask.getTaskLogic().getLogic());
+ + axTask.getTaskLogic().getLogic());
argumentOfClassNotNull(axTask.getTaskLogic().getLogic(), StateMachineException.class,
- "task logic cannot be null.");
+ "task logic cannot be null.");
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#execute(java.lang.long, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public Map<String, Object> execute(final long executionId, final Map<String, Object> newIncomingFields)
- throws StateMachineException, ContextException {
+ public Map<String, Object> execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException {
throw new StateMachineException(
- "execute() not implemented on abstract TaskExecutor class, only on its subclasses");
+ "execute() not implemented on abstract TaskExecutor class, only on its subclasses");
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#executePre(java.lang.long, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public final void executePre(final long executionId, final Map<String, Object> newIncomingFields)
- throws StateMachineException, ContextException {
+ public final void executePre(final long executionId, final Properties executionProperties,
+ final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException {
LOGGER.debug("execute-pre:" + getSubject().getTaskLogic().getLogicFlavour() + ","
- + getSubject().getKey().getId() + "," + getSubject().getTaskLogic().getLogic());
+ + getSubject().getKey().getId() + "," + getSubject().getTaskLogic().getLogic());
// Check that the incoming event has all the input fields for this state
final Set<String> missingTaskInputFields = new TreeSet<>(axTask.getInputFields().keySet());
// Remove fields from the set that are optional
final Set<String> optionalFields = new TreeSet<>();
for (final Iterator<String> missingFieldIterator = missingTaskInputFields.iterator(); missingFieldIterator
- .hasNext();) {
+ .hasNext();) {
final String missingField = missingFieldIterator.next();
if (axTask.getInputFields().get(missingField).getOptional()) {
optionalFields.add(missingField);
missingTaskInputFields.removeAll(optionalFields);
if (!missingTaskInputFields.isEmpty()) {
throw new StateMachineException("task input fields \"" + missingTaskInputFields
- + "\" are missing for task \"" + axTask.getKey().getId() + "\"");
+ + "\" are missing for task \"" + axTask.getKey().getId() + "\"");
}
// Record the incoming fields
}
// Get task context object
- executionContext = new TaskExecutionContext(this, executionId, getSubject(), getIncoming(), getOutgoing(),
- getContext());
+ executionContext = new TaskExecutionContext(this, executionId, executionProperties, getSubject(), getIncoming(),
+ getOutgoing(), getContext());
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#executePost(boolean)
+ /**
+ * {@inheritDoc}
*/
@Override
public final void executePost(final boolean returnValue) throws StateMachineException, ContextException {
if (!returnValue) {
String errorMessage = "execute-post: task logic execution failure on task \"" + axTask.getKey().getName()
- + "\" in model " + internalContext.getKey().getId();
+ + "\" in model " + internalContext.getKey().getId();
if (executionContext.getMessage() != null) {
errorMessage += ", user message: " + executionContext.getMessage();
}
// Remove fields from the set that are optional
final Set<String> optionalOrCopiedFields = new TreeSet<>();
for (final Iterator<String> missingFieldIterator = missingTaskOutputFields.iterator(); missingFieldIterator
- .hasNext();) {
+ .hasNext();) {
final String missingField = missingFieldIterator.next();
if (axTask.getInputFields().containsKey(missingField)
- || axTask.getOutputFields().get(missingField).getOptional()) {
+ || axTask.getOutputFields().get(missingField).getOptional()) {
optionalOrCopiedFields.add(missingField);
}
}
missingTaskOutputFields.removeAll(optionalOrCopiedFields);
if (!missingTaskOutputFields.isEmpty()) {
throw new StateMachineException("task output fields \"" + missingTaskOutputFields
- + "\" are missing for task \"" + axTask.getKey().getId() + "\"");
+ + "\" are missing for task \"" + axTask.getKey().getId() + "\"");
}
// Finally, check that the outgoing field map don't have any extra fields, if present, raise
extraTaskOutputFields.removeAll(axTask.getOutputFields().keySet());
if (!extraTaskOutputFields.isEmpty()) {
throw new StateMachineException("task output fields \"" + extraTaskOutputFields
- + "\" are unwanted for task \"" + axTask.getKey().getId() + "\"");
+ + "\" are unwanted for task \"" + axTask.getKey().getId() + "\"");
}
String message = "execute-post:" + axTask.getKey().getId() + ", returning fields " + outgoingFields.toString();
getOutgoing().put(field, getIncoming().get(field));
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp()
+ /**
+ * {@inheritDoc}
*/
@Override
public void cleanUp() throws StateMachineException {
throw new StateMachineException("cleanUp() not implemented on class");
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getKey()
+ /**
+ * {@inheritDoc}
*/
@Override
public AxArtifactKey getKey() {
return axTask.getKey();
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getParent()
+ /**
+ * {@inheritDoc}
*/
@Override
public Executor<?, ?, ?, ?> getParent() {
return parent;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getSubject()
+ /**
+ * {@inheritDoc}
*/
@Override
public AxTask getSubject() {
return axTask;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getContext()
+ /**
+ * {@inheritDoc}
*/
@Override
public ApexInternalContext getContext() {
return internalContext;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getIncoming()
+ /**
+ * {@inheritDoc}
*/
@Override
public Map<String, Object> getIncoming() {
return incomingFields;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getOutgoing()
+ /**
+ * {@inheritDoc}
*/
@Override
public Map<String, Object> getOutgoing() {
return outgoingFields;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#setNext(org.onap.policy.apex.core.engine.
- * executor.Executor)
+ /**
+ * {@inheritDoc}
*/
@Override
- public void setNext(
- final Executor<Map<String, Object>, Map<String, Object>, AxTask, ApexInternalContext> nextEx) {
+ public void setNext(final Executor<Map<String, Object>, Map<String, Object>, AxTask, ApexInternalContext> nextEx) {
this.nextExecutor = nextEx;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getNext()
+ /**
+ * {@inheritDoc}
*/
@Override
public Executor<Map<String, Object>, Map<String, Object>, AxTask, ApexInternalContext> getNext() {
return nextExecutor;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#setParameters(org.onap.policy.apex.core. engine.
- * ExecutorParameters)
+ /**
+ * {@inheritDoc}
*/
@Override
- public void setParameters(final ExecutorParameters parameters) {
- }
+ public void setParameters(final ExecutorParameters parameters) {}
}
import static org.onap.policy.common.utils.validation.Assertions.argumentNotNull;
+import java.util.Properties;
+
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
import org.slf4j.ext.XLoggerFactory;
/**
- * This abstract class executes a the task selection logic of a state of an Apex policy and is
- * specialized by classes that implement execution of task selection logic.
+ * This abstract class executes a the task selection logic of a state of an Apex policy and is specialized by classes
+ * that implement execution of task selection logic.
*
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
* @author Liam Fallon (liam.fallon@ericsson.com)
return executionContext;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#setContext(org.onap.policy.apex.core.
- * engine.executor.Executor, java.lang.Object, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
public void setContext(final Executor<?, ?, ?, ?> newParent, final AxState newAxState,
this.context = newContext;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#prepare()
+ /**
+ * {@inheritDoc}
*/
@Override
public void prepare() throws StateMachineException {
argumentNotNull(axState.getTaskSelectionLogic().getLogic(), "task selection logic cannot be null.");
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#execute(java.lang.long,
- * java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public AxArtifactKey execute(final long executionId, final EnEvent newIncomingEvent)
- throws StateMachineException, ContextException {
+ public AxArtifactKey execute(final long executionId, final Properties executionProperties,
+ final EnEvent newIncomingEvent) throws StateMachineException, ContextException {
throw new StateMachineException("execute() not implemented on class");
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#executePre(java.lang.long,
- * java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public final void executePre(final long executionId, final EnEvent newIncomingEvent) throws StateMachineException {
+ public final void executePre(final long executionId, final Properties executionProperties,
+ final EnEvent newIncomingEvent) throws StateMachineException {
LOGGER.debug("execute-pre:" + axState.getKey().getId() + "," + axState.getTaskSelectionLogic().getLogicFlavour()
+ "," + axState.getTaskSelectionLogic().getLogic());
getOutgoing(), getContext());
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#executePost(boolean)
+ /**
+ * {@inheritDoc}
*/
@Override
public final void executePost(final boolean returnValue) throws StateMachineException {
LOGGER.debug("execute-post:" + axState.getKey().getId() + "," + ", returning task " + outgoingTaskKey.getId());
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp()
+ /**
+ * {@inheritDoc}
*/
@Override
public void cleanUp() throws StateMachineException {
throw new StateMachineException("cleanUp() not implemented on class");
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getKey()
+ /**
+ * {@inheritDoc}
*/
@Override
public AxReferenceKey getKey() {
return axState.getKey();
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getParent()
+ /**
+ * {@inheritDoc}
*/
@Override
public Executor<?, ?, ?, ?> getParent() {
return parent;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getSubject()
+ /**
+ * {@inheritDoc}
*/
@Override
public AxState getSubject() {
return axState;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getContext()
+ /**
+ * {@inheritDoc}
*/
@Override
public ApexInternalContext getContext() {
return context;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.onap.policy.apex.core.engine.executor.Executor#setNext(org.onap.policy.apex.core.engine.
- * executor.Executor)
+ /**
+ * {@inheritDoc}
*/
@Override
public void setNext(final Executor<EnEvent, AxArtifactKey, AxState, ApexInternalContext> newNextExecutor) {
this.nextExecutor = newNextExecutor;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getNext()
+ /**
+ * {@inheritDoc}
*/
@Override
public Executor<EnEvent, AxArtifactKey, AxState, ApexInternalContext> getNext() {
return nextExecutor;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getIncoming()
+ /**
+ * {@inheritDoc}
*/
@Override
public EnEvent getIncoming() {
return incomingEvent;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getOutgoing()
+ /**
+ * {@inheritDoc}
*/
@Override
public AxArtifactKey getOutgoing() {
return outgoingTaskKey;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.onap.policy.apex.core.engine.executor.Executor#setParameters(org.onap.policy.apex.core.
- * engine. ExecutorParameters)
+ /**
+ * {@inheritDoc}
*/
@Override
public void setParameters(final ExecutorParameters parameters) {}
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import java.util.TreeMap;
import org.slf4j.ext.XLoggerFactory;
/**
- * Container class for the execution context for state finalizer logic executions in a state being
- * executed in an Apex engine. The state finalizer must have easy access to the state definition,
- * the fields, as well as the policy, global, and external context.
+ * Container class for the execution context for state finalizer logic executions in a state being executed in an Apex
+ * engine. The state finalizer must have easy access to the state definition, the fields, as well as the policy, global,
+ * and external context.
*
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
public class StateFinalizerExecutionContext {
/**
- * Logger for state finalizer execution, state finalizer logic can use this field to access and
- * log to Apex logging.
+ * Logger for state finalizer execution, state finalizer logic can use this field to access and log to Apex logging.
*/
private static final XLogger EXCEUTION_LOGGER =
XLoggerFactory.getXLogger("org.onap.policy.apex.executionlogging.StateFinalizerExecutionLogging");
/** the execution ID for the current APEX policy execution instance. */
public final Long executionId;
+ /** the execution properties the current APEX policy execution instance. */
+ public final Properties executionProperties;
+
/**
- * The list of state outputs for this state finalizer. The purpose of a state finalizer is to
- * select a state output for a state from this list of state output names.
+ * The list of state outputs for this state finalizer. The purpose of a state finalizer is to select a state output
+ * for a state from this list of state output names.
*/
public final Set<String> stateOutputNames;
/**
- * The fields of this state finalizer. A state finalizer receives this list of fields from a
- * task and may use these fields to determine what state output to select. Once a state
- * finalizer has selected a state output, it must marshal these fields so that they match the
- * fields required for the event defined in the state output.
+ * The fields of this state finalizer. A state finalizer receives this list of fields from a task and may use these
+ * fields to determine what state output to select. Once a state finalizer has selected a state output, it must
+ * marshal these fields so that they match the fields required for the event defined in the state output.
*/
public final Map<String, Object> fields;
private String message;
/**
- * The state output that the state finalizer logic has selected for a state. The state finalizer
- * logic sets this field in its logic after executing and the Apex engine uses this state output
- * for this state.
+ * The state output that the state finalizer logic has selected for a state. The state finalizer logic sets this
+ * field in its logic after executing and the Apex engine uses this state output for this state.
*/
private String selectedStateOutputName;
/**
- * Logger for state finalizer execution, state finalizer logic can use this field to access and
- * log to Apex logging.
+ * Logger for state finalizer execution, state finalizer logic can use this field to access and log to Apex logging.
*/
public final XLogger logger = EXCEUTION_LOGGER;
*
* @param stateFinalizerExecutor the state finalizer executor that requires context
* @param executionId the execution ID for the current APEX policy execution instance
+ * @param executionProperties the execution properties for task execution
* @param axState the state definition that is the subject of execution
* @param fields the fields to be manipulated by the state finalizer
- * @param stateOutputNames the state output names, one of which will be selected by the state
- * finalizer
- * @param internalContext the execution context of the Apex engine in which the task is being
- * executed
+ * @param stateOutputNames the state output names, one of which will be selected by the state finalizer
+ * @param internalContext the execution context of the Apex engine in which the task is being executed
*/
public StateFinalizerExecutionContext(final StateFinalizerExecutor stateFinalizerExecutor, final long executionId,
- final AxState axState, final Map<String, Object> fields, final Set<String> stateOutputNames,
- final ApexInternalContext internalContext) {
+ final Properties executionProperties, final AxState axState, final Map<String, Object> fields,
+ final Set<String> stateOutputNames, final ApexInternalContext internalContext) {
subject = new AxStateFacade(axState);
// Execution ID is the current policy execution instance
this.executionId = executionId;
+ this.executionProperties = executionProperties;
this.fields = fields;
this.stateOutputNames = stateOutputNames;
*
* @param contextAlbumName The context album name
* @return The context album
- * @throws ContextRuntimeException if the context album does not exist on the state for this
- * executor
+ * @throws ContextRuntimeException if the context album does not exist on the state for this executor
*/
public ContextAlbum getContextAlbum(final String contextAlbumName) {
// Find the context album
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.TreeMap;
import org.onap.policy.apex.context.ContextAlbum;
import org.slf4j.ext.XLoggerFactory;
/**
- * Container class for the execution context for Task logic executions in a task being executed in
- * an Apex engine. The task must have easy access to the task definition, the incoming and outgoing
- * field contexts, as well as the policy, global, and external context.
+ * Container class for the execution context for Task logic executions in a task being executed in an Apex engine. The
+ * task must have easy access to the task definition, the incoming and outgoing field contexts, as well as the policy,
+ * global, and external context.
*
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
/** the execution ID for the current APEX policy execution instance. */
public final Long executionId;
+ /** the execution properties the current APEX policy execution instance. */
+ public final Properties executionProperties;
+
/**
- * The incoming fields from the trigger event for the task. The task logic can access these
- * fields when executing its logic.
+ * The incoming fields from the trigger event for the task. The task logic can access these fields when executing
+ * its logic.
*/
public final Map<String, Object> inFields;
/**
- * The outgoing fields from the task. The task logic can access and set these fields with its
- * logic. A task outputs its result using these fields.
+ * The outgoing fields from the task. The task logic can access and set these fields with its logic. A task outputs
+ * its result using these fields.
*/
public final Map<String, Object> outFields;
*
* @param taskExecutor the task executor that requires context
* @param executionId the execution ID for the current APEX policy execution instance
+ * @param executionProperties the execution properties for task execution
* @param axTask the task definition that is the subject of execution
* @param inFields the in fields
* @param outFields the out fields
- * @param internalContext the execution context of the Apex engine in which the task is being
- * executed
+ * @param internalContext the execution context of the Apex engine in which the task is being executed
*/
- public TaskExecutionContext(final TaskExecutor taskExecutor, final long executionId, final AxTask axTask,
- final Map<String, Object> inFields, final Map<String, Object> outFields,
- final ApexInternalContext internalContext) {
+ public TaskExecutionContext(final TaskExecutor taskExecutor, final long executionId,
+ final Properties executionProperties, final AxTask axTask, final Map<String, Object> inFields,
+ final Map<String, Object> outFields, final ApexInternalContext internalContext) {
// The subject is the task definition
subject = new AxTaskFacade(axTask);
// Execution ID is the current policy execution instance
this.executionId = executionId;
+ this.executionProperties = executionProperties;
// The input and output fields
this.inFields = Collections.unmodifiableMap(inFields);
*
* @param contextAlbumName The context album name
* @return The context album
- * @throws ContextRuntimeException if the context album does not exist on the task for this
- * executor
+ * @throws ContextRuntimeException if the context album does not exist on the task for this executor
*/
public ContextAlbum getContextAlbum(final String contextAlbumName) {
// Find the context album
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.TreeMap;
import org.onap.policy.apex.context.ContextAlbum;
/** the execution ID for the current APEX policy execution instance. */
public final Long executionId;
+ /** the execution properties the current APEX policy execution instance. */
+ public final Properties executionProperties;
+
/**
* The incoming fields from the trigger event for the state. The task selection logic can access
* these fields to decide what task to select for the state.
// Execution ID is the current policy execution instance
this.executionId = executionId;
+ this.executionProperties = incomingEvent.getExecutionProperties();
// The events
inFields = incomingEvent;
* 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;
+import java.util.Properties;
+
import org.onap.policy.apex.core.engine.event.EnEvent;
import org.onap.policy.apex.core.engine.executor.ExecutorFactory;
import org.onap.policy.apex.core.engine.executor.StateMachineExecutor;
public class DummySmExecutor extends StateMachineExecutor {
private boolean cleanupWorks = false;
private boolean prepareWorks;
-
+
/**
* Constructor.
- *
+ *
* @param executorFactory the factory for executors
* @param owner the owner key
*/
super(executorFactory, owner);
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#prepare()
+ /**
+ * {@inheritDoc}
*/
@Override
public void prepare() throws StateMachineException {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#executeDirected(java.lang.long, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public EnEvent execute(final long executionId, final EnEvent incomingEvent) {
+ public EnEvent execute(final long executionId, final Properties executionProperties, final EnEvent incomingEvent) {
return incomingEvent;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp()
+ /**
+ * {@inheritDoc}
*/
@Override
public void cleanUp() throws StateMachineException {
* 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.executor;
import java.util.Map;
+import java.util.Properties;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.executor.exception.StateMachineException;
*/
public class DummyStateFinalizerExecutor extends StateFinalizerExecutor {
private boolean override;
-
+
private boolean returnBad;
public DummyStateFinalizerExecutor() {
this(false);
}
-
+
public DummyStateFinalizerExecutor(final boolean override) {
this.override = override;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#execute(java.lang.long, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public String execute(final long executionId, final Map<String, Object> newIncomingFields)
- throws StateMachineException, ContextException {
-
+ public String execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException {
+
if (!override) {
- super.execute(executionId, newIncomingFields);
+ super.execute(executionId, executionProperties, newIncomingFields);
}
-
+
if (returnBad) {
return "stateOutputBad";
- }
- else {
+ } else {
return "stateOutput1";
}
}
* 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.executor;
import java.util.Map;
+import java.util.Properties;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.event.EnEvent;
super.prepare();
}
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#execute(java.lang.long, java.lang.Object)
+
+ /**
+ * {@inheritDoc}
*/
@Override
- public Map<String, Object> execute(final long executionId, final Map<String, Object> newIncomingFields)
- throws StateMachineException, ContextException {
+ public Map<String, Object> execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException {
if (!override) {
- super.execute(executionId, newIncomingFields);
+ super.execute(executionId, executionProperties, newIncomingFields);
}
-
+
AxArtifactKey event0Key = new AxArtifactKey("Event0:0.0.1");
return new EnEvent(event0Key);
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#getSubject()
+
+ /**
+ * {@inheritDoc}
*/
@Override
public AxTask getSubject() {
if (!override) {
super.getSubject();
}
-
+
AxArtifactKey taskKey = new AxArtifactKey("FirstTask:0.0.1");
return new AxTask(taskKey);
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp()
+ /**
+ * {@inheritDoc}
*/
@Override
public void cleanUp() throws StateMachineException {
* 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.executor;
+import java.util.Properties;
+
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.event.EnEvent;
import org.onap.policy.apex.core.engine.executor.exception.StateMachineException;
private boolean override;
private static int taskNo;
-
+
public DummyTaskSelectExecutor() {
this(false);
}
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#execute(java.lang.long, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public AxArtifactKey execute(final long executionId, final EnEvent newIncomingEvent)
- throws StateMachineException, ContextException {
+ public AxArtifactKey execute(final long executionId, final Properties executionProperties,
+ final EnEvent newIncomingEvent) throws StateMachineException, ContextException {
if (!override) {
- return super.execute(executionId, newIncomingEvent);
+ return super.execute(executionId, executionProperties, newIncomingEvent);
}
-
+
return new AxArtifactKey("task" + (taskNo++) + ":0.0.1");
}
public void setTaskNo(int incomingTaskNo) {
taskNo = incomingTaskNo;
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.core.engine.executor.Executor#cleanUp()
+ /**
+ * {@inheritDoc}
*/
@Override
public void cleanUp() throws StateMachineException {
* 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=========================================================
*/
@Before
public void startMocking() {
MockitoAnnotations.initMocks(this);
-
+
Mockito.doReturn(new AxReferenceKey("Policy:0.0.1:PolName:State0")).when(axStateMock).getKey();
}
assertEquals(null, executor.getNext());
try {
- executor.executePre(0, null);
+ executor.executePre(0, null, null);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("execution pre work not implemented on class", ex.getMessage());
* 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=========================================================
*/
@Before
public void startMocking() {
MockitoAnnotations.initMocks(this);
-
+
AxState state = new AxState();
state.getStateOutputs().put("ValidOutput", null);
-
+
Mockito.doReturn(state).when(parentMock).getSubject();
Mockito.doReturn(new AxReferenceKey("State:0.0.1:StateName:StateSFL")).when(stateFinalizerLogicMock).getKey();
}
try {
- executor.executePre(0, incomingEvent);
+ executor.executePre(0, null, incomingEvent);
} catch (Exception ex) {
assertEquals("task input fields \"[InField0]\" are missing for task \"Task0:0.0.1\"", ex.getMessage());
}
try {
- executor.executePre(0, incomingEvent);
+ executor.executePre(0, null, incomingEvent);
} catch (Exception e) {
fail("test should not throw an exception");
}
try {
- executor.execute(0, incomingEvent);
+ executor.execute(0, null, incomingEvent);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("execute() not implemented on abstract StateFinalizerExecutionContext class, "
}
try {
- executor.executePre(0, incomingEvent);
+ executor.executePre(0, null, incomingEvent);
} catch (Exception ex) {
fail("test should not throw an exception");
}
}
try {
- executor.executePre(0, incomingEvent);
+ executor.executePre(0, null, incomingEvent);
} catch (Exception ex) {
fail("test should not throw an exception");
}
}
try {
- executor.executePre(0, incomingEvent);
+ executor.executePre(0, null, incomingEvent);
} catch (Exception ex) {
fail("test should not throw an exception");
}
* 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=========================================================
*/
new AxArtifactKey("OwnerKey:0.0.1"));
try {
- executor.execute(0, incomingEventMock);
+ executor.execute(0, null, incomingEventMock);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("no states defined on state machine", ex.getMessage());
assertEquals(null, executor.getNext());
try {
- executor.executePre(0, null);
+ executor.executePre(0, null, null);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("execution pre work not implemented on class", ex.getMessage());
axPolicy.setFirstState("BadState");
executor.setContext(null, axPolicy, internalContextMock);
try {
- executor.execute(0, incomingEventMock);
+ executor.execute(0, null, incomingEventMock);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("first state not defined on state machine", ex.getMessage());
axPolicy.setFirstState("state0");
executor.setContext(null, axPolicy, internalContextMock);
try {
- executor.execute(0, incomingEventMock);
+ executor.execute(0, null, incomingEventMock);
} catch (Exception ex) {
fail("test should not throw an exception");
}
dummyTsle.setTaskNo(0);
try {
- executor.execute(0, incomingEventMock);
+ executor.execute(0, null, incomingEventMock);
} catch (Exception ex) {
fail("test should not throw an exception");
}
axPolicy.getStateMap().get("State1").getStateOutputs().get("stateOutput1").setNextState(badStateKey);
dummyTsle.setTaskNo(0);
try {
- executor.execute(0, incomingEventMock);
+ executor.execute(0, null, incomingEventMock);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("state execution failed, next state \"Policy:0.0.1:PName:BadState\" not found",
.setNextState(AxReferenceKey.getNullKey());
dummyTsle.setTaskNo(0);
try {
- executor.execute(0, incomingEventMock);
+ executor.execute(0, null, incomingEventMock);
} catch (Exception ex) {
fail("test should not throw an exception");
}
axPolicy.getStateMap().get("State1").setTrigger(new AxArtifactKey("BadTrigger:0.0.1"));
dummyTsle.setTaskNo(0);
try {
- executor.execute(0, incomingEventMock);
+ executor.execute(0, null, incomingEventMock);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("incoming event \"Event1:0.0.1\" does not match trigger \"BadTrigger:0.0.1\" "
axPolicy.getStateMap().get("State1").setTrigger(new AxArtifactKey("Event1:0.0.1"));
dummyTsle.setTaskNo(0);
try {
- executor.execute(0, incomingEventMock);
+ executor.execute(0, null, incomingEventMock);
} catch (Exception ex) {
fail("test should not throw an exception");
}
dummyTsle.setTaskNo(0);
try {
- executor.execute(0, incomingEventMock);
+ executor.execute(0, null, incomingEventMock);
} catch (Exception ex) {
fail("test should not throw an exception");
}
dummyTsle.setTaskNo(0);
try {
- executor.execute(0, incomingEventMock);
+ executor.execute(0, null, incomingEventMock);
} catch (Exception ex) {
fail("test should not throw an exception");
}
dummyTsle.setTaskNo(0);
dummySfle.setReturnBad(true);
try {
- executor.execute(0, incomingEventMock);
+ executor.execute(0, null, incomingEventMock);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("State execution of state \"Policy:0.0.1:NULL:state1\" on task \"task1:0.0.1\" failed: "
dummyTsle.setTaskNo(0);
dummySfle.setReturnBad(false);
try {
- executor.execute(0, incomingEventMock);
+ executor.execute(0, null, incomingEventMock);
} catch (Exception ex) {
fail("test should not throw an exception");
}
* 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=========================================================
*/
Map<String, Object> incomingFields = new LinkedHashMap<>();
try {
- executor.executePre(0, incomingFields);
+ executor.executePre(0, null, incomingFields);
} catch (Exception ex) {
assertEquals("task input fields \"[InField0]\" are missing for task \"Task0:0.0.1\"", ex.getMessage());
}
incomingFields.put("InField0", "A Value");
try {
- executor.executePre(0, incomingFields);
+ executor.executePre(0, null, incomingFields);
} catch (Exception e) {
fail("test should not throw an exception");
}
try {
- executor.execute(0, incomingFields);
+ executor.execute(0, null, incomingFields);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("execute() not implemented on abstract TaskExecutor class, only on its subclasses",
* 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=========================================================
*/
AxReferenceKey state0Key = new AxReferenceKey("State0Parent:0.0.1:Parent:State0");
Mockito.doReturn(state0Key).when(axStateMock).getKey();
Mockito.doReturn(state0Key.getId()).when(axStateMock).getId();
-
+
Map<AxArtifactKey, AxStateTaskReference> taskReferences = new LinkedHashMap<>();
taskReferences.put(new AxArtifactKey("Task0:0.0.0"), null);
taskReferences.put(new AxArtifactKey("Task1:0.0.0"), null);
}
try {
- executor.executePre(0, incomingEvent);
+ executor.executePre(0, null, incomingEvent);
} catch (Exception ex) {
assertEquals("task input fields \"[InField0]\" are missing for task \"Task0:0.0.1\"", ex.getMessage());
}
try {
- executor.executePre(0, incomingEvent);
+ executor.executePre(0, null, incomingEvent);
} catch (Exception e) {
fail("test should not throw an exception");
}
try {
- executor.execute(0, incomingEvent);
+ executor.execute(0, null, incomingEvent);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("execute() not implemented on class", ex.getMessage());
}
try {
- executor.executePre(0, incomingEvent);
+ executor.executePre(0, null, incomingEvent);
} catch (Exception e) {
fail("test should not throw an exception");
}
}
try {
- executor.executePre(0, incomingEvent);
+ executor.executePre(0, null, incomingEvent);
} catch (Exception e) {
fail("test should not throw an exception");
}
assertEquals("task \"IDontExist:0.0.0\" returned by task selection logic not defined "
+ "on state \"State0Parent:0.0.1:Parent:State0\"", ex.getMessage());
}
-
+
try {
- executor.executePre(0, incomingEvent);
+ executor.executePre(0, null, incomingEvent);
} catch (Exception e) {
fail("test should not throw an exception");
}
executor.getOutgoing().setName("Task0");
-
+
try {
executor.executePost(true);
assertEquals("Task0", executor.getOutgoing().getName());
* 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=========================================================
*/
final Map<String, Object> fields = new LinkedHashMap<>();
final Set<String> stateOutputNames = new LinkedHashSet<>();
- StateFinalizerExecutionContext sfec = new StateFinalizerExecutionContext(stateFinalizerExecutorMock, 0,
+ StateFinalizerExecutionContext sfec = new StateFinalizerExecutionContext(stateFinalizerExecutorMock, 0, null,
axStateMock, fields, stateOutputNames, internalContextMock);
assertNotNull(sfec);
* 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=========================================================
*/
final Map<String, Object> inFields = new LinkedHashMap<>();
final Map<String, Object> outFields = new LinkedHashMap<>();
- TaskExecutionContext tec = new TaskExecutionContext(taskExecutorMock, 0, axTaskMock, inFields, outFields,
+ TaskExecutionContext tec = new TaskExecutionContext(taskExecutorMock, 0, null, axTaskMock, inFields, outFields,
internalContextMock);
assertNotNull(tec);
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventConsumer#start()
+ /**
+ * {@inheritDoc}
*/
@Override
public void start() {
consumerThread.start();
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventConsumer#getName()
+ /**
+ * {@inheritDoc}
*/
@Override
public String getName() {
return name;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventConsumer#getPeeredReference(org.onap.policy.apex.service.
- * parameters. eventhandler.EventHandlerPeeredMode)
+ /**
+ * {@inheritDoc}
*/
@Override
public PeeredReference getPeeredReference(final EventHandlerPeeredMode peeredMode) {
}
}
- /*
- * (non-Javadoc)
- *
- * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
+ /**
+ * {@inheritDoc}
*/
@Override
public void onMessage(final Message jmsMessage) {
jmsMessage.getJMSType());
}
- eventReceiver.receiveEvent(jmsMessage);
+ eventReceiver.receiveEvent(null, jmsMessage);
} catch (final Exception e) {
final String errorMessage = "failed to receive message from JMS";
LOGGER.warn(errorMessage, e);
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.apps.uservice.producer.ApexEventProducer#stop()
+ /**
+ * {@inheritDoc}
*/
@Override
public void stop() {
import java.io.Serializable;
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
*/
@Override
public void init(final String producerName, final EventHandlerParameters producerParameters)
- throws ApexEventException {
+ throws ApexEventException {
this.name = producerName;
// Check and get the JMS Properties
if (!(producerParameters.getCarrierTechnologyParameters() instanceof JmsCarrierTechnologyParameters)) {
- final String errorMessage = "specified producer properties are not applicable to a JMS producer ("
- + this.name + ")";
+ final String errorMessage =
+ "specified producer properties are not applicable to a JMS producer (" + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
// Check if we actually got a connection factory
if (connectionFactory == null) {
throw new IllegalArgumentException(
- "JMS context lookup of \"" + jmsProducerProperties.getConnectionFactory()
- + "\" returned null for producer (" + this.name + ")");
+ "JMS context lookup of \"" + jmsProducerProperties.getConnectionFactory()
+ + "\" returned null for producer (" + this.name + ")");
}
} catch (final Exception e) {
final String errorMessage = "lookup of JMS connection factory \""
- + jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \""
- + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
+ + jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \""
+ + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
// Check if we actually got a topic
if (jmsOutgoingTopic == null) {
throw new IllegalArgumentException("JMS context lookup of \"" + jmsProducerProperties.getProducerTopic()
- + "\" returned null for producer (" + this.name + ")");
+ + "\" returned null for producer (" + this.name + ")");
}
} catch (final Exception e) {
final String errorMessage = "lookup of JMS topic \"" + jmsProducerProperties.getProducerTopic()
- + "\" failed for JMS producer properties \""
- + jmsProducerProperties.getJmsProducerProperties() + FOR_PRODUCER_TAG + this.name + ")";
+ + "\" failed for JMS producer properties \"" + jmsProducerProperties.getJmsProducerProperties()
+ + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
// Create and start a connection to the JMS server
try {
connection = connectionFactory.createConnection(jmsProducerProperties.getSecurityPrincipal(),
- jmsProducerProperties.getSecurityCredentials());
+ jmsProducerProperties.getSecurityCredentials());
connection.start();
} catch (final Exception e) {
final String errorMessage = "connection to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
} catch (final Exception e) {
final String errorMessage = "creation of session to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
try {
messageProducer = jmsSession.createProducer(jmsOutgoingTopic);
} catch (final Exception e) {
- final String errorMessage = "creation of producer for sending events "
- + "to JMS server failed for JMS properties \""
+ final String errorMessage =
+ "creation of producer for sending events " + "to JMS server failed for JMS properties \""
+ jmsProducerProperties.getJmsConsumerProperties() + "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
* java.lang.Object)
*/
@Override
- public void sendEvent(final long executionId, final String eventname, final Object eventObject) {
+ public void sendEvent(final long executionId, final Properties executionProperties, final String eventname,
+ final Object eventObject) {
// Check if this is a synchronized event, if so we have received a reply
- final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) peerReferenceMap
- .get(EventHandlerPeeredMode.SYNCHRONOUS);
+ final SynchronousEventCache synchronousEventCache =
+ (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
if (synchronousEventCache != null) {
synchronousEventCache.removeCachedEventToApexIfExists(executionId);
}
// Check if the object to be sent is serializable
if (!Serializable.class.isAssignableFrom(eventObject.getClass())) {
final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name
- + ", object of type \"" + eventObject.getClass().getCanonicalName()
- + "\" is not serializable";
+ + ", object of type \"" + eventObject.getClass().getCanonicalName() + "\" is not serializable";
LOGGER.warn(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
jmsMessage = jmsSession.createObjectMessage((Serializable) eventObject);
} catch (final Exception e) {
final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name
- + ", could not create JMS Object Message for object \"" + eventObject;
+ + ", could not create JMS Object Message for object \"" + eventObject;
LOGGER.warn(errorMessage, e);
throw new ApexEventRuntimeException(errorMessage);
}
jmsMessage = jmsSession.createTextMessage(eventObject.toString());
} catch (final Exception e) {
final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name
- + ", could not create JMS Text Message for object \"" + eventObject;
+ + ", could not create JMS Text Message for object \"" + eventObject;
LOGGER.warn(errorMessage, e);
throw new ApexEventRuntimeException(errorMessage);
}
messageProducer.send(jmsMessage);
} catch (final Exception e) {
final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name
- + ", send failed for object \"" + eventObject;
+ + ", send failed for object \"" + eventObject;
LOGGER.warn(errorMessage, e);
throw new ApexEventRuntimeException(errorMessage);
}
synchronousEventCache);
ApexEvent apexEvent = new ApexEvent("testEvent", "testVersion", "testNameSpace",
"testSource", "testTarget");
- apexJmsProducer.sendEvent(1000L, "TestApexJmsProducer", apexEvent);
+ apexJmsProducer.sendEvent(1000L, null, "TestApexJmsProducer", apexEvent);
}
@Test(expected = ApexEventRuntimeException.class)
apexJmsConsumer, apexJmsProducer, DEFAULT_SYNCHRONOUS_EVENT_TIMEOUT);
apexJmsProducer.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS,
synchronousEventCache);
- apexJmsProducer.sendEvent(-1L, "TestApexJmsProducer", new ApexJmsProducerTest());
+ apexJmsProducer.sendEvent(-1L, null, "TestApexJmsProducer", new ApexJmsProducerTest());
}
@Test
kafkaConsumer.poll(kafkaConsumerProperties.getConsumerPollDuration().toMillis());
for (final ConsumerRecord<String, String> record : records) {
traceIfTraceEnabled(record);
- eventReceiver.receiveEvent(record.value());
+ eventReceiver.receiveEvent(null, record.value());
}
} catch (final Exception e) {
LOGGER.warn("error receiving events on thread {}", consumerThread.getName(), e);
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.Producer;
if (!(producerParameters.getCarrierTechnologyParameters() instanceof KafkaCarrierTechnologyParameters)) {
String message = "specified producer properties are not applicable to a Kafka producer (" + this.name + ")";
LOGGER.warn(message);
- throw new ApexEventException(
- message);
+ throw new ApexEventException(message);
}
kafkaProducerProperties =
(KafkaCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
* java.lang.Object)
*/
@Override
- public void sendEvent(final long executionId, final String eventName, final Object event) {
+ public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
+ final Object event) {
// Check if this is a synchronized event, if so we have received a reply
final SynchronousEventCache synchronousEventCache =
(SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
public static final String KAFKA_EVENT_CONSUMER_PLUGIN_CLASS = ApexKafkaConsumer.class.getName();
// Repeated strings in messages
- private static final String SPECIFY_AS_STRING_MESSAGE = "not specified, must be specified as a string";
private static final String ENTRY = "entry ";
private static final String KAFKA_PROPERTIES = "kafkaProperties";
}
// Send the event into Apex
- eventReceiver.receiveEvent(eventJsonString);
+ eventReceiver.receiveEvent(null, eventJsonString);
} catch (final Exception e) {
LOGGER.warn("error receiving events on thread {}", consumerThread.getName(), e);
}
/**
* Hook for unit test mocking of HTTP client.
- *
+ *
* @param client the mocked client
*/
protected void setClient(final Client client) {
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
*/
@Override
public void init(final String producerName, final EventHandlerParameters producerParameters)
- throws ApexEventException {
+ throws ApexEventException {
this.name = producerName;
// Check and get the REST Properties
if (!(producerParameters.getCarrierTechnologyParameters() instanceof RestClientCarrierTechnologyParameters)) {
- final String errorMessage = "specified producer properties are not applicable to REST client producer ("
- + this.name + ")";
+ final String errorMessage =
+ "specified producer properties are not applicable to REST client producer (" + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
- restProducerProperties = (RestClientCarrierTechnologyParameters) producerParameters
- .getCarrierTechnologyParameters();
+ restProducerProperties =
+ (RestClientCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
// Check if the HTTP method has been set
if (restProducerProperties.getHttpMethod() == null) {
}
if (!RestClientCarrierTechnologyParameters.HttpMethod.POST.equals(restProducerProperties.getHttpMethod())
- && !RestClientCarrierTechnologyParameters.HttpMethod.PUT.equals(restProducerProperties.getHttpMethod())) {
+ && !RestClientCarrierTechnologyParameters.HttpMethod.PUT
+ .equals(restProducerProperties.getHttpMethod())) {
final String errorMessage = "specified HTTP method of \"" + restProducerProperties.getHttpMethod()
- + "\" is invalid, only HTTP methods \"POST\" and \"PUT\" are supproted "
- + "for event sending on REST client producer (" + this.name + ")";
+ + "\" is invalid, only HTTP methods \"POST\" and \"PUT\" are supproted "
+ + "for event sending on REST client producer (" + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
* java.lang.Object)
*/
@Override
- public void sendEvent(final long executionId, final String eventName, final Object event) {
+ public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
+ final Object event) {
// Check if this is a synchronized event, if so we have received a reply
- final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) peerReferenceMap
- .get(EventHandlerPeeredMode.SYNCHRONOUS);
+ final SynchronousEventCache synchronousEventCache =
+ (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
if (synchronousEventCache != null) {
synchronousEventCache.removeCachedEventToApexIfExists(executionId);
}
// Check that the request worked
if (response.getStatus() != Response.Status.OK.getStatusCode()) {
final String errorMessage = "send of event to URL \"" + restProducerProperties.getUrl() + "\" using HTTP \""
- + restProducerProperties.getHttpMethod() + "\" failed with status code " + response.getStatus()
- + " and message \"" + response.readEntity(String.class) + "\", event:\n" + event;
+ + restProducerProperties.getHttpMethod() + "\" failed with status code " + response.getStatus()
+ + " and message \"" + response.readEntity(String.class) + "\", event:\n" + event;
LOGGER.warn(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("event sent from engine using {} to URL {} with HTTP {} : {} and response {} ", this.name,
- restProducerProperties.getUrl(), restProducerProperties.getHttpMethod(), event, response);
+ restProducerProperties.getUrl(), restProducerProperties.getHttpMethod(), event, response);
}
}
// We have already checked that it is a PUT or POST request
if (RestClientCarrierTechnologyParameters.HttpMethod.POST.equals(restProducerProperties.getHttpMethod())) {
return client.target(restProducerProperties.getUrl()).request("application/json")
- .headers(restProducerProperties.getHttpHeadersAsMultivaluedMap()).post(Entity.json(event));
+ .headers(restProducerProperties.getHttpHeadersAsMultivaluedMap()).post(Entity.json(event));
} else {
return client.target(restProducerProperties.getUrl()).request("application/json")
- .headers(restProducerProperties.getHttpHeadersAsMultivaluedMap()).put(Entity.json(event));
+ .headers(restProducerProperties.getHttpHeadersAsMultivaluedMap()).put(Entity.json(event));
}
}
/**
* Hook for unit test mocking of HTTP client.
- *
+ *
* @param client the mocked client
*/
protected void setClient(final Client client) {
* 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=========================================================
*/
arcp.setClient(httpClientMock);
try {
- arcp.sendEvent(123, "EventName", "This is an Event");
+ arcp.sendEvent(123, null, "EventName", "This is an Event");
arcp.stop();
} catch (Exception ex) {
fail("test should not throw an exception");
arcp.setClient(httpClientMock);
try {
- arcp.sendEvent(123, "EventName", "This is an Event");
+ arcp.sendEvent(123, null, "EventName", "This is an Event");
arcp.stop();
} catch (Exception e) {
fail("test should not throw an exception");
arcp.setClient(httpClientMock);
try {
- arcp.sendEvent(123, "EventName", "This is an Event");
+ arcp.sendEvent(123, null, "EventName", "This is an Event");
arcp.stop();
} catch (Exception e) {
fail("test should not throw an exception");
arcp.setClient(httpClientMock);
try {
- arcp.sendEvent(123, "EventName", "This is an Event");
+ arcp.sendEvent(123, null, "EventName", "This is an Event");
arcp.stop();
} catch (Exception e) {
fail("test should not throw an exception");
arcp.setClient(httpClientMock);
try {
- arcp.sendEvent(123, "EventName", "This is an Event");
+ arcp.sendEvent(123, null, "EventName", "This is an Event");
fail("test should throw an exception here");
} catch (Exception e) {
assertEquals(
* 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.plugins.event.carrier.restclient;
+import java.util.Properties;
+
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventReceiver;
private Object lastEvent;
private int eventCount;
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.onap.policy.apex.service.engine.event.ApexEventReceiver#receiveEvent(long, java.lang.Object)
*/
@Override
- public void receiveEvent(long executionId, Object event) throws ApexEventException {
+ public void receiveEvent(final long executionId, final Properties executionProperties, final Object event)
+ throws ApexEventException {
this.lastExecutionId = executionId;
this.lastEvent = event;
this.eventCount++;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.onap.policy.apex.service.engine.event.ApexEventReceiver#receiveEvent(java.lang.Object)
*/
@Override
- public void receiveEvent(Object event) throws ApexEventException {
+ public void receiveEvent(final Properties executionProperties, final Object event) throws ApexEventException {
this.lastEvent = event;
this.eventCount++;
}
/**
* Get the number of events received.
- *
+ *
* @return the number of events received
*/
public int getEventCount() {
}
// Send the event into Apex
- eventReceiver.receiveEvent(request.getExecutionId(), eventJsonString);
+ eventReceiver.receiveEvent(request.getExecutionId(), null, eventJsonString);
synchronized (eventsReceivedLock) {
eventsReceived++;
/**
* Execute the REST request.
*
- *
+ *
* @return the response to the REST request
*/
public Response sendEventAsRestRequest() {
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import org.onap.policy.apex.service.engine.event.ApexEventConsumer;
import org.onap.policy.apex.service.engine.event.ApexEventException;
* java.lang.Object)
*/
@Override
- public void sendEvent(final long executionId, final String eventName, final Object event) {
+ public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
+ final Object event) {
// Check if this is a synchronized event, if so we have received a reply
final SynchronousEventCache synchronousEventCache =
(SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
* 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=========================================================
*/
String event = "This is the event";
try {
- producer.sendEvent(12345, eventName, event);
+ producer.sendEvent(12345, null, eventName, event);
fail("test should throw an exception here");
} catch (Exception aee) {
assertEquals("send of event to URL \"null\" failed, REST response consumer is not defined\n"
PeeredReference peeredReference = new PeeredReference(EventHandlerPeeredMode.REQUESTOR, consumer, producer);
producer.setPeeredReference(EventHandlerPeeredMode.REQUESTOR, peeredReference);
try {
- producer.sendEvent(12345, eventName, event);
+ producer.sendEvent(12345, null, eventName, event);
fail("test should throw an exception here");
} catch (Exception aee) {
assertEquals("send of event to URL \"null\" failed, REST response consumer "
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
-
+
// The REST parameters read from the parameter service
RestServerCarrierTechnologyParameters restConsumerProperties =
(RestServerCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
try {
// Send the event into Apex
- eventReceiver.receiveEvent(executionId, event);
+ eventReceiver.receiveEvent(executionId, null, event);
} catch (final Exception e) {
final String errorMessage = "error receiving events on event consumer " + name + ", " + e.getMessage();
LOGGER.warn(errorMessage, e);
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventProducer;
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
-
+
// The REST carrier properties
RestServerCarrierTechnologyParameters restProducerProperties =
(RestServerCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
* java.lang.Object)
*/
@Override
- public void sendEvent(final long executionId, final String eventName, final Object event) {
+ public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
+ final Object event) {
if (LOGGER.isDebugEnabled()) {
String message = name + ": event " + executionId + ':' + eventName + " recevied from Apex, event=" + event;
LOGGER.debug(message);
* 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.plugins.event.carrier.restserver;
+import java.util.Properties;
+
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventReceiver;
private Object lastEvent;
private int eventCount;
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.onap.policy.apex.service.engine.event.ApexEventReceiver#receiveEvent(long, java.lang.Object)
*/
@Override
- public void receiveEvent(long executionId, Object event) throws ApexEventException {
+ public void receiveEvent(final long executionId, final Properties executionProperties, final Object event)
+ throws ApexEventException {
this.lastExecutionId = executionId;
this.lastEvent = event;
this.eventCount++;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.onap.policy.apex.service.engine.event.ApexEventReceiver#receiveEvent(java.lang.Object)
*/
@Override
- public void receiveEvent(Object event) throws ApexEventException {
+ public void receiveEvent(final Properties executionProperties, final Object event) throws ApexEventException {
this.lastEvent = event;
this.eventCount++;
}
/**
* Get the number of events received.
- *
+ *
* @return the number of events received
*/
public int getEventCount() {
LOGGER.warn("specified consumer properties are not applicable to a web socket consumer");
throw new ApexEventException("specified consumer properties are not applicable to a web socket consumer");
}
-
+
// The Web Socket properties
WebSocketCarrierTechnologyParameters webSocketConsumerProperties =
(WebSocketCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
@Override
public void receiveString(final String eventString) {
try {
- eventReceiver.receiveEvent(eventString);
+ eventReceiver.receiveEvent(null, eventString);
eventsRead++;
} catch (final Exception e) {
final String errorMessage = "Error sending event " + name + '_' + eventsRead + ", " + e.getMessage()
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageClient;
@Override
public void init(final String producerName, final EventHandlerParameters producerParameters)
- throws ApexEventException {
+ throws ApexEventException {
this.name = producerName;
// Check and get the web socket Properties
if (!(producerParameters.getCarrierTechnologyParameters() instanceof WebSocketCarrierTechnologyParameters)) {
- String message = "specified producer properties for " + this.name
- + "are not applicable to a web socket producer";
+ String message =
+ "specified producer properties for " + this.name + "are not applicable to a web socket producer";
LOGGER.warn(message);
throw new ApexEventException("specified producer properties are not applicable to a web socket producer");
}
// The Web Socket properties
WebSocketCarrierTechnologyParameters webSocketProducerProperties =
- (WebSocketCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
+ (WebSocketCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
// Check if this is a server or a client Web Socket
if (webSocketProducerProperties.isWsClient()) {
// Create a WS client
wsStringMessager = new WsStringMessageClient(webSocketProducerProperties.getHost(),
- webSocketProducerProperties.getPort());
+ webSocketProducerProperties.getPort());
} else {
wsStringMessager = new WsStringMessageServer(webSocketProducerProperties.getPort());
}
* java.lang.Object)
*/
@Override
- public void sendEvent(final long executionId, final String eventName, final Object event) {
+ public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
+ final Object event) {
// Check if this is a synchronized event, if so we have received a reply
- final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) peerReferenceMap
- .get(EventHandlerPeeredMode.SYNCHRONOUS);
+ final SynchronousEventCache synchronousEventCache =
+ (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
if (synchronousEventCache != null) {
synchronousEventCache.removeCachedEventToApexIfExists(executionId);
}
@Override
public void receiveString(final String messageString) {
String message = "received message \"" + messageString + "\" on web socket producer (" + this.name
- + ") , no messages should be received on a web socket producer";
+ + ") , no messages should be received on a web socket producer";
LOGGER.warn(message);
}
}
apexWebSocketConsumer, apexWebSocketProducer, DEFAULT_SYNCHRONOUS_EVENT_TIMEOUT);
apexWebSocketProducer.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS,
synchronousEventCache);
- apexWebSocketProducer.sendEvent(1000L, "TestApexWebSocketProducer", "apexEvent");
+ apexWebSocketProducer.sendEvent(1000L, null, "TestApexWebSocketProducer", "apexEvent");
}
@Test
import java.lang.reflect.Method;
import java.util.Map;
+import java.util.Properties;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.executor.StateFinalizerExecutor;
* Executes the executor for the state finalizer logic in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingFields the incoming fields for finalisation
* @return The state output for the state
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public String execute(final long executionId, final Map<String, Object> incomingFields)
- throws StateMachineException, ContextException {
+ public String execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingFields);
+ executePre(executionId, executionProperties, incomingFields);
// Check and execute the Java logic
boolean returnValue = false;
// StateFinalizerExecutionContext executor) throws ApexException"
// to invoke the
// task logic in the Java class
- final Method method = stateFinalizerLogicObject.getClass().getDeclaredMethod("getStateOutput", (Class[])
+ final Method method = stateFinalizerLogicObject.getClass().getDeclaredMethod("getStateOutput",
new Class[] { StateFinalizerExecutionContext.class });
returnValue = (boolean) method.invoke(stateFinalizerLogicObject, getExecutionContext());
} catch (final Exception e) {
import java.lang.reflect.Method;
import java.util.Map;
+import java.util.Properties;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.executor.TaskExecutor;
* Executes the executor for the task in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingFields the incoming fields
* @return The outgoing fields
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public Map<String, Object> execute(final long executionId, final Map<String, Object> incomingFields)
- throws StateMachineException, ContextException {
+ public Map<String, Object> execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingFields);
+ executePre(executionId, executionProperties, incomingFields);
// Check and execute the Java logic
boolean returnValue = false;
// Find and call the method with the signature "public boolean getEvent(final TaskExecutionContext executor)
// throws ApexException" to invoke the
// task logic in the Java class
- final Method method = taskLogicObject.getClass().getDeclaredMethod("getEvent", (Class[])
+ final Method method = taskLogicObject.getClass().getDeclaredMethod("getEvent",
new Class[] { TaskExecutionContext.class });
returnValue = (boolean) method.invoke(taskLogicObject, getExecutionContext());
} catch (final Exception e) {
package org.onap.policy.apex.plugins.executor.java;
import java.lang.reflect.Method;
+import java.util.Properties;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.event.EnEvent;
// Create the task logic object from the byte code of the class
taskSelectionLogicObject = Class.forName(getSubject().getTaskSelectionLogic().getLogic()).newInstance();
} catch (final Exception e) {
- LOGGER.error("instantiation error on Java class \"" + getSubject().getTaskSelectionLogic().getLogic()
- + "\"", e);
- throw new StateMachineException("instantiation error on Java class \""
- + getSubject().getTaskSelectionLogic().getLogic() + "\"", e);
+ LOGGER.error(
+ "instantiation error on Java class \"" + getSubject().getTaskSelectionLogic().getLogic() + "\"", e);
+ throw new StateMachineException(
+ "instantiation error on Java class \"" + getSubject().getTaskSelectionLogic().getLogic() + "\"", e);
}
}
* Executes the executor for the task in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingEvent the incoming event
* @return The outgoing event
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public AxArtifactKey execute(final long executionId, final EnEvent incomingEvent)
- throws StateMachineException, ContextException {
+ public AxArtifactKey execute(final long executionId, final Properties executionProperties,
+ final EnEvent incomingEvent) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingEvent);
+ executePre(executionId, executionProperties, incomingEvent);
// Check and execute the Java logic
boolean returnValue = false;
// executor)" to invoke the task selection
// logic in the Java class
final Method method = taskSelectionLogicObject.getClass().getDeclaredMethod("getTask",
- (Class[]) new Class[] { TaskSelectionExecutionContext.class });
+ new Class[] { TaskSelectionExecutionContext.class });
returnValue = (boolean) method.invoke(taskSelectionLogicObject, getExecutionContext());
} catch (final Exception e) {
- LOGGER.error("execute: task selection logic failed to run for state \"" + getSubject().getKey().getId()
- + "\"", e);
+ LOGGER.error(
+ "execute: task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\"",
+ e);
throw new StateMachineException(
- "task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\"",
- e);
+ "task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\"", e);
}
// Do the execution post work
@Override
public void cleanUp() throws StateMachineException {
LOGGER.debug("cleanUp:" + getSubject().getKey().getId() + ","
- + getSubject().getTaskSelectionLogic().getLogicFlavour() + ","
- + getSubject().getTaskSelectionLogic().getLogic());
+ + getSubject().getTaskSelectionLogic().getLogicFlavour() + ","
+ + getSubject().getTaskSelectionLogic().getLogic());
}
}
* 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=========================================================
*/
}
try {
- jsfe.execute(-1, null);
+ jsfe.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("state finalizer logic failed to run for state finalizer \"NULL:0.0.0:NULL:NULL\"",
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
try {
- jsfe.execute(-1, event);
+ jsfe.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("state finalizer logic failed to run for state finalizer \"NULL:0.0.0:NULL:NULL\"",
stateFinalizerLogic.setLogic("org.onap.policy.apex.plugins.executor.java.DummyJavaStateFinalizerLogic");
try {
jsfe.prepare();
- jsfe.execute(-1, event);
+ jsfe.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("execute-post: state finalizer logic execution failure on state \"NULL:0.0.0:NULL:NULL\" "
state.getStateOutputs().put("SelectedOutputIsMe", null);
try {
jsfe.prepare();
- String stateOutput = jsfe.execute(0, event);
+ String stateOutput = jsfe.execute(0, null, event);
assertEquals("SelectedOutputIsMe", stateOutput);
jsfe.cleanUp();
} catch (Exception jtseException) {
* 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=========================================================
*/
}
try {
- jte.execute(-1, null);
+ jte.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals(java.lang.NullPointerException.class, jteException.getClass());
Map<String, Object> incomingParameters = new HashMap<>();
try {
- jte.execute(-1, incomingParameters);
+ jte.execute(-1, null, incomingParameters);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("task logic failed to run for task \"NULL:0.0.0\"", jteException.getMessage());
task.getTaskLogic().setLogic("org.onap.policy.apex.plugins.executor.java.DummyJavaTaskLogic");
try {
jte.prepare();
- jte.execute(-1, incomingParameters);
+ jte.execute(-1, null, incomingParameters);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0",
try {
jte.prepare();
- Map<String, Object> returnMap = jte.execute(0, incomingParameters);
+ Map<String, Object> returnMap = jte.execute(0, null, incomingParameters);
assertEquals(0, returnMap.size());
jte.cleanUp();
} catch (Exception jteException) {
* 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=========================================================
*/
}
try {
- jtse.execute(-1, null);
+ jtse.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(java.lang.NullPointerException.class, jtseException.getClass());
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
try {
- jtse.execute(-1, event);
+ jtse.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("task selection logic failed to run for state \"NULL:0.0.0:NULL:NULL\"",
.setLogic("org.onap.policy.apex.plugins.executor.java.DummyJavaTaskSelectionLogic");
try {
jtse.prepare();
- jtse.execute(-1, event);
+ jtse.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"",
try {
jtse.prepare();
- AxArtifactKey taskKey = jtse.execute(0, event);
+ AxArtifactKey taskKey = jtse.execute(0, null, event);
assertEquals("NULL:0.0.0", taskKey.getId());
jtse.cleanUp();
} catch (Exception jtseException) {
package org.onap.policy.apex.plugins.executor.javascript;
import java.util.Map;
+import java.util.Properties;
+
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.ScriptEngine;
import org.slf4j.ext.XLoggerFactory;
/**
- * The Class JavascriptStateFinalizerExecutor is the state finalizer executor for state finalizer
- * logic written in Javascript It is unlikely that this is thread safe.
+ * The Class JavascriptStateFinalizerExecutor is the state finalizer executor for state finalizer logic written in
+ * Javascript It is unlikely that this is thread safe.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
* Executes the executor for the state finalizer logic in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingFields the incoming fields for finalisation
* @return The state output for the state
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public String execute(final long executionId, final Map<String, Object> incomingFields)
- throws StateMachineException, ContextException {
+ public String execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingFields);
+ executePre(executionId, executionProperties, incomingFields);
// Set up the Javascript engine
engine.put("executor", getExecutionContext());
package org.onap.policy.apex.plugins.executor.javascript;
import java.util.Map;
+import java.util.Properties;
+
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.ScriptEngine;
import org.slf4j.ext.XLoggerFactory;
/**
- * The Class JavascriptTaskExecutor is the task executor for task logic written in Javascript It is
- * unlikely that this is thread safe.
+ * The Class JavascriptTaskExecutor is the task executor for task logic written in Javascript It is unlikely that this
+ * is thread safe.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
* Executes the executor for the task in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingFields the incoming fields
* @return The outgoing fields
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public Map<String, Object> execute(final long executionId, final Map<String, Object> incomingFields)
- throws StateMachineException, ContextException {
+ public Map<String, Object> execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingFields);
+ executePre(executionId, executionProperties, incomingFields);
// Set up the Javascript engine
engine.put("executor", getExecutionContext());
package org.onap.policy.apex.plugins.executor.javascript;
+import java.util.Properties;
+
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.ScriptEngine;
import org.slf4j.ext.XLoggerFactory;
/**
- * The Class JavascriptTaskSelectExecutor is the task selection executor for task selection logic
- * written in Javascript It is unlikely that this is thread safe.
+ * The Class JavascriptTaskSelectExecutor is the task selection executor for task selection logic written in Javascript
+ * It is unlikely that this is thread safe.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
* Executes the executor for the task in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingEvent the incoming event
* @return The outgoing event
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public AxArtifactKey execute(final long executionId, final EnEvent incomingEvent)
- throws StateMachineException, ContextException {
+ public AxArtifactKey execute(final long executionId, final Properties executionProperties,
+ final EnEvent incomingEvent) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingEvent);
+ executePre(executionId, executionProperties, incomingEvent);
// Set up the Javascript engine
engine.put("executor", getExecutionContext());
Map<String, Object> incomingParameters1 = new HashMap<>();
try {
- jsfe.execute(-1, incomingParameters1);
+ jsfe.execute(-1, null, incomingParameters1);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("state finalizer logic failed to run for state finalizer \"NULL:0.0.0:NULL:NULL\"",
+ "var returnValue = new returnValueType(true);}");
try {
jsfe.prepare();
- jsfe.execute(-1, event);
+ jsfe.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(
state.getStateOutputs().put("SelectedOutputIsMe", null);
try {
jsfe.prepare();
- String stateOutput = jsfe.execute(0, event);
+ String stateOutput = jsfe.execute(0, null, event);
assertEquals("SelectedOutputIsMe", stateOutput);
jsfe.cleanUp();
} catch (Exception jtseException) {
Map<String, Object> incomingParameters2 = new HashMap<>();
try {
- jte.execute(-1, incomingParameters2);
+ jte.execute(-1, null, incomingParameters2);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("task logic failed to run for task \"NULL:0.0.0\"", jteException.getMessage());
}
try {
- jte.execute(-1, null);
+ jte.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals(java.lang.NullPointerException.class, jteException.getClass());
Map<String, Object> incomingParameters = new HashMap<>();
try {
- jte.execute(-1, incomingParameters);
+ jte.execute(-1, null, incomingParameters);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("execute: task logic failed to set a return value for task \"NULL:0.0.0\"",
+ "var returnValue = new returnValueType(false); ");
try {
jte.prepare();
- jte.execute(-1, incomingParameters);
+ jte.execute(-1, null, incomingParameters);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0",
+ "var returnValue = new returnValueType(true); ");
try {
jte.prepare();
- Map<String, Object> returnMap = jte.execute(0, incomingParameters);
+ Map<String, Object> returnMap = jte.execute(0, null, incomingParameters);
assertEquals(0, returnMap.size());
jte.cleanUp();
} catch (Exception jteException) {
AxEvent axEvent1 = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event1 = new EnEvent(axEvent1);
try {
- jtse.execute(-1, event1);
+ jtse.execute(-1, null, event1);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(
}
try {
- jtse.execute(-1, null);
+ jtse.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(java.lang.NullPointerException.class, jtseException.getClass());
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
try {
- jtse.execute(-1, event);
+ jtse.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(
+ "var returnValue = new returnValueType(false); ");
try {
jtse.prepare();
- jtse.execute(-1, event);
+ jtse.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"",
+ "var returnValue = new returnValueType(true); ");
try {
jtse.prepare();
- AxArtifactKey taskKey = jtse.execute(0, event);
+ AxArtifactKey taskKey = jtse.execute(0, null, event);
assertEquals("NULL:0.0.0", taskKey.getId());
jtse.cleanUp();
} catch (Exception jtseException) {
package org.onap.policy.apex.plugins.executor.jruby;
import java.util.Map;
+import java.util.Properties;
import org.jruby.embed.EmbedEvalUnit;
import org.jruby.embed.LocalContextScope;
* Executes the executor for the state finalizer logic in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingFields the incoming fields for finalisation
* @return The state output for the state
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public String execute(final long executionId, final Map<String, Object> incomingFields)
- throws StateMachineException, ContextException {
+ public String execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingFields);
+ executePre(executionId, executionProperties, incomingFields);
// Check and execute the JRuby logic
container.put("executor", getExecutionContext());
package org.onap.policy.apex.plugins.executor.jruby;
import java.util.Map;
+import java.util.Properties;
import org.jruby.embed.EmbedEvalUnit;
import org.jruby.embed.LocalContextScope;
* Executes the executor for the task in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingFields the incoming fields
* @return The outgoing fields
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public Map<String, Object> execute(final long executionId, final Map<String, Object> incomingFields)
- throws StateMachineException, ContextException {
+ public Map<String, Object> execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingFields);
+ executePre(executionId, executionProperties, incomingFields);
// Check and execute the JRuby logic
container.put("executor", getExecutionContext());
package org.onap.policy.apex.plugins.executor.jruby;
+import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
* Executes the executor for the task in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingEvent the incoming event
* @return The outgoing event
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public AxArtifactKey execute(final long executionId, final EnEvent incomingEvent)
- throws StateMachineException, ContextException {
+ public AxArtifactKey execute(final long executionId, final Properties executionProperties,
+ final EnEvent incomingEvent) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingEvent);
+ executePre(executionId, executionProperties, incomingEvent);
// Check and execute the JRuby logic
container.put("executor", getExecutionContext());
}\r
\r
try {\r
- jsfe.execute(-1, null);\r
+ jsfe.execute(-1, null, null);\r
fail("test should throw an exception here");\r
} catch (Exception jtseException) {\r
assertEquals("execute-post: state finalizer logic execution failure on state \"NULL:0.0.0:NULL:NULL\" on "\r
state.getStateOutputs().put("SelectedOutputIsMe", null);\r
try {\r
jsfe.prepare();\r
- String stateOutput = jsfe.execute(0, event);\r
+ String stateOutput = jsfe.execute(0, null, event);\r
assertEquals("SelectedOutputIsMe", stateOutput);\r
jsfe.cleanUp();\r
} catch (Exception jtseException) {\r
\r
Map<String, Object> incomingParameters = new HashMap<>();\r
try {\r
- jte.execute(-1, incomingParameters);\r
+ jte.execute(-1, null, incomingParameters);\r
fail("test should throw an exception here");\r
} catch (Exception jteException) {\r
assertEquals("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0",\r
\r
try {\r
jte.prepare();\r
- Map<String, Object> returnMap = jte.execute(0, incomingParameters);\r
+ Map<String, Object> returnMap = jte.execute(0, null, incomingParameters);\r
assertEquals(0, returnMap.size());\r
jte.cleanUp();\r
} catch (Exception jteException) {\r
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));\r
EnEvent event = new EnEvent(axEvent);\r
try {\r
- jtse.execute(-1, event);\r
+ jtse.execute(-1, null, event);\r
fail("test should throw an exception here");\r
} catch (Exception jtseException) {\r
assertEquals("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"",\r
\r
try {\r
jtse.prepare();\r
- AxArtifactKey taskKey = jtse.execute(0, event);\r
+ AxArtifactKey taskKey = jtse.execute(0, null, event);\r
assertEquals("NULL:0.0.0", taskKey.getId());\r
jtse.cleanUp();\r
} catch (Exception jtseException) {\r
package org.onap.policy.apex.plugins.executor.jython;
import java.util.Map;
+import java.util.Properties;
+
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.executor.StateFinalizerExecutor;
import org.onap.policy.apex.core.engine.executor.exception.StateMachineException;
*
* @param executionId the execution ID for the current APEX policy execution
* @param incomingFields the incoming fields for finalisation
+ * @param executionProperties properties for the current APEX policy execution
* @return The state output for the state
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public String execute(final long executionId, final Map<String, Object> incomingFields)
- throws StateMachineException, ContextException {
+ public String execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
boolean returnValue = false;
// Do execution pre work
- executePre(executionId, incomingFields);
+ executePre(executionId, executionProperties, incomingFields);
try {
package org.onap.policy.apex.plugins.executor.jython;
import java.util.Map;
+import java.util.Properties;
+
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.executor.TaskExecutor;
import org.onap.policy.apex.core.engine.executor.exception.StateMachineException;
import org.slf4j.ext.XLoggerFactory;
/**
- * The Class JythonTaskExecutor is the task executor for task logic written in Jython It is unlikely
- * that this is thread safe.
+ * The Class JythonTaskExecutor is the task executor for task logic written in Jython It is unlikely that this is thread
+ * safe.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
* Executes the executor for the task in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingFields the incoming fields
* @return The outgoing fields
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public Map<String, Object> execute(final long executionId, final Map<String, Object> incomingFields)
- throws StateMachineException, ContextException {
+ public Map<String, Object> execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
boolean returnValue = false;
// Do execution pre work
- executePre(executionId, incomingFields);
+ executePre(executionId, executionProperties, incomingFields);
try {
package org.onap.policy.apex.plugins.executor.jython;
+import java.util.Properties;
+
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.event.EnEvent;
import org.onap.policy.apex.core.engine.executor.TaskSelectExecutor;
import org.slf4j.ext.XLoggerFactory;
/**
- * The Class JythonTaskSelectExecutor is the task selection executor for task selection logic
- * written in Jython It is unlikely that this is thread safe.
+ * The Class JythonTaskSelectExecutor is the task selection executor for task selection logic written in Jython It is
+ * unlikely that this is thread safe.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
* Executes the executor for the task in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingEvent the incoming event
* @return The outgoing event
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public AxArtifactKey execute(final long executionId, final EnEvent incomingEvent)
- throws StateMachineException, ContextException {
+ public AxArtifactKey execute(final long executionId, final Properties executionProperties,
+ final EnEvent incomingEvent) throws StateMachineException, ContextException {
boolean returnValue = false;
// Do execution pre work
- executePre(executionId, incomingEvent);
+ executePre(executionId, executionProperties, incomingEvent);
try {
// Check and execute the Jython logic
stateFinalizerLogic.setLogic(scriptSource);
try {
jsfe.prepare();
- jsfe.execute(-1, null);
+ jsfe.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
try {
- jsfe.execute(0, event);
+ jsfe.execute(0, null, event);
} catch (Exception jtseException) {
jtseException.printStackTrace();
fail("test should not throw an exception here");
try {
jsfe.prepare();
- String stateOutput = jsfe.execute(0, event);
+ String stateOutput = jsfe.execute(0, null, event);
assertEquals("SelectedOutputIsMe", stateOutput);
jsfe.cleanUp();
} catch (Exception jtseException) {
}
try {
- jte.execute(-1, null);
+ jte.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals(java.lang.NullPointerException.class, jteException.getClass());
Map<String, Object> incomingParameters = new HashMap<>();
try {
- jte.execute(-1, incomingParameters);
+ jte.execute(-1, null, incomingParameters);
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("failed to execute Jython code for task NULL:0.0.0", jteException.getMessage());
try {
jte.prepare();
- Map<String, Object> returnMap = jte.execute(-1, incomingParameters);
+ Map<String, Object> returnMap = jte.execute(-1, null, incomingParameters);
assertEquals(0, returnMap.size());
jte.cleanUp();
fail("test should throw an exception here");
task.getTaskLogic().setLogic(scriptSource);
try {
jte.prepare();
- Map<String, Object> returnMap = jte.execute(0, incomingParameters);
+ Map<String, Object> returnMap = jte.execute(0, null, incomingParameters);
assertEquals(0, returnMap.size());
jte.cleanUp();
} catch (Exception jteException) {
state.getTaskSelectionLogic().setLogic(scriptSource);
try {
jtse.prepare();
- jtse.execute(-1, null);
+ jtse.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals(java.lang.NullPointerException.class, jtseException.getClass());
EnEvent event = new EnEvent(axEvent);
try {
jtse.prepare();
- jtse.execute(-1, event);
+ jtse.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("failed to execute Jython code for task selection logic in NULL:0.0.0:NULL:NULL",
state.getTaskSelectionLogic().setLogic(scriptSource);
try {
jtse.prepare();
- jtse.execute(-1, event);
+ jtse.execute(-1, null, event);
jtse.cleanUp();
} catch (Exception jtseException) {
fail("test should not throw an exception here");
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import org.mvel2.MVEL;
import org.onap.policy.apex.context.ContextException;
* Executes the executor for the state finalizer logic in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingFields the incoming fields for finalisation
* @return The state output for the state
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public String execute(final long executionId, final Map<String, Object> incomingFields)
- throws StateMachineException, ContextException {
+ public String execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingFields);
+ executePre(executionId, executionProperties, incomingFields);
// Check and execute the MVEL logic
argumentNotNull(compiled, "MVEL state finalizer logic not compiled.");
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import org.mvel2.MVEL;
import org.onap.policy.apex.context.ContextException;
* Executes the executor for the task in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingFields the incoming fields
* @return The outgoing fields
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public Map<String, Object> execute(final long executionId, final Map<String, Object> incomingFields)
- throws StateMachineException, ContextException {
+ public Map<String, Object> execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingFields);
+ executePre(executionId, executionProperties, incomingFields);
// Check and execute the MVEL logic
argumentNotNull(compiled, "MVEL task not compiled.");
import java.io.Serializable;
import java.util.HashMap;
+import java.util.Properties;
import org.mvel2.MVEL;
import org.onap.policy.apex.context.ContextException;
* Executes the executor for the task in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingEvent the incoming event
* @return The outgoing event
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public AxArtifactKey execute(final long executionId, final EnEvent incomingEvent)
- throws StateMachineException, ContextException {
+ public AxArtifactKey execute(final long executionId, final Properties executionProperties,
+ final EnEvent incomingEvent) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingEvent);
+ executePre(executionId, executionProperties, incomingEvent);
// Check and execute the MVEL logic
argumentNotNull(compiled, "MVEL task not compiled.");
}
try {
- msfe.execute(-1, null);
+ msfe.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception msfeException) {
assertEquals("failed to execute MVEL code for state NULL:0.0.0:NULL:NULL",
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
try {
- msfe.execute(-1, event);
+ msfe.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception msfeException) {
assertEquals("failed to execute MVEL code for state NULL:0.0.0:NULL:NULL",
stateFinalizerLogic.setLogic("executionId !=-1");
try {
msfe.prepare();
- msfe.execute(-1, event);
+ msfe.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception msfeException) {
assertEquals(
state.getStateOutputs().put("SelectedOutputIsMe", null);
try {
msfe.prepare();
- String stateOutput = msfe.execute(0, event);
+ String stateOutput = msfe.execute(0, null, event);
assertEquals("SelectedOutputIsMe", stateOutput);
} catch (Exception msfeException) {
LOGGER.warn("Unexpected exception happened here.", msfeException);
}
try {
- mte.execute(-1, null);
+ mte.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception mteException) {
assertEquals(java.lang.NullPointerException.class, mteException.getClass());
Map<String, Object> incomingParameters = new HashMap<>();
try {
- mte.execute(-1, incomingParameters);
+ mte.execute(-1, null, incomingParameters);
fail("test should throw an exception here");
} catch (Exception mteException) {
assertEquals("failed to execute MVEL code for task NULL:0.0.0", mteException.getMessage());
task.getTaskLogic().setLogic("executionId != -1");
try {
mte.prepare();
- mte.execute(-1, incomingParameters);
+ mte.execute(-1, null, incomingParameters);
fail("test should throw an exception here");
} catch (Exception mteException) {
assertEquals("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0",
try {
mte.prepare();
- Map<String, Object> returnMap = mte.execute(0, incomingParameters);
+ Map<String, Object> returnMap = mte.execute(0, null, incomingParameters);
assertEquals(0, returnMap.size());
mte.cleanUp();
} catch (Exception mteException) {
}
try {
- mtse.execute(-1, null);
+ mtse.execute(-1, null, null);
fail("test should throw an exception here");
} catch (Exception mtseException) {
assertEquals(java.lang.NullPointerException.class, mtseException.getClass());
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
EnEvent event = new EnEvent(axEvent);
try {
- mtse.execute(-1, event);
+ mtse.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception mtseException) {
assertEquals("failed to execute MVEL code for state NULL:0.0.0:NULL:NULL",
state.getTaskSelectionLogic().setLogic("executionId != -1");
try {
mtse.prepare();
- mtse.execute(-1, event);
+ mtse.execute(-1, null, event);
fail("test should throw an exception here");
} catch (Exception mtseException) {
assertEquals("execute-post: task selection logic failed on state \"NULL:0.0.0:NULL:NULL\"",
try {
mtse.prepare();
- AxArtifactKey taskKey = mtse.execute(0, event);
+ AxArtifactKey taskKey = mtse.execute(0, null, event);
assertEquals("NULL:0.0.0", taskKey.getId());
mtse.cleanUp();
} catch (Exception mtseException) {
* 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=========================================================
*/
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import java.util.concurrent.atomic.AtomicLong;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
+@Getter
+@ToString
+@EqualsAndHashCode(callSuper = false)
public class ApexEvent extends HashMap<String, Object> implements Serializable {
private static final long serialVersionUID = -4451918242101961685L;
/** The target of an Apex event must match this regular expression. */
public static final String TARGET_REGEXP = SOURCE_REGEXP;
- // The fields of the event
- // @formatter:off
+ // The standard fields of the event
private final String name;
private final String version;
private final String nameSpace;
private final String source;
private final String target;
- // @formatter:on
// An identifier for the current event execution. The default value here will always be unique
// in a single JVM
private long executionId = ApexEvent.getNextExecutionId();
+ // Event related properties used during processing of this event
+ private Properties executionProperties;
+
// A string holding a message that indicates why processing of this event threw an exception
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() {
}
/**
- * Gets the name.
+ * Sets the pass-thru executionID for this event.
*
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Gets the version.
- *
- * @return the version
- */
- public String getVersion() {
- return version;
- }
-
- /**
- * Gets the name space.
- *
- * @return the name space
- */
- public String getNameSpace() {
- return nameSpace;
- }
-
- /**
- * Gets the source.
- *
- * @return the source
- */
- public String getSource() {
- return source;
- }
-
- /**
- * Gets the target.
- *
- * @return the target
- */
- public String getTarget() {
- return target;
- }
-
- /**
- * Gets the pass-thru executionID for this event.
- *
- * @return the executionID
- */
- public long getExecutionId() {
- return executionId;
- }
-
- /**
- * Sets the pass-thru executionID for this event. The default value for executionID will be be
- * unique in the current JVM. For some applications/deployments this executionID may need to
- * globally unique
+ * <p>The default value for executionID is unique in the current JVM. For some applications/deployments this
+ * executionID may need to be globally unique
*
* @param executionId the executionID
*/
}
/**
- * Gets the exception message explaining why processing of this event to fail.
+ * Set the execution properties for this event.
*
- * @return the exception message
+ * @param executionProperties the execution properties to set
*/
- public String getExceptionMessage() {
- return exceptionMessage;
+ public void setExecutionProperties(Properties executionProperties) {
+ this.executionProperties = executionProperties;
}
/**
// Go ahead and put everything
super.putAll(incomingMap);
}
-
- /*
- * Object overrides from here
- */
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("name=");
- builder.append(name);
- builder.append(",version=");
- builder.append(version);
- builder.append(",nameSpace=");
- builder.append(nameSpace);
- builder.append(",source=");
- builder.append(source);
- builder.append(",target=");
- builder.append(target);
- builder.append(",executionID=");
- builder.append(executionId);
- builder.append(",exceptionMessage=");
- builder.append(exceptionMessage);
- builder.append(",");
- builder.append("[");
-
- boolean firstData = true;
- for (final Map.Entry<String, Object> dataEntry : this.entrySet()) {
- if (firstData) {
- firstData = false;
- } else {
- builder.append(',');
- }
-
- builder.append(dataEntry.getKey());
- builder.append('=');
- builder.append(dataEntry.getValue());
- }
-
- builder.append("]");
- return builder.toString();
- }
}
* 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=========================================================
*/
* 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.service.engine.event;
+import java.util.Properties;
+
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
/**
* Get the peered reference object for this producer.
- *
+ *
* @param peeredMode the peered mode for which to return the reference
* @return the peered reference object for this producer
*/
/**
* Set the peered reference object for this producer.
- *
+ *
* @param peeredMode the peered mode for which to return the reference
* @param peeredReference the peered reference object for this producer
*/
* Send an event to the producer.
*
* @param executionId the unique ID that produced this event
+ * @param executionProperties properties used during processing of this event
* @param eventName The name of the event
* @param event The converted event as an object
*/
- void sendEvent(long executionId, String eventName, Object event);
+ void sendEvent(long executionId, Properties executionProperties, String eventName, Object event);
/**
* Get the name of this event producer.
- *
+ *
* @return the event producer name
*/
String getName();
* 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.service.engine.event;
+import java.util.Properties;
+
/**
* This interface is used by an Apex event consumer {@link ApexEventConsumer} consumer to pass a
* received event to Apex.
* Receive an event from a consumer for processing.
*
* @param executionId the unique ID for execution of this event
+ * @param executionProperties properties used during processing of this event
* @param event the event to receive
* @throws ApexEventException on exceptions receiving an event into Apex
*/
- void receiveEvent(long executionId, Object event) throws ApexEventException;
+ void receiveEvent(long executionId, Properties executionProperties, Object event) throws ApexEventException;
/**
* Receive an event from a consumer for processing.
*
+ * @param executionProperties properties used during processing of this event
* @param event the event to receive
* @throws ApexEventException on exceptions receiving an event into Apex
*/
- void receiveEvent(Object event) throws ApexEventException;
+ void receiveEvent(Properties executionProperties, Object event) throws ApexEventException;
}
* 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=========================================================
*/
/**
* Receive an incoming event send request from the peered event Requestor producer and queue it.
- *
+ *
* @param eventObject the incoming event to process
* @throws ApexEventRuntimeException on queueing errors
*/
/*
* (non-Javadoc)
- *
+ *
* @see org.onap.policy.apex.service.engine.event.ApexEventConsumer#start()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.onap.policy.apex.service.engine.event.ApexEventConsumer#getName()
*/
@Override
/**
* Get the number of events received to date.
- *
+ *
* @return the number of events received
*/
public int getEventsReceived() {
/*
* (non-Javadoc)
- *
+ *
* @see org.onap.policy.apex.service.engine.event.ApexEventConsumer#getPeeredReference(org.onap.
* policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode)
*/
/*
* (non-Javadoc)
- *
+ *
* @see org.onap.policy.apex.service.engine.event.ApexEventConsumer#setPeeredReference(org.onap.
* policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode,
* org.onap.policy.apex.service.engine.event.PeeredReference)
}
// Send the event into Apex
- eventReceiver.receiveEvent(eventObject);
+ eventReceiver.receiveEvent(null, eventObject);
eventsReceived++;
} catch (final InterruptedException e) {
* 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=========================================================
*/
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import org.onap.policy.apex.service.engine.event.ApexEventConsumer;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.slf4j.LoggerFactory;
/**
- * Concrete implementation of an Apex event producer that sends one or more events to its peered
- * event requestor consumer.
- *
+ * Concrete implementation of an Apex event producer that sends one or more events to its peered event requestor
+ * consumer.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
- *
+ *
*/
public class EventRequestorProducer implements ApexEventProducer {
private static final Logger LOGGER = LoggerFactory.getLogger(EventRequestorProducer.class);
/*
* (non-Javadoc)
- *
+ *
* @see org.onap.policy.apex.service.engine.event.ApexEventProducer#init(java.lang.String,
* org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters)
*/
/*
* (non-Javadoc)
- *
+ *
* @see org.onap.policy.apex.service.engine.event.ApexEventProducer#getName()
*/
@Override
/**
* Get the number of events sent to date.
- *
+ *
* @return the number of events received
*/
public int getEventsSent() {
return eventsSent;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventProducer#getPeeredReference(org.onap.
- * policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode)
+ /**
+ * {@inheritDoc}
*/
@Override
public PeeredReference getPeeredReference(final EventHandlerPeeredMode peeredMode) {
return peerReferenceMap.get(peeredMode);
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventProducer#setPeeredReference(org.onap.
- * policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode,
- * org.onap.policy.apex.service.engine.event.PeeredReference)
+ /**
+ * {@inheritDoc}
*/
@Override
public void setPeeredReference(final EventHandlerPeeredMode peeredMode, final PeeredReference peeredReference) {
peerReferenceMap.put(peeredMode, peeredReference);
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventProducer#sendEvent(long, java.lang.
- * String, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public void sendEvent(final long executionId, final String eventName, final Object eventObject) {
+ public void sendEvent(final long executionId, final Properties executorProperties, final String eventName,
+ final Object eventObject) {
// Check if this is a synchronized event, if so we have received a reply
final SynchronousEventCache synchronousEventCache =
(SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventProducer#stop()
+ /**
+ * {@inheritDoc}
*/
@Override
public void stop() {
* 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=========================================================
*/
/**
* 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() {
/*
* (non-Javadoc)
- *
+ *
* @see org.onap.policy.apex.service.engine.event.ApexEventConsumer#getName()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.onap.policy.apex.service.engine.event.ApexEventConsumer#getPeeredReference(org.onap.
* policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode)
*/
/*
* (non-Javadoc)
- *
+ *
* @see org.onap.policy.apex.service.engine.event.ApexEventConsumer#setPeeredReference(org.onap.
* policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode,
* org.onap.policy.apex.service.engine.event.PeeredReference)
/*
* (non-Javadoc)
- *
+ *
* @see org.onap.policy.apex.service.engine.event.ApexEventConsumer#start()
*/
@Override
// Process the event from the text block if there is one there
if (textBlock.getText() != null) {
- eventReceiver.receiveEvent(getNextExecutionId(), textBlock.getText());
+ eventReceiver.receiveEvent(getNextExecutionId(), null, textBlock.getText());
}
}
while (!textBlock.isEndOfText());
* 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=========================================================
*/
import java.io.PrintStream;
import java.util.EnumMap;
import java.util.Map;
+import java.util.Properties;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.service.engine.event.ApexEventException;
private final Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap =
new EnumMap<>(EventHandlerPeeredMode.class);
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.apps.uservice.producer.ApexEventProducer#init()
+ /**
+ * {@inheritDoc}
*/
@Override
public void init(final String name, final EventHandlerParameters producerParameters) throws ApexEventException {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventProducer#getName()
+ /**
+ * {@inheritDoc}
*/
@Override
public String getName() {
return producerName;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventProducer#getPeeredReference(org.onap.
- * policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode)
+ /**
+ * {@inheritDoc}
*/
@Override
public PeeredReference getPeeredReference(final EventHandlerPeeredMode peeredMode) {
return peerReferenceMap.get(peeredMode);
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventProducer#setPeeredReference(org.onap.
- * policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode,
- * org.onap.policy.apex.service.engine.event.PeeredReference)
+ /**
+ * {@inheritDoc}
*/
@Override
public void setPeeredReference(final EventHandlerPeeredMode peeredMode, final PeeredReference peeredReference) {
peerReferenceMap.put(peeredMode, peeredReference);
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventProducer#sendEvent(long,
- * java.lang.String, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public void sendEvent(final long executionId, final String eventName, final Object event) {
+ public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
+ final Object event) {
// Check if this is a synchronized event, if so we have received a reply
final SynchronousEventCache synchronousEventCache =
(SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
eventOutputStream.flush();
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.apps.uservice.producer.ApexEventProducer#stop()
+ /**
+ * {@inheritDoc}
*/
@Override
public void stop() {
// Process the next Apex event from the queue
final Object event = converter.fromApexEvent(apexEvent);
- producer.sendEvent(apexEvent.getExecutionId(), apexEvent.getName(), event);
+ producer.sendEvent(apexEvent.getExecutionId(), apexEvent.getExecutionProperties(), apexEvent.getName(),
+ event);
if (LOGGER.isTraceEnabled()) {
final String message = "event sent : " + apexEvent.toString();
* 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.service.engine.main;
import java.util.List;
+import java.util.Properties;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
* @param consumerParameters the consumer parameters for this specific unmarshaler
*/
public ApexEventUnmarshaller(final String name, final EngineServiceParameters engineServiceParameters,
- final EventHandlerParameters consumerParameters) {
+ final EventHandlerParameters consumerParameters) {
this.name = name;
this.engineServiceParameters = engineServiceParameters;
this.consumerParameters = consumerParameters;
consumer.start();
// Configure and start the event reception thread
- final String threadName = engineServiceParameters.getEngineKey().getName() + ":" + this.getClass().getName()
- + ":" + name;
+ final String threadName =
+ engineServiceParameters.getEngineKey().getName() + ":" + this.getClass().getName() + ":" + name;
unmarshallerThread = new ApplicationThreadFactory(threadName).newThread(this);
unmarshallerThread.setDaemon(true);
unmarshallerThread.start();
/**
* Connect a synchronous unmarshaler with a synchronous marshaler.
- *
+ *
* @param peeredMode the peered mode under which the unmarshaler and marshaler are connected
* @param peeredMarshaller the synchronous marshaler to connect with
*/
// To connect a synchronous unmarshaler and marshaler, we create a synchronous event
// cache on the consumer/producer pair
new SynchronousEventCache(peeredMode, consumer, peeredMarshaller.getProducer(),
- consumerParameters.getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
+ consumerParameters.getPeerTimeout(EventHandlerPeeredMode.SYNCHRONOUS));
return;
case REQUESTOR:
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventReceiver#receiveEvent(java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public void receiveEvent(final Object event) throws ApexEventException {
- receiveEvent(0, event, true);
+ public void receiveEvent(final Properties executionProperties, final Object event) throws ApexEventException {
+ receiveEvent(0, executionProperties, event, true);
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventReceiver#receiveEvent(long, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public void receiveEvent(final long executionId, final Object event) throws ApexEventException {
- receiveEvent(executionId, event, false);
+ public void receiveEvent(final long executionId, final Properties executionProperties, final Object event)
+ throws ApexEventException {
+ receiveEvent(executionId, executionProperties, event, false);
}
/**
* Receive an event from a consumer, convert its protocol and forward it to Apex.
*
* @param executionId the execution id the incoming execution ID
+ * @param executionProperties properties used during processing of this event
* @param event the event in its native format
* @param generateExecutionId if true, let Apex generate the execution ID, if false, use the incoming execution ID
* @throws ApexEventException on unmarshaling errors on events
*/
- private void receiveEvent(final long executionId, final Object event, final boolean generateExecutionId)
- throws ApexEventException {
+ private void receiveEvent(final long executionId, final Properties executionProperties, final Object event,
+ final boolean generateExecutionId) throws ApexEventException {
// Push the event onto the queue
if (LOGGER.isTraceEnabled()) {
String eventString = "onMessage(): event received: " + event.toString();
// Convert the incoming events to Apex events
try {
final List<ApexEvent> apexEventList = converter.toApexEvent(consumerParameters.getEventName(), event);
+
for (final ApexEvent apexEvent : apexEventList) {
isEventFilteredOut(apexEvent);
apexEvent.setExecutionId(executionId);
}
+ apexEvent.setExecutionProperties(executionProperties);
+
// Enqueue the event
queue.add(apexEvent);
// Cache synchronized events that are sent
if (consumerParameters.isPeeredMode(EventHandlerPeeredMode.SYNCHRONOUS)) {
- final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) consumer
- .getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS);
+ final SynchronousEventCache synchronousEventCache =
+ (SynchronousEventCache) consumer.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS);
synchronousEventCache.cacheSynchronizedEventToApex(apexEvent.getExecutionId(), apexEvent);
}
}
} catch (final ApexException e) {
final String errorMessage = "Error while converting event into an ApexEvent for " + name + ": "
- + e.getMessage() + ", Event=" + event;
+ + e.getMessage() + ", Event=" + event;
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
/**
* 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())) {
-
+ && !apexEvent.getName().matches(consumerParameters.getEventNameFilter())) {
+
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("onMessage(): event {} not processed, filtered out by filter", apexEvent,
- consumerParameters.getEventNameFilter());
+ consumerParameters.getEventNameFilter());
}
-
+
return true;
- }
- else {
+ } else {
return false;
}
}
// Order a stop on the synchronous cache if one exists
if (consumerParameters != null && consumerParameters.isPeeredMode(EventHandlerPeeredMode.SYNCHRONOUS)
- && consumer.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS) != null) {
+ && consumer.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS) != null) {
((SynchronousEventCache) consumer.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)).stop();
}
* 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.service.engine.parameters.dummyclasses;
import java.util.Map;
+import java.util.Properties;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.executor.StateFinalizerExecutor;
* Dummy state finalizer executor for testing.
*/
public class DummyStateFinalizerExecutor extends StateFinalizerExecutor {
- public DummyStateFinalizerExecutor() {
- }
-
+ public DummyStateFinalizerExecutor() {}
+
@Override
- public String execute(final long executionId, final Map<String, Object> newIncomingFields)
- throws StateMachineException, ContextException {
-
+ public String execute(final long executionId, final Properties executorProperties,
+ final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException {
+
return "stateOutput0";
}
}
* 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.service.engine.parameters.dummyclasses;
import java.util.Map;
+import java.util.Properties;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.event.EnEvent;
* Dummy task executor for testing.
*/
public class DummyTaskExecutor extends TaskExecutor {
- public DummyTaskExecutor() {
- }
+ public DummyTaskExecutor() {}
@Override
- public void prepare() throws StateMachineException {
- }
-
+ public void prepare() throws StateMachineException {}
+
@Override
- public Map<String, Object> execute(final long executionId, final Map<String, Object> newIncomingFields)
- throws StateMachineException, ContextException {
+ public Map<String, Object> execute(final long executionId, final Properties executorProperties,
+ final Map<String, Object> newIncomingFields) throws StateMachineException, ContextException {
AxArtifactKey event0Key = new AxArtifactKey("Event0:0.0.1");
return new EnEvent(event0Key);
}
-
+
@Override
public AxTask getSubject() {
AxArtifactKey taskKey = new AxArtifactKey("FirstTask:0.0.1");
}
@Override
- public void cleanUp() throws StateMachineException {
- }
+ public void cleanUp() throws StateMachineException {}
}
* 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.service.engine.parameters.dummyclasses;
+import java.util.Properties;
+
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.event.EnEvent;
import org.onap.policy.apex.core.engine.executor.TaskSelectExecutor;
* Dummy task selection executor for testing.
*/
public class DummyTaskSelectExecutor extends TaskSelectExecutor {
- public DummyTaskSelectExecutor() {
- }
+ public DummyTaskSelectExecutor() {}
@Override
- public void prepare() throws StateMachineException {
- }
+ public void prepare() throws StateMachineException {}
@Override
- public AxArtifactKey execute(final long executionId, final EnEvent newIncomingEvent)
- throws StateMachineException, ContextException {
-
+ public AxArtifactKey execute(final long executionId, final Properties executorProperties,
+ final EnEvent newIncomingEvent) throws StateMachineException, ContextException {
+
return new AxArtifactKey("task:0.0.1");
}
@Override
- public void cleanUp() throws StateMachineException {
- }
+ public void cleanUp() throws StateMachineException {}
}
* 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.service.engine.parameters.dummyclasses;
+import java.util.Properties;
+
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventProducer;
import org.onap.policy.apex.service.engine.event.PeeredReference;
/**
* Dummy event producer parameters.
+ *
* @author John Keeney (john.keeney@ericsson.com)
*/
public class SuperDooperEventProducer implements ApexEventProducer {
public SuperDooperEventProducer() {}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventProducer#init(java.lang.String,
- * org.onap.policy.apex.service.parameters.producer.ProducerParameters)
+ /**
+ * {@inheritDoc}
*/
@Override
public void init(final String name, final EventHandlerParameters producerParameters) throws ApexEventException {
this.name = name;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventProducer#getName()
+ /**
+ * {@inheritDoc}
*/
@Override
public String getName() {
return name;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.onap.policy.apex.service.engine.event.ApexEventProducer#getPeeredReference(org.onap.policy.apex
- * .service.parameters.eventhandler.EventHandlerPeeredMode)
+ /**
+ * {@inheritDoc}
*/
@Override
public PeeredReference getPeeredReference(final EventHandlerPeeredMode peeredMode) {
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.onap.policy.apex.service.engine.event.ApexEventProducer#setPeeredReference(org.onap.policy.apex
- * .service.parameters.eventhandler.EventHandlerPeeredMode,
- * org.onap.policy.apex.service.engine.event.PeeredReference)
+ /**
+ * {@inheritDoc}
*/
@Override
public void setPeeredReference(final EventHandlerPeeredMode peeredMode, final PeeredReference peeredReference) {}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventProducer#sendEvent(long,
- * java.lang.String, java.lang.Object)
+ /**
+ * {@inheritDoc}
*/
@Override
- public void sendEvent(final long executionId, final String eventName, final Object event) {
+ public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
+ final Object event) {
LOGGER.info("Sending Event: " + this.getClass().getCanonicalName() + ":" + this.name + " ... event ("
+ eventName + ") : " + event);
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.service.engine.event.ApexEventProducer#stop()
+ /**
+ * {@inheritDoc}
*/
@Override
public void stop() {}