summaryrefslogtreecommitdiffstats
path: root/core/core-protocols/src
diff options
context:
space:
mode:
authorramverma <ram.krishna.verma@ericsson.com>2018-06-01 11:51:36 +0100
committerramverma <ram.krishna.verma@ericsson.com>2018-06-04 10:50:44 +0100
commit37d6fd9069eb30d88c4ad80b5f35099ed173cc13 (patch)
tree0f30a71577644047feee43bd8857dc5a82a51c87 /core/core-protocols/src
parent5722440b2eb8ff1923dda9d4d856f0adc1ac8e6f (diff)
Adding apex core module to apex-pdp
Change-Id: I4bfe1df3e44fe62ff6789e813e59836e267ab3b2 Issue-ID: POLICY-858 Signed-off-by: ramverma <ram.krishna.verma@ericsson.com>
Diffstat (limited to 'core/core-protocols/src')
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Action.java37
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Message.java200
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/EngDepAction.java94
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponse.java124
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/GetEngineInfo.java63
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/GetEngineServiceInfo.java63
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/GetEngineStatus.java63
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/Response.java144
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StartEngine.java63
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StartPeriodicEvents.java63
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StopEngine.java63
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StopPeriodicEvents.java63
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/UpdateModel.java100
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/package-info.java27
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/package-info.java27
-rw-r--r--core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/package-info.java27
-rw-r--r--core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetExecutionStatusTest.java58
-rw-r--r--core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetPolicyStatusTest.java58
-rw-r--r--core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/ResponseTest.java65
-rw-r--r--core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/UpdateModelTest.java58
-rw-r--r--core/core-protocols/src/test/resources/logback-test.xml70
21 files changed, 1530 insertions, 0 deletions
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Action.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Action.java
new file mode 100644
index 000000000..62a2e0a75
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Action.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols;
+
+/**
+ * This interface is used to enforce a common type on actions in the Apex messasging protocol. Action types the Apex
+ * messaging protocol supports implement this interface.
+ *
+ * @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com)
+ */
+public interface Action {
+
+ /**
+ * This method returns a string representation of each action.
+ *
+ * @return the action string
+ */
+ String getActionString();
+}
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Message.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Message.java
new file mode 100644
index 000000000..73465cef6
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Message.java
@@ -0,0 +1,200 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols;
+
+import java.io.Serializable;
+
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+
+/**
+ * The Class Message is used to pass protocol messages between Apex components.
+ *
+ * @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com)
+ */
+public abstract class Message implements Serializable {
+ private static final int HASH_PRIME = 31;
+
+ // Serialization ID
+ private static final long serialVersionUID = 2271443377544488309L;
+
+ // Default timeout on server side should be used
+ private static final int DEFAULT_REPLY_TIMEOUT = -1;
+
+ // The Action or message type of the message
+ private Action action = null;
+
+ // The artifact key of the artifact to which this message is related
+ private AxArtifactKey targetKey = null;
+
+ // The data of the message
+ private String messageData = null;
+
+ // The timeout time for replies in milliseconds
+ private int replyTimeout = DEFAULT_REPLY_TIMEOUT;
+
+ /**
+ * Instantiates a new message.
+ *
+ * @param action the action or message type of the message
+ * @param targetKey the artifact key of the artifact to which this message relates
+ */
+ public Message(final Action action, final AxArtifactKey targetKey) {
+ this(action, targetKey, null);
+ }
+
+ /**
+ * Instantiates a new message.
+ *
+ * @param action the action or message type of the message
+ * @param targetKey the artifact key of the artifact to which this message relates
+ * @param messageData the message data to deliver
+ */
+ public Message(final Action action, final AxArtifactKey targetKey, final String messageData) {
+ this.action = action;
+ this.targetKey = targetKey;
+ this.messageData = messageData;
+ }
+
+ /**
+ * Set the message timeout.
+ *
+ * @param replyTimeout the timeout on reply messages in milliseconds
+ */
+ public void setReplyTimeout(final int replyTimeout) {
+ this.replyTimeout = replyTimeout;
+ }
+
+ /**
+ * Sets the message data.
+ *
+ * @param messageData the new message data
+ */
+ public void setMessageData(final String messageData) {
+ this.messageData = messageData;
+ }
+
+ /**
+ * Append to the message data.
+ *
+ * @param newMessageData the message data
+ */
+ public void appendMessageData(final String newMessageData) {
+ if (this.messageData == null) {
+ this.messageData = newMessageData;
+ } else {
+ this.messageData += newMessageData;
+ }
+ }
+
+ /**
+ * Gets the artifact key of the target of the message.
+ *
+ * @return the target
+ */
+ public final AxArtifactKey getTarget() {
+ return targetKey;
+ }
+
+ /**
+ * Gets the artifact key name of the target of the message.
+ *
+ * @return the target name
+ */
+ public final String getTargetName() {
+ return targetKey.getName();
+ }
+
+ /**
+ * Gets the action or message type of this message.
+ *
+ * @return the action
+ */
+ public final Action getAction() {
+ return action;
+ }
+
+ /**
+ * Gets the message data.
+ *
+ * @return the message data
+ */
+ public final String getMessageData() {
+ return messageData;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ final Message message = (Message) o;
+
+ if (action != null ? !action.equals(message.action) : message.action != null) {
+ return false;
+ }
+ if (targetKey != null ? !targetKey.equals(message.targetKey) : message.targetKey != null) {
+ return false;
+ }
+ return !(messageData != null ? !messageData.equals(message.messageData) : message.messageData != null);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ int result = action != null ? action.hashCode() : 0;
+ result = HASH_PRIME * result + (targetKey != null ? targetKey.hashCode() : 0);
+ result = HASH_PRIME * result + (messageData != null ? messageData.hashCode() : 0);
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "Message [action=" + action + ", targetKey=" + targetKey + ", data=" + messageData + "]";
+ }
+
+ /**
+ * Get the timeout to wait for a reply.
+ *
+ * @return the timeout in milliseconds
+ */
+ public int getReplyTimeout() {
+ return replyTimeout;
+ }
+}
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/EngDepAction.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/EngDepAction.java
new file mode 100644
index 000000000..b46fe59b9
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/EngDepAction.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols.engdep;
+
+import org.onap.policy.apex.core.protocols.Action;
+
+/**
+ * Action types the EngDep messaging protocol supports.
+ *
+ * @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com)
+ */
+public enum EngDepAction implements Action {
+ /** Action to get information on the running engine service. */
+ GET_ENGINE_SERVICE_INFO {
+ @Override
+ public String getActionString() {
+ return "Apex engine service information";
+ }
+ },
+ /** Action to update the policy model in an engine service. */
+ UPDATE_MODEL {
+ @Override
+ public String getActionString() {
+ return "update model on Apex engine service";
+ }
+ },
+ /** Action to start an engine service. */
+ START_ENGINE {
+ @Override
+ public String getActionString() {
+ return "starts an Apex engine";
+ }
+ },
+ /** Action to stop an engine service. */
+ STOP_ENGINE {
+ @Override
+ public String getActionString() {
+ return "stops an Apex engine service";
+ }
+ },
+ /** Action to start sending periodic events to an engine service. */
+ START_PERIODIC_EVENTS {
+ @Override
+ public String getActionString() {
+ return "starts periodic events on an Apex engine service";
+ }
+ },
+ /** Action to stop sending periodic events to an engine service. */
+ STOP_PERIODIC_EVENTS {
+ @Override
+ public String getActionString() {
+ return "stops periodic events on an Apex engine service";
+ }
+ },
+ /** Action to get the status of an engine in the engine service. */
+ GET_ENGINE_STATUS {
+ @Override
+ public String getActionString() {
+ return "gets the status of an Apex engine service";
+ }
+ },
+ /** Action to get information on an engine in the engine service. */
+ GET_ENGINE_INFO {
+ @Override
+ public String getActionString() {
+ return "gets runtime information an Apex engine service";
+ }
+ },
+ /** The response message to all actions. */
+ RESPONSE {
+ @Override
+ public String getActionString() {
+ return "response from Apex engine service";
+ }
+ };
+}
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponse.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponse.java
new file mode 100644
index 000000000..be0bfb2c5
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponse.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols.engdep.messages;
+
+import java.util.Collection;
+
+import org.onap.policy.apex.core.protocols.Message;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+
+/**
+ * The Class Response is a message that holds the response by an Apex engine to another Actino message sent to that
+ * engine.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class EngineServiceInfoResponse extends Response {
+ private static final long serialVersionUID = -7895025789667402067L;
+
+ // The engine service key
+ private AxArtifactKey engineServiceKey;
+
+ // The engines under the control of this engine service
+ private AxArtifactKey[] engineKeyArray;
+
+ // The engine service key
+ private AxArtifactKey apexModelKey;
+
+ /**
+ * Instantiates a new EngineServiceInfoResponse message.
+ *
+ * @param targetKey the target key of the entity that asked for the action that triggered this response message
+ * @param successful the successful if the action in the triggering message worked
+ * @param responseTo the message to which this message is a response
+ */
+ public EngineServiceInfoResponse(final AxArtifactKey targetKey, final boolean successful,
+ final Message responseTo) {
+ super(targetKey, successful, null, responseTo);
+ }
+
+ /**
+ * Instantiates a new EngineServiceInfoResponse message.
+ *
+ * @param targetKey the target key of the entity that asked for the action that triggered this response message
+ * @param successful the successful if the action in the triggering message worked
+ * @param messageData the message data which may indicate specific conditions for the response
+ * @param responseTo the message to which this message is a response
+ */
+ public EngineServiceInfoResponse(final AxArtifactKey targetKey, final boolean successful, final String messageData,
+ final Message responseTo) {
+ super(targetKey, successful, messageData, responseTo);
+ }
+
+ /**
+ * Gets the engine service key.
+ *
+ * @return the engine service key
+ */
+ public AxArtifactKey getEngineServiceKey() {
+ return engineServiceKey;
+ }
+
+ /**
+ * Sets the engine service key.
+ *
+ * @param engineServiceKey the engine service key
+ */
+ public void setEngineServiceKey(final AxArtifactKey engineServiceKey) {
+ this.engineServiceKey = engineServiceKey;
+ }
+
+ /**
+ * Gets the engine key array.
+ *
+ * @return the engine key array
+ */
+ public AxArtifactKey[] getEngineKeyArray() {
+ return engineKeyArray;
+ }
+
+ /**
+ * Sets the engine key array.
+ *
+ * @param engineKeyCollection the engine key array
+ */
+ public void setEngineKeyArray(final Collection<AxArtifactKey> engineKeyCollection) {
+ engineKeyArray = engineKeyCollection.toArray(new AxArtifactKey[engineKeyCollection.size()]);
+ }
+
+ /**
+ * Gets the apex model key.
+ *
+ * @return the apex model key
+ */
+ public AxArtifactKey getApexModelKey() {
+ return apexModelKey;
+ }
+
+ /**
+ * Sets the apex model key.
+ *
+ * @param apexModelKey the apex model key
+ */
+ public void setApexModelKey(final AxArtifactKey apexModelKey) {
+ this.apexModelKey = apexModelKey;
+ }
+}
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/GetEngineInfo.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/GetEngineInfo.java
new file mode 100644
index 000000000..5b53856d8
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/GetEngineInfo.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols.engdep.messages;
+
+import org.onap.policy.apex.core.protocols.Message;
+import org.onap.policy.apex.core.protocols.engdep.EngDepAction;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+
+/**
+ * The Class GetEngineInfo is a message that requests information on Apex engines and the policies they are running.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class GetEngineInfo extends Message {
+ private static final long serialVersionUID = 5885214410842753037L;
+
+ /**
+ * Instantiates a new GetEngineInfo message.
+ *
+ * @param engineKey the key the engine for which the runtime information is requested
+ */
+ public GetEngineInfo(final AxArtifactKey engineKey) {
+ this(engineKey, null);
+ }
+
+ /**
+ * Instantiates a new GetEngineInfo message.
+ *
+ * @param engineKey the key the engine for which the runtime information is requested
+ * @param messageData the message data that may give specifics on what information to return
+ */
+ public GetEngineInfo(final AxArtifactKey engineKey, final String messageData) {
+ super(EngDepAction.GET_ENGINE_INFO, engineKey, messageData);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.core.model.protocols.Message#toString()
+ */
+ @Override
+ public String toString() {
+ return "GetEngineInfo {" + super.toString() + "}[]";
+ }
+}
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/GetEngineServiceInfo.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/GetEngineServiceInfo.java
new file mode 100644
index 000000000..bdab1ce9f
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/GetEngineServiceInfo.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols.engdep.messages;
+
+import org.onap.policy.apex.core.protocols.Message;
+import org.onap.policy.apex.core.protocols.engdep.EngDepAction;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+
+/**
+ * The Class GetEngineServiceInfo is a message that requests information on what is in an Apex engine service.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class GetEngineServiceInfo extends Message {
+ private static final long serialVersionUID = 5885214410842753037L;
+
+ /**
+ * Instantiates a new GetEngineServiceInfo message.
+ *
+ * @param nullKey not used, set to null
+ */
+ public GetEngineServiceInfo(final AxArtifactKey nullKey) {
+ this(nullKey, null);
+ }
+
+ /**
+ * Instantiates a new GetEngineServiceInfo message.
+ *
+ * @param nullKey not used, set to null
+ * @param messageData the message data that may give specifics on what information to return
+ */
+ public GetEngineServiceInfo(final AxArtifactKey nullKey, final String messageData) {
+ super(EngDepAction.GET_ENGINE_SERVICE_INFO, nullKey, messageData);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.core.model.protocols.Message#toString()
+ */
+ @Override
+ public String toString() {
+ return "GetEngineServiceInfo {" + super.toString() + "}[]";
+ }
+}
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/GetEngineStatus.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/GetEngineStatus.java
new file mode 100644
index 000000000..59c345647
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/GetEngineStatus.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols.engdep.messages;
+
+import org.onap.policy.apex.core.protocols.Message;
+import org.onap.policy.apex.core.protocols.engdep.EngDepAction;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+
+/**
+ * The Class GetEngineInfo is a message that requests information on Apex engines and the policies they are running.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class GetEngineStatus extends Message {
+ private static final long serialVersionUID = 5885214410842753037L;
+
+ /**
+ * Instantiates a new GetEngineStatus message.
+ *
+ * @param engineKey the key of the engine for which the status information is requested
+ */
+ public GetEngineStatus(final AxArtifactKey engineKey) {
+ this(engineKey, null);
+ }
+
+ /**
+ * Instantiates a new GetEngineStatus message.
+ *
+ * @param engineKey the key of the engine for which the status information is requested
+ * @param messageData the message data that may give specifics on what information to return
+ */
+ public GetEngineStatus(final AxArtifactKey engineKey, final String messageData) {
+ super(EngDepAction.GET_ENGINE_STATUS, engineKey, messageData);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.core.model.protocols.Message#toString()
+ */
+ @Override
+ public String toString() {
+ return "GetEngineStatus {" + super.toString() + "}[]";
+ }
+}
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/Response.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/Response.java
new file mode 100644
index 000000000..69e36baed
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/Response.java
@@ -0,0 +1,144 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols.engdep.messages;
+
+import org.onap.policy.apex.core.protocols.Message;
+import org.onap.policy.apex.core.protocols.engdep.EngDepAction;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+
+/**
+ * The Class Response is a message that holds the response by an Apex engine to another Actino message sent to that
+ * engine.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class Response extends Message {
+ private static final int HASH_PRIME = 31;
+
+ private static final long serialVersionUID = -4162385039044294476L;
+
+ private boolean successful = false;
+ private Message responseTo = null;
+
+ /**
+ * Instantiates a new Response message.
+ *
+ * @param targetKey the target key of the entity that asked for the action that triggered this response message
+ * @param successful the successful if the action in the triggering message worked
+ * @param responseTo the message to which this message is a response
+ */
+ public Response(final AxArtifactKey targetKey, final boolean successful, final Message responseTo) {
+ this(targetKey, successful, null, responseTo);
+ }
+
+ /**
+ * Instantiates a new Response message.
+ *
+ * @param targetKey the target key of the entity that asked for the action that triggered this response message
+ * @param successful the successful if the action in the triggering message worked
+ * @param messageData the message data which may indicate specific conditions for the response
+ * @param responseTo the message to which this message is a response
+ */
+ public Response(final AxArtifactKey targetKey, final boolean successful, final String messageData,
+ final Message responseTo) {
+ super(EngDepAction.RESPONSE, targetKey, messageData);
+ this.successful = successful;
+ this.responseTo = responseTo;
+ }
+
+ /**
+ * Checks if the action to which this is a response was successful.
+ *
+ * @return true, if is successful
+ */
+ public boolean isSuccessful() {
+ return successful;
+ }
+
+ /**
+ * Gets the message to which this message is a response to.
+ *
+ * @return the the message to which this message is a response to
+ */
+ public Message getResponseTo() {
+ return responseTo;
+ }
+
+ /**
+ * Compare this message to another Response message.
+ *
+ * @param otherMessage the other message
+ * @return true, if successful
+ */
+ public boolean equals(final Response otherMessage) {
+ return super.equals(otherMessage) && successful == otherMessage.successful
+ && responseTo.equals(otherMessage.responseTo);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.core.protocols.Message#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ if (!super.equals(o)) {
+ return false;
+ }
+
+ final Response response = (Response) o;
+
+ if (successful != response.successful) {
+ return false;
+ }
+ return !(responseTo != null ? !responseTo.equals(response.responseTo) : response.responseTo != null);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.core.protocols.Message#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ int result = super.hashCode();
+ result = HASH_PRIME * result + (successful ? 1 : 0);
+ result = HASH_PRIME * result + (responseTo != null ? responseTo.hashCode() : 0);
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.core.model.protocols.Message#toString()
+ */
+ @Override
+ public String toString() {
+ return "Response {" + super.toString() + "}[successful=" + successful + "]";
+ }
+}
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StartEngine.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StartEngine.java
new file mode 100644
index 000000000..81353236f
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StartEngine.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols.engdep.messages;
+
+import org.onap.policy.apex.core.protocols.Message;
+import org.onap.policy.apex.core.protocols.engdep.EngDepAction;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+
+/**
+ * The Class StartEngine is a message that requests that an Apex engine in an engine service be started.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class StartEngine extends Message {
+ private static final long serialVersionUID = 5885214410842753037L;
+
+ /**
+ * Instantiates a new StartEngine message.
+ *
+ * @param engineKey the key of the engine to start
+ */
+ public StartEngine(final AxArtifactKey engineKey) {
+ this(engineKey, null);
+ }
+
+ /**
+ * Instantiates a new StartEngine message.
+ *
+ * @param engineKey the key of the engine to start
+ * @param messageData the message data that may give specifics on what way to start
+ */
+ public StartEngine(final AxArtifactKey engineKey, final String messageData) {
+ super(EngDepAction.START_ENGINE, engineKey, messageData);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.core.model.protocols.Message#toString()
+ */
+ @Override
+ public String toString() {
+ return "StartEngine {" + super.toString() + "}[]";
+ }
+}
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StartPeriodicEvents.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StartPeriodicEvents.java
new file mode 100644
index 000000000..421669f97
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StartPeriodicEvents.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols.engdep.messages;
+
+import org.onap.policy.apex.core.protocols.Message;
+import org.onap.policy.apex.core.protocols.engdep.EngDepAction;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+
+/**
+ * The Class StartEngine is a message that requests that an Apex engine in an engine service be started.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class StartPeriodicEvents extends Message {
+ private static final long serialVersionUID = -9172376034035242135L;
+
+ /**
+ * Instantiates a new StartEngine message.
+ *
+ * @param engineKey the key of the engine to start
+ */
+ public StartPeriodicEvents(final AxArtifactKey engineKey) {
+ this(engineKey, null);
+ }
+
+ /**
+ * Instantiates a new StartEngine message.
+ *
+ * @param engineKey the key of the engine to start
+ * @param messageData the message data that may give specifics on what way to start
+ */
+ public StartPeriodicEvents(final AxArtifactKey engineKey, final String messageData) {
+ super(EngDepAction.START_PERIODIC_EVENTS, engineKey, messageData);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.core.model.protocols.Message#toString()
+ */
+ @Override
+ public String toString() {
+ return "StartPeriodicEvents {" + super.toString() + "}[]";
+ }
+}
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StopEngine.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StopEngine.java
new file mode 100644
index 000000000..33e66ba6d
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StopEngine.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols.engdep.messages;
+
+import org.onap.policy.apex.core.protocols.Message;
+import org.onap.policy.apex.core.protocols.engdep.EngDepAction;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+
+/**
+ * The Class StopEngine is a message that requests that an Apex engine in an engine service be stopped.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class StopEngine extends Message {
+ private static final long serialVersionUID = 5885214410842753037L;
+
+ /**
+ * Instantiates a new StopEngine message.
+ *
+ * @param engineKey the key of the engine to stop
+ */
+ public StopEngine(final AxArtifactKey engineKey) {
+ this(engineKey, null);
+ }
+
+ /**
+ * Instantiates a new StopEngine message.
+ *
+ * @param engineKey the key of the engine to stop
+ * @param messageData the message data that may give specifics on what way to stop
+ */
+ public StopEngine(final AxArtifactKey engineKey, final String messageData) {
+ super(EngDepAction.STOP_ENGINE, engineKey, messageData);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.core.model.protocols.Message#toString()
+ */
+ @Override
+ public String toString() {
+ return "StopEngine {" + super.toString() + "}[]";
+ }
+}
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StopPeriodicEvents.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StopPeriodicEvents.java
new file mode 100644
index 000000000..49f80ecb0
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/StopPeriodicEvents.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols.engdep.messages;
+
+import org.onap.policy.apex.core.protocols.Message;
+import org.onap.policy.apex.core.protocols.engdep.EngDepAction;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+
+/**
+ * The Class StopEngine is a message that requests that an Apex engine in an engine service be stopped.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class StopPeriodicEvents extends Message {
+ private static final long serialVersionUID = -1796422638427413285L;
+
+ /**
+ * Instantiates a new StopEngine message.
+ *
+ * @param engineKey the key of the engine to stop
+ */
+ public StopPeriodicEvents(final AxArtifactKey engineKey) {
+ this(engineKey, null);
+ }
+
+ /**
+ * Instantiates a new StopEngine message.
+ *
+ * @param engineKey the key of the engine to stop
+ * @param messageData the message data that may give specifics on what way to stop
+ */
+ public StopPeriodicEvents(final AxArtifactKey engineKey, final String messageData) {
+ super(EngDepAction.STOP_PERIODIC_EVENTS, engineKey, messageData);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.core.model.protocols.Message#toString()
+ */
+ @Override
+ public String toString() {
+ return "StopPeriodicEvents {" + super.toString() + "}[]";
+ }
+}
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/UpdateModel.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/UpdateModel.java
new file mode 100644
index 000000000..8d6d315ce
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/UpdateModel.java
@@ -0,0 +1,100 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols.engdep.messages;
+
+import org.onap.policy.apex.core.protocols.Message;
+import org.onap.policy.apex.core.protocols.engdep.EngDepAction;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+
+/**
+ * The Class UpdateModel is a message that requests an Apex engine to update its model using the data provided in the
+ * message.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class UpdateModel extends Message {
+ private static final long serialVersionUID = 5885214410842753037L;
+
+ // The reply timeout value for update messages
+ private static final int UPDATE_MODEL_REPLY_TIMEOUT = 30000;
+
+ // Flags indicating whether conflicts in context should be ignored and whether the model should be forced even if it
+ // is incompatible
+ private boolean ignoreConflicts = false;
+ private boolean forceInstall = false;
+
+ /**
+ * Instantiates a new update model message.
+ *
+ * @param engineServiceKey the key of the engine service in which the model of all engines will be updated
+ */
+ public UpdateModel(final AxArtifactKey engineServiceKey) {
+ this(engineServiceKey, null, false, false);
+ }
+
+ /**
+ * Instantiates a new update model message.
+ *
+ * @param engineServiceKey the key of the engine service in which the model of all engines will be updated
+ * @param messageData the message data that indicates to the Apex engine the manner in which its model should be
+ * updated
+ * @param ignoreConflicts true if conflicts between context in polices is to be ignored
+ * @param force true if the model is to be applied even if it is incompatible with the existing model
+ */
+ public UpdateModel(final AxArtifactKey engineServiceKey, final String messageData, final boolean ignoreConflicts,
+ final boolean force) {
+ super(EngDepAction.UPDATE_MODEL, engineServiceKey, messageData);
+
+ this.ignoreConflicts = ignoreConflicts;
+ this.forceInstall = force;
+
+ // Update messages have a longer timeout
+ setReplyTimeout(UPDATE_MODEL_REPLY_TIMEOUT);
+ }
+
+ /**
+ * Check if context conflicts should be ignored.
+ *
+ * @return true if conflicts should be ignored
+ */
+ public boolean isIgnoreConflicts() {
+ return ignoreConflicts;
+ }
+
+ /**
+ * Check if version checks should be overridden.
+ *
+ * @return true if version checks should be overridden
+ */
+ public boolean isForceInstall() {
+ return forceInstall;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.core.model.protocols.Message#toString()
+ */
+ @Override
+ public String toString() {
+ return "UpdateModel {" + super.toString() + "}[]";
+ }
+}
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/package-info.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/package-info.java
new file mode 100644
index 000000000..3c9a5e856
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/package-info.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ * Provides classes that define the EngDep messages.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+
+package org.onap.policy.apex.core.protocols.engdep.messages;
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/package-info.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/package-info.java
new file mode 100644
index 000000000..5d8fd7893
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/package-info.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ * Provides the EngDep protocol for communication between the APEX Engine and Apex deployment.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+
+package org.onap.policy.apex.core.protocols.engdep;
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/package-info.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/package-info.java
new file mode 100644
index 000000000..fceef33e2
--- /dev/null
+++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/package-info.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ * Contains protocols that are used for communication in APEX.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+
+package org.onap.policy.apex.core.protocols;
diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetExecutionStatusTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetExecutionStatusTest.java
new file mode 100644
index 000000000..d5cf2bcba
--- /dev/null
+++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetExecutionStatusTest.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols.engdep;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.UnknownHostException;
+
+import org.junit.Test;
+import org.onap.policy.apex.core.protocols.engdep.messages.GetEngineStatus;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class GetExecutionStatusTest.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class GetExecutionStatusTest {
+ // Logger for this class
+ private static final XLogger logger = XLoggerFactory.getXLogger(GetExecutionStatusTest.class);
+
+ GetEngineStatus message = null;
+
+ /**
+ * Test register entity.
+ *
+ * @throws UnknownHostException the unknown host exception
+ */
+ @Test
+ public void testRegisterEntity() throws UnknownHostException {
+ final AxArtifactKey targetKey = new AxArtifactKey("UpdateModelTest", "0.0.1");
+ message = new GetEngineStatus(targetKey);
+ assertNotNull(message);
+ logger.debug(message.toString());
+ assertTrue((message.toString()).contains("UpdateModelTest"));
+ }
+}
diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetPolicyStatusTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetPolicyStatusTest.java
new file mode 100644
index 000000000..97cc8d5b9
--- /dev/null
+++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetPolicyStatusTest.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols.engdep;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.UnknownHostException;
+
+import org.junit.Test;
+import org.onap.policy.apex.core.protocols.engdep.messages.GetEngineStatus;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class GetPolicyStatusTest.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class GetPolicyStatusTest {
+ // Logger for this class
+ private static final XLogger logger = XLoggerFactory.getXLogger(GetPolicyStatusTest.class);
+
+ GetEngineStatus message = null;
+
+ /**
+ * Test register entity.
+ *
+ * @throws UnknownHostException the unknown host exception
+ */
+ @Test
+ public void testRegisterEntity() throws UnknownHostException {
+ final AxArtifactKey targetKey = new AxArtifactKey("PolicyStatusTest", "0.0.1");
+ message = new GetEngineStatus(targetKey);
+ assertNotNull(message);
+ logger.debug(message.toString());
+ assertTrue((message.toString()).contains("PolicyStatusTest"));
+ }
+}
diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/ResponseTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/ResponseTest.java
new file mode 100644
index 000000000..74def7cc0
--- /dev/null
+++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/ResponseTest.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols.engdep;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.net.UnknownHostException;
+
+import org.junit.Test;
+import org.onap.policy.apex.core.protocols.engdep.messages.Response;
+import org.onap.policy.apex.core.protocols.engdep.messages.UpdateModel;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class ResponseTest.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class ResponseTest {
+ // Logger for this class
+ private static final XLogger logger = XLoggerFactory.getXLogger(ResponseTest.class);
+
+ Response message = null;
+
+ /**
+ * Test response.
+ *
+ * @throws UnknownHostException the unknown host exception
+ */
+ @Test
+ public void testResponse() throws UnknownHostException {
+ final AxArtifactKey responseKey = new AxArtifactKey("ResponseTest", "0.0.1");
+ final AxArtifactKey responseToKey = new AxArtifactKey("ResponseTestTO", "0.0.1");
+ message = new Response(responseKey, false, new UpdateModel(responseToKey));
+ logger.debug(message.toString());
+ assertTrue(message.toString().contains("ResponseTest"));
+ assertFalse(message.isSuccessful());
+
+ message = new Response(responseKey, true, new UpdateModel(responseToKey));
+ logger.debug(message.toString());
+ assertTrue(message.toString().contains("ResponseTest"));
+ assertTrue(message.isSuccessful());
+ }
+}
diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/UpdateModelTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/UpdateModelTest.java
new file mode 100644
index 000000000..ca919c389
--- /dev/null
+++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/UpdateModelTest.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.core.protocols.engdep;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.UnknownHostException;
+
+import org.junit.Test;
+import org.onap.policy.apex.core.protocols.engdep.messages.UpdateModel;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class UpdateModelTest.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class UpdateModelTest {
+ // Logger for this class
+ private static final XLogger logger = XLoggerFactory.getXLogger(UpdateModelTest.class);
+
+ UpdateModel message = null;
+
+ /**
+ * Test register entity.
+ *
+ * @throws UnknownHostException the unknown host exception
+ */
+ @Test
+ public void testRegisterEntity() throws UnknownHostException {
+ final AxArtifactKey targetKey = new AxArtifactKey("UpdateModelTest", "0.0.1");
+ message = new UpdateModel(targetKey, new String("Placeholder for Apex model XML"), false, false);
+ assertNotNull(message);
+ logger.debug(message.toString());
+ assertTrue((message.toString()).contains("Placeholder for Apex model XML"));
+ }
+}
diff --git a/core/core-protocols/src/test/resources/logback-test.xml b/core/core-protocols/src/test/resources/logback-test.xml
new file mode 100644
index 000000000..034511335
--- /dev/null
+++ b/core/core-protocols/src/test/resources/logback-test.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<configuration>
+
+ <contextName>Apex</contextName>
+ <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+ <property name="LOG_DIR" value="${java.io.tmpdir}/apex_logging/" />
+
+ <!-- USE FOR STD OUT ONLY -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+ <logger name="org.infinispan" level="INFO" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <logger name="org.apache.zookeeper.ClientCnxn" level="OFF" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>${LOG_DIR}/apex.log</file>
+ <encoder>
+ <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
+ %logger{26} - %msg %n %ex{full}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
+ <file>${LOG_DIR}/apex_ctxt.log</file>
+ <encoder>
+ <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
+ %logger{26} - %msg %n %ex{full}</pattern>
+ </encoder>
+ </appender>
+
+ <logger name="org.onap.policy.apex.core.context.impl.monitoring" level="TRACE" additivity="false">
+ <appender-ref ref="CTXT_FILE" />
+ </logger>
+
+ <logger name="org.onap.policy.apex.core.context" level="INFO" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+</configuration>