summaryrefslogtreecommitdiffstats
path: root/sli/provider
diff options
context:
space:
mode:
authorSmokowski, Kevin (ks6305) <kevin.smokowski@att.com>2018-10-04 20:12:40 +0000
committerSmokowski, Kevin (ks6305) <kevin.smokowski@att.com>2018-10-04 20:12:40 +0000
commit86e489058f5a8f75f0b8fbcbd0a3eca2dbcb4470 (patch)
tree0810ee935852d90b3ad7f26da1910e3c61fd0726 /sli/provider
parenta68b1d51bdb4b5fb8575b7029b86d2d1abbfdace (diff)
implement exit node
exit node functions similar to a return statement in most programming languages Change-Id: I2991590fb700b03a9f3d72ae0bc7b5dd9bb25f74 Issue-ID: CCSDK-611 Signed-off-by: Smokowski, Kevin (ks6305) <kevin.smokowski@att.com>
Diffstat (limited to 'sli/provider')
-rwxr-xr-xsli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java42
-rwxr-xr-xsli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java45
2 files changed, 77 insertions, 10 deletions
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java
new file mode 100755
index 00000000..fc667f40
--- /dev/null
+++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.core.sli.provider;
+
+import org.onap.ccsdk.sli.core.sli.ExitNodeException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ExitNodeExecutor extends SvcLogicNodeExecutor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ExitNodeExecutor.class);
+
+ @Override
+ public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
+ String message = "ExitNodeExecutor encountered exit with nodeId " + node.getNodeId();
+ LOG.debug(message);
+ throw new ExitNodeException(message);
+ }
+
+}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java
index 000c2872..0a286958 100755
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java
+++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java
@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Properties;
import org.onap.ccsdk.sli.core.dblib.DbLibService;
import org.onap.ccsdk.sli.core.sli.ConfigurationException;
+import org.onap.ccsdk.sli.core.sli.ExitNodeException;
import org.onap.ccsdk.sli.core.sli.MetricLogger;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore;
@@ -70,7 +71,7 @@ public class SvcLogicServiceImpl implements SvcLogicService {
put("update", new UpdateNodeExecutor());
put("break", new BreakNodeExecutor());
put("while", new WhileNodeExecutor());
-
+ put("exit", new ExitNodeExecutor());
}
};
@@ -151,14 +152,17 @@ public class SvcLogicServiceImpl implements SvcLogicService {
SvcLogicNode curNode = graph.getRootNode();
LOG.info("About to execute graph {}", graph.toString());
-
- while (curNode != null) {
- MDC.put("nodeId", curNode.getNodeId() + " (" + curNode.getNodeType() + ")");
- LOG.info("About to execute node # {} ({})", curNode.getNodeId(), curNode.getNodeType());
-
- SvcLogicNode nextNode = executeNode(curNode, ctx);
- curNode = nextNode;
- }
+ try {
+ while (curNode != null) {
+ MDC.put("nodeId", curNode.getNodeId() + " (" + curNode.getNodeType() + ")");
+ LOG.info("About to execute node # {} ({})", curNode.getNodeId(), curNode.getNodeType());
+
+ SvcLogicNode nextNode = executeNode(curNode, ctx);
+ curNode = nextNode;
+ }
+ } catch (ExitNodeException e) {
+ LOG.debug("SvcLogicServiceImpl caught ExitNodeException");
+ }
MDC.remove("nodeId");
MDC.remove("currentGraph");
@@ -181,7 +185,28 @@ public class SvcLogicServiceImpl implements SvcLogicService {
executor.getClass().getName());
return (executor.execute(this, node, ctx));
} else {
- throw new SvcLogicException("Attempted to execute a node of type " + node.getNodeType() + ", but no executor was registered for this type");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("{} node not implemented", node.getNodeType());
+ }
+ SvcLogicNode nextNode = node.getOutcomeValue("failure");
+ if (nextNode != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("about to execute failure branch");
+ }
+ return (nextNode);
+ }
+
+ nextNode = node.getOutcomeValue("Other");
+ if (nextNode != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("about to execute Other branch");
+ }
+ } else {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("no failure or Other branch found");
+ }
+ }
+ return (nextNode);
}
}