collapse get node into a common metho, reset MDC right before getting next node for certain executor
Change-Id: I85b1cf0dfd595deee42dc93f4095ecbc6c831998
Issue-ID: CCSDK-187
Signed-off-by: Kevin Smokowski <ks6305@att.com>
str = str.replaceAll("\\|","%7C"); //log records should not contain a pipe, encode the pipe character
return str;
}
+
+ public static void resetContext() {
+ MDC.remove(TARGET_ENTITY);
+ MDC.remove(TARGET_SERVICE_NAME);
+ MDC.remove(TARGET_VIRTUAL_ENTITY);
+ MDC.remove(STATUS_CODE);
+ MDC.remove(RESPONSE_CODE);
+ MDC.remove(RESPONSE_DESCRIPTION);
+ }
}
public class DeleteNodeExecutor extends SvcLogicNodeExecutor {
- private static final Logger LOG = LoggerFactory
- .getLogger(DeleteNodeExecutor.class);
- @Override
- public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
+ private static final Logger LOG = LoggerFactory.getLogger(DeleteNodeExecutor.class);
- String plugin = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("plugin"), node, ctx);
- String resourceType = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("resource"), node, ctx);
- String key = SvcLogicExpressionResolver.evaluateAsKey(
- node.getAttribute("key"), node, ctx);
+ @Override
+ public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx)
+ throws SvcLogicException {
- String outValue = "failure";
+ String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
+ String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx);
+ String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx);
- if (LOG.isDebugEnabled()) {
- LOG.debug("delete node encountered - looking for resource class "
- + plugin);
- }
+ String outValue = "failure";
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("delete node encountered - looking for resource class " + plugin);
+ }
- SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
- if (resourcePlugin != null) {
-
- try {
-
- switch (resourcePlugin.delete(resourceType, key, ctx)) {
- case SUCCESS:
- outValue = "success";
- break;
- case NOT_FOUND:
- outValue = "not-found";
- break;
- case FAILURE:
- default:
- outValue = "failure";
- }
- } catch (SvcLogicException e) {
- LOG.error("Caught exception from resource plugin", e);
- outValue = "failure";
- }
- } else {
- LOG.warn("Could not find SvcLogicResource object for plugin "
- + plugin);
- }
-
-
- SvcLogicNode nextNode = node.getOutcomeValue(outValue);
- if (nextNode != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("about to execute " + outValue + " 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 "+outValue+" or Other branch found");
- }
- }
- return (nextNode);
- }
+ SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
+ if (resourcePlugin != null) {
+ try {
+ switch (resourcePlugin.delete(resourceType, key, ctx)) {
+ case SUCCESS:
+ outValue = "success";
+ break;
+ case NOT_FOUND:
+ outValue = "not-found";
+ break;
+ case FAILURE:
+ default:
+ outValue = "failure";
+ }
+ } catch (SvcLogicException e) {
+ LOG.error("Caught exception from resource plugin", e);
+ outValue = "failure";
+ }
+ } else {
+ LOG.warn("Could not find SvcLogicResource object for plugin " + plugin);
+ }
+ return (getNextNode(node, outValue));
+ }
}
}
}
-
- SvcLogicNode nextNode = node.getOutcomeValue(outValue);
- if (nextNode != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("about to execute " + outValue + " 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 " + outValue + " or Other branch found");
- }
- }
- return (nextNode);
+ return (getNextNode(node, outValue));
}
protected String evaluate(SvcLogicExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
} else {
return "success";
}
-
} else {
return "success";
}
public class ExistsNodeExecutor extends SvcLogicNodeExecutor {
- private static final Logger LOG = LoggerFactory
- .getLogger(ExistsNodeExecutor.class);
- @Override
- public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
-
- String plugin = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("plugin"), node, ctx);
- String resourceType = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("resource"), node, ctx);
- String key = SvcLogicExpressionResolver.evaluateAsKey(
- node.getAttribute("key"), node, ctx);
- String pfx = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("pfx"), node, ctx);
-
- String outValue = "failure";
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("exists node encountered - looking for resource class "
- + plugin);
- }
-
-
-
- SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
-
- if (resourcePlugin != null) {
-
- try {
-
- switch (resourcePlugin.exists(resourceType, key, pfx, ctx)) {
- case SUCCESS:
- outValue = "true";
- break;
- case NOT_FOUND:
- outValue = "false";
- break;
- case FAILURE:
- default:
- outValue = "false";
- }
- } catch (SvcLogicException e) {
- LOG.error("Caught exception from resource plugin", e);
- outValue = "failure";
- }
- } else {
- LOG.warn("Could not find SvcLogicResource object for plugin "
- + plugin);
- }
-
- SvcLogicNode nextNode = node.getOutcomeValue(outValue);
- if (nextNode != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("about to execute " + outValue + " 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 "+outValue+" or Other branch found");
- }
- }
- return (nextNode);
- }
+ private static final Logger LOG = LoggerFactory.getLogger(ExistsNodeExecutor.class);
+
+ @Override
+ public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx)
+ throws SvcLogicException {
+
+ String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
+ String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx);
+ String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx);
+ String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx);
+
+ String outValue = "failure";
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("exists node encountered - looking for resource class " + plugin);
+ }
+
+ SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
+
+ if (resourcePlugin != null) {
+ try {
+ switch (resourcePlugin.exists(resourceType, key, pfx, ctx)) {
+ case SUCCESS:
+ outValue = "true";
+ break;
+ case NOT_FOUND:
+ outValue = "false";
+ break;
+ case FAILURE:
+ default:
+ outValue = "false";
+ }
+ } catch (SvcLogicException e) {
+ LOG.error("Caught exception from resource plugin", e);
+ outValue = "failure";
+ }
+ } else {
+ LOG.warn("Could not find SvcLogicResource object for plugin " + plugin);
+ }
+ return (getNextNode(node, outValue));
+ }
}
public class GetResourceNodeExecutor extends SvcLogicNodeExecutor {
- private static final Logger LOG = LoggerFactory
- .getLogger(GetResourceNodeExecutor.class);
-
- public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
-
- String plugin = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("plugin"), node, ctx);
- String resourceType = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("resource"), node, ctx);
- String key = SvcLogicExpressionResolver.evaluateAsKey(
- node.getAttribute("key"), node, ctx);
- String pfx = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("pfx"), node, ctx);
-
- String localOnlyStr = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("local-only"), node, ctx);
-
- // Note: for get-resource, only refresh from A&AI if the DG explicitly set
- // local-only to false. Otherwise, just read from local database.
- boolean localOnly = true;
-
- if ("false".equalsIgnoreCase(localOnlyStr)) {
- localOnly = false;
- }
-
- SvcLogicExpression selectExpr = node.getAttribute("select");
- String select = null;
-
- if (selectExpr != null) {
- select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node,
- ctx);
- }
-
- SvcLogicExpression orderByExpr = node.getAttribute("order-by");
- String orderBy = null;
-
- if (orderByExpr != null) {
- orderBy = SvcLogicExpressionResolver.evaluateAsKey(orderByExpr, node,
- ctx);
- }
-
- String outValue = "failure";
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(node.getNodeType()
- + " node encountered - looking for resource class "
- + plugin);
- }
-
-
- SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
-
- if (resourcePlugin != null) {
-
- try {
- switch (resourcePlugin.query(resourceType, localOnly, select, key,
- pfx, orderBy, ctx)) {
- case SUCCESS:
- outValue = "success";
- break;
- case NOT_FOUND:
- outValue = "not-found";
- break;
- case FAILURE:
- default:
- outValue = "failure";
- }
- } catch (SvcLogicException e) {
- LOG.error("Caught exception from resource plugin", e);
- outValue = "failure";
- }
- } else {
- LOG.warn("Could not find SvcLogicResource object for plugin "
- + plugin);
- }
-
-
- SvcLogicNode nextNode = node.getOutcomeValue(outValue);
- if (nextNode != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("about to execute " + outValue + " 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 "+outValue+" or Other branch found");
- }
- }
- return (nextNode);
- }
+ private static final Logger LOG = LoggerFactory.getLogger(GetResourceNodeExecutor.class);
+
+ public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx)
+ throws SvcLogicException {
+
+ String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
+ String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx);
+ String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx);
+ String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx);
+
+ String localOnlyStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("local-only"), node, ctx);
+
+ // Note: for get-resource, only refresh from A&AI if the DG explicitly set
+ // local-only to false. Otherwise, just read from local database.
+ boolean localOnly = true;
+
+ if ("false".equalsIgnoreCase(localOnlyStr)) {
+ localOnly = false;
+ }
+
+ SvcLogicExpression selectExpr = node.getAttribute("select");
+ String select = null;
+
+ if (selectExpr != null) {
+ select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx);
+ }
+
+ SvcLogicExpression orderByExpr = node.getAttribute("order-by");
+ String orderBy = null;
+
+ if (orderByExpr != null) {
+ orderBy = SvcLogicExpressionResolver.evaluateAsKey(orderByExpr, node, ctx);
+ }
+
+ String outValue = "failure";
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(node.getNodeType() + " node encountered - looking for resource class " + plugin);
+ }
+
+ SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
+
+ if (resourcePlugin != null) {
+ try {
+ switch (resourcePlugin.query(resourceType, localOnly, select, key, pfx, orderBy, ctx)) {
+ case SUCCESS:
+ outValue = "success";
+ break;
+ case NOT_FOUND:
+ outValue = "not-found";
+ break;
+ case FAILURE:
+ default:
+ outValue = "failure";
+ }
+ } catch (SvcLogicException e) {
+ LOG.error("Caught exception from resource plugin", e);
+ outValue = "failure";
+ }
+ } else {
+ LOG.warn("Could not find SvcLogicResource object for plugin " + plugin);
+ }
+ return (getNextNode(node, outValue));
+ }
}
public class IsAvailableNodeExecutor extends SvcLogicNodeExecutor {
- private static final Logger LOG = LoggerFactory
- .getLogger(IsAvailableNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
+ private static final Logger LOG = LoggerFactory.getLogger(IsAvailableNodeExecutor.class);
- String plugin = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("plugin"), node, ctx);
- String resourceType = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("resource"), node, ctx);
- String key = SvcLogicExpressionResolver.evaluateAsKey(
- node.getAttribute("key"), node, ctx);
- String pfx = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("pfx"), node, ctx);
+ @Override
+ public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx)
+ throws SvcLogicException {
- String outValue = "failure";
+ String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
+ String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx);
+ String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx);
+ String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx);
- if (LOG.isDebugEnabled()) {
- LOG.debug("is-available node encountered - looking for resource class "
- + plugin);
- }
+ String outValue = "failure";
- SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
+ SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
-
- if (resourcePlugin != null) {
- try {
- switch (resourcePlugin.isAvailable(resourceType, key, pfx, ctx)) {
- case SUCCESS:
- outValue = "true";
- break;
- case NOT_FOUND:
- outValue = "false";
- break;
- case FAILURE:
- default:
- outValue = "false";
- }
- } catch (SvcLogicException e) {
- LOG.error("Caught exception from resource plugin", e);
- outValue = "failure";
- }
- } else {
- LOG.warn("Could not find SvcLogicResource object for plugin "
- + plugin);
- }
-
- SvcLogicNode nextNode = node.getOutcomeValue(outValue);
- if (nextNode != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("about to execute " + outValue + " 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 "+outValue+" or Other branch found");
- }
- }
- return (nextNode);
- }
+ if (resourcePlugin != null) {
+ try {
+ switch (resourcePlugin.isAvailable(resourceType, key, pfx, ctx)) {
+ case SUCCESS:
+ outValue = "true";
+ break;
+ case NOT_FOUND:
+ outValue = "false";
+ break;
+ case FAILURE:
+ default:
+ outValue = "false";
+ }
+ } catch (SvcLogicException e) {
+ LOG.error("Caught exception from resource plugin", e);
+ outValue = "failure";
+ }
+ } else {
+ LOG.warn("Could not find SvcLogicResource object for plugin " + plugin);
+ }
+ return (getNextNode(node, outValue));
+ }
}
public class NotifyNodeExecutor extends SvcLogicNodeExecutor {
- private static final Logger LOG = LoggerFactory
- .getLogger(NotifyNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
+ private static final Logger LOG = LoggerFactory.getLogger(NotifyNodeExecutor.class);
- String plugin = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("plugin"), node, ctx);
- String resourceType = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("resource"), node, ctx);
- String action = SvcLogicExpressionResolver.evaluateAsKey(
- node.getAttribute("action"), node, ctx);
- String key = SvcLogicExpressionResolver.evaluateAsKey(
- node.getAttribute("key"), node, ctx);
+ @Override
+ public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx)
+ throws SvcLogicException {
- String outValue = "failure";
+ String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
+ String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx);
+ String action = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("action"), node, ctx);
+ String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx);
- if (LOG.isDebugEnabled()) {
- LOG.debug("release node encountered - looking for resource class "
- + plugin);
- }
+ String outValue = "failure";
- SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
- if (resourcePlugin != null) {
-
- try {
-
- switch (resourcePlugin.notify(resourceType, action, key, ctx)) {
- case SUCCESS:
- outValue = "success";
- break;
- case NOT_FOUND:
- outValue = "not-found";
- break;
- case FAILURE:
- default:
- outValue = "failure";
- }
- } catch (SvcLogicException e) {
- LOG.error("Caught exception from resource plugin", e);
- outValue = "failure";
- }
- } else {
- LOG.warn("Could not find SvcLogicResource object for plugin "
- + plugin);
- }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("release node encountered - looking for resource class " + plugin);
+ }
- SvcLogicNode nextNode = node.getOutcomeValue(outValue);
- if (nextNode != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("about to execute " + outValue + " 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 "+outValue+" or Other branch found");
- }
- }
- return (nextNode);
- }
+ SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
+ if (resourcePlugin != null) {
+ try {
+ switch (resourcePlugin.notify(resourceType, action, key, ctx)) {
+ case SUCCESS:
+ outValue = "success";
+ break;
+ case NOT_FOUND:
+ outValue = "not-found";
+ break;
+ case FAILURE:
+ default:
+ outValue = "failure";
+ }
+ } catch (SvcLogicException e) {
+ LOG.error("Caught exception from resource plugin", e);
+ outValue = "failure";
+ }
+ } else {
+ LOG.warn("Could not find SvcLogicResource object for plugin " + plugin);
+ }
+ return (getNextNode(node, outValue));
+ }
}
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicExpression;
public class RecordNodeExecutor extends SvcLogicNodeExecutor {
- private static final Logger LOG = LoggerFactory
- .getLogger(RecordNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
-
- String plugin = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("plugin"), node, ctx);
- String outValue = "failure";
-
- if (LOG.isTraceEnabled()) {
- LOG.trace(node.getNodeType()
- + " node encountered - looking for recorder class "
- + plugin);
- }
-
- Map<String, String> parmMap = new HashMap<String, String>();
-
- Set<Map.Entry<String, SvcLogicExpression>> parmSet = node
- .getParameterSet();
- boolean hasParms = false;
-
- for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = parmSet
- .iterator(); iter.hasNext();) {
- hasParms = true;
- Map.Entry<String, SvcLogicExpression> curEnt = iter.next();
- String curName = curEnt.getKey();
- SvcLogicExpression curExpr = curEnt.getValue();
- String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr,
- node, ctx);
-
- if (LOG.isTraceEnabled()) {
- LOG.trace("executeRecordNode : parameter " + curName + " = "
- + curExpr + " => " + curExprValue);
- }
- parmMap.put(curName, curExprValue);
- }
-
-
- SvcLogicRecorder recorder = getSvcLogicRecorder(plugin);
-
- if (recorder != null) {
-
- try {
- recorder.record(parmMap);
- } catch (SvcLogicException e) {
- LOG.error("Caught exception from recorder plugin", e);
- outValue = "failure";
- }
- } else {
- LOG.warn("Could not find SvcLogicRecorder object for plugin "
- + plugin);
- }
-
- SvcLogicNode nextNode = node.getOutcomeValue(outValue);
- if (nextNode != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("about to execute " + outValue + " branch");
- }
- return (nextNode);
- }
-
- nextNode = node.getOutcomeValue("Other");
- if (nextNode != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("about to execute Other branch");
- }
- } else {
- if (LOG.isTraceEnabled()) {
- LOG.trace("no failure or Other branch found");
- }
- }
- return (nextNode);
- }
-
-
-
-
-
+ private static final Logger LOG = LoggerFactory.getLogger(RecordNodeExecutor.class);
+
+ @Override
+ public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx)
+ throws SvcLogicException {
+
+ String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
+ String outValue = "failure";
+
+ if (LOG.isTraceEnabled()) {
+ LOG.trace(node.getNodeType() + " node encountered - looking for recorder class " + plugin);
+ }
+
+ Map<String, String> parmMap = new HashMap<String, String>();
+
+ Set<Map.Entry<String, SvcLogicExpression>> parmSet = node.getParameterSet();
+ boolean hasParms = false;
+
+ for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = parmSet.iterator(); iter.hasNext();) {
+ hasParms = true;
+ Map.Entry<String, SvcLogicExpression> curEnt = iter.next();
+ String curName = curEnt.getKey();
+ SvcLogicExpression curExpr = curEnt.getValue();
+ String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx);
+
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("executeRecordNode : parameter " + curName + " = " + curExpr + " => " + curExprValue);
+ }
+ parmMap.put(curName, curExprValue);
+ }
+
+ SvcLogicRecorder recorder = getSvcLogicRecorder(plugin);
+ if (recorder != null) {
+ try {
+ recorder.record(parmMap);
+ } catch (SvcLogicException e) {
+ LOG.error("Caught exception from recorder plugin", e);
+ outValue = "failure";
+ }
+ } else {
+ LOG.warn("Could not find SvcLogicRecorder object for plugin " + plugin);
+ }
+ return (getNextNode(node, outValue));
+ }
}
public class ReleaseNodeExecutor extends SvcLogicNodeExecutor {
- private static final Logger LOG = LoggerFactory
- .getLogger(ReleaseNodeExecutor.class);
- @Override
- public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
+ private static final Logger LOG = LoggerFactory.getLogger(ReleaseNodeExecutor.class);
- String plugin = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("plugin"), node, ctx);
- String resourceType = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("resource"), node, ctx);
- String key = SvcLogicExpressionResolver.evaluateAsKey(
- node.getAttribute("key"), node, ctx);
+ @Override
+ public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx)
+ throws SvcLogicException {
- String outValue = "failure";
+ String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
+ String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx);
+ String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx);
- if (LOG.isDebugEnabled()) {
- LOG.debug("release node encountered - looking for resource class "
- + plugin);
- }
+ String outValue = "failure";
- SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
- if (resourcePlugin != null) {
-
- try {
-
- switch (resourcePlugin.release(resourceType, key, ctx)) {
- case SUCCESS:
- outValue = "success";
- break;
- case NOT_FOUND:
- outValue = "not-found";
- break;
- case FAILURE:
- default:
- outValue = "failure";
- }
- } catch (SvcLogicException e) {
- LOG.error("Caught exception from resource plugin", e);
- outValue = "failure";
- }
- } else {
- LOG.warn("Could not find SvcLogicResource object for plugin "
- + plugin);
- }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("release node encountered - looking for resource class " + plugin);
+ }
- SvcLogicNode nextNode = node.getOutcomeValue(outValue);
- if (nextNode != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("about to execute " + outValue + " 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 "+outValue+" or Other branch found");
- }
- }
- return (nextNode);
- }
+ SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
+ if (resourcePlugin != null) {
+ try {
+ switch (resourcePlugin.release(resourceType, key, ctx)) {
+ case SUCCESS:
+ outValue = "success";
+ break;
+ case NOT_FOUND:
+ outValue = "not-found";
+ break;
+ case FAILURE:
+ default:
+ outValue = "failure";
+ }
+ } catch (SvcLogicException e) {
+ LOG.error("Caught exception from resource plugin", e);
+ outValue = "failure";
+ }
+ } else {
+ LOG.warn("Could not find SvcLogicResource object for plugin " + plugin);
+ }
+ return (getNextNode(node, outValue));
+ }
}
public class ReserveNodeExecutor extends SvcLogicNodeExecutor {
- private static final Logger LOG = LoggerFactory
- .getLogger(ReserveNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
-
- String plugin = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("plugin"), node, ctx);
- String resourceType = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("resource"), node, ctx);
- String key = SvcLogicExpressionResolver.evaluateAsKey(
- node.getAttribute("key"), node, ctx);
- String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"),node,ctx);
-
-
+ private static final Logger LOG = LoggerFactory.getLogger(ReserveNodeExecutor.class);
+
+ @Override
+ public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx)
+ throws SvcLogicException {
+
+ String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
+ String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx);
+ String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx);
+ String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx);
+
+
SvcLogicExpression selectExpr = node.getAttribute("select");
String select = null;
- if (selectExpr != null)
- {
- select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx);
+ if (selectExpr != null) {
+ select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx);
}
- String outValue = "failure";
+ String outValue = "failure";
- if (LOG.isDebugEnabled()) {
- LOG.debug("reserve node encountered - looking for resource class "
- + plugin);
- }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("reserve node encountered - looking for resource class " + plugin);
+ }
SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
- if (resourcePlugin != null) {
-
- try {
- switch (resourcePlugin.reserve(resourceType, select, key, pfx, ctx)) {
- case SUCCESS:
- outValue = "success";
- break;
- case NOT_FOUND:
- outValue = "not-found";
- break;
- case FAILURE:
- default:
- outValue = "failure";
- }
- } catch (SvcLogicException e) {
- LOG.error("Caught exception from resource plugin", e);
- outValue = "failure";
- }
- } else {
- LOG.warn("Could not find SvcLogicResource object for plugin "
- + plugin);
- }
-
- SvcLogicNode nextNode = node.getOutcomeValue(outValue);
- if (nextNode != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("about to execute " + outValue + " 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 "+outValue+" or Other branch found");
- }
- }
- return (nextNode);
- }
+ if (resourcePlugin != null) {
+
+ try {
+ switch (resourcePlugin.reserve(resourceType, select, key, pfx, ctx)) {
+ case SUCCESS:
+ outValue = "success";
+ break;
+ case NOT_FOUND:
+ outValue = "not-found";
+ break;
+ case FAILURE:
+ default:
+ outValue = "failure";
+ }
+ } catch (SvcLogicException e) {
+ LOG.error("Caught exception from resource plugin", e);
+ outValue = "failure";
+ }
+ } else {
+ LOG.warn("Could not find SvcLogicResource object for plugin " + plugin);
+ }
+ return (getNextNode(node, outValue));
+ }
}
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicExpression;
public class SaveNodeExecutor extends SvcLogicNodeExecutor {
- private static final Logger LOG = LoggerFactory
- .getLogger(SaveNodeExecutor.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SaveNodeExecutor.class);
- @Override
- public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
+ @Override
+ public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx)
+ throws SvcLogicException {
- String plugin = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("plugin"), node, ctx);
- String resourceType = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("resource"), node, ctx);
- String key = SvcLogicExpressionResolver.evaluateAsKey(
- node.getAttribute("key"), node, ctx);
- String forceStr = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("force"), node, ctx);
- String localOnlyStr = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("local-only"), node, ctx);
- String pfx = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("pfx"), node, ctx);
+ String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
+ String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx);
+ String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx);
+ String forceStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("force"), node, ctx);
+ String localOnlyStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("local-only"), node, ctx);
+ String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx);
- boolean force = "true".equalsIgnoreCase(forceStr);
- boolean localOnly = "true".equalsIgnoreCase(localOnlyStr);
+ boolean force = "true".equalsIgnoreCase(forceStr);
+ boolean localOnly = "true".equalsIgnoreCase(localOnlyStr);
- Map<String, String> parmMap = new HashMap<String, String>();
+ Map<String, String> parmMap = new HashMap<String, String>();
- Set<Map.Entry<String, SvcLogicExpression>> parmSet = node
- .getParameterSet();
- boolean hasParms = false;
+ Set<Map.Entry<String, SvcLogicExpression>> parmSet = node.getParameterSet();
+ boolean hasParms = false;
- for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = parmSet
- .iterator(); iter.hasNext();) {
- hasParms = true;
- Map.Entry<String, SvcLogicExpression> curEnt = iter.next();
- String curName = curEnt.getKey();
- SvcLogicExpression curExpr = curEnt.getValue();
- if (curExpr != null) {
- String curExprValue = SvcLogicExpressionResolver.evaluate(
- curExpr, node, ctx);
+ for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = parmSet.iterator(); iter.hasNext();) {
+ hasParms = true;
+ Map.Entry<String, SvcLogicExpression> curEnt = iter.next();
+ String curName = curEnt.getKey();
+ SvcLogicExpression curExpr = curEnt.getValue();
+ if (curExpr != null) {
+ String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx);
- LOG.debug("Parameter " + curName + " = "
- + curExpr.asParsedExpr() + " resolves to "
- + curExprValue);
+ LOG.debug("Parameter " + curName + " = " + curExpr.asParsedExpr() + " resolves to " + curExprValue);
- parmMap.put(curName, curExprValue);
- }
- }
+ parmMap.put(curName, curExprValue);
+ }
+ }
- String outValue = "failure";
+ String outValue = "failure";
- if (LOG.isDebugEnabled()) {
- LOG.debug("save node encountered - looking for resource class "
- + plugin);
- }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("save node encountered - looking for resource class " + plugin);
+ }
SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
- if (resourcePlugin != null) {
-
- try {
- switch (resourcePlugin.save(resourceType, force, localOnly, key,
- parmMap, pfx, ctx)) {
- case SUCCESS:
- outValue = "success";
- break;
- case NOT_FOUND:
- outValue = "not-found";
- break;
- case FAILURE:
- default:
- outValue = "failure";
- }
- } catch (SvcLogicException e) {
- LOG.error("Caught exception from resource plugin", e);
- outValue = "failure";
- }
- } else {
- LOG.warn("Could not find SvcLogicResource object for plugin "
- + plugin);
- }
-
- SvcLogicNode nextNode = node.getOutcomeValue(outValue);
- if (nextNode != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("about to execute " + outValue + " 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 "+outValue+" or Other branch found");
- }
- }
- return (nextNode);
- }
+ if (resourcePlugin != null) {
+
+ try {
+ switch (resourcePlugin.save(resourceType, force, localOnly, key, parmMap, pfx, ctx)) {
+ case SUCCESS:
+ outValue = "success";
+ break;
+ case NOT_FOUND:
+ outValue = "not-found";
+ break;
+ case FAILURE:
+ default:
+ outValue = "failure";
+ }
+ } catch (SvcLogicException e) {
+ LOG.error("Caught exception from resource plugin", e);
+ outValue = "failure";
+ }
+ } else {
+ LOG.warn("Could not find SvcLogicResource object for plugin " + plugin);
+ }
+ return (getNextNode(node, outValue));
+ }
}
package org.onap.ccsdk.sli.core.sli.provider;
+import org.onap.ccsdk.sli.core.sli.MetricLogger;
import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor;
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.onap.ccsdk.sli.core.sli.SvcLogicRecorder;
import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
-import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
return plugin;
}
}
+ protected SvcLogicNode getNextNode(SvcLogicNode node, String outValue) {
+ MetricLogger.resetContext();
+ SvcLogicNode nextNode = node.getOutcomeValue(outValue);
+ if (nextNode != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("about to execute " + outValue + " 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 " + outValue + " or Other branch found");
+ }
+ }
+ return (nextNode);
+ }
}
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicExpression;
public class UpdateNodeExecutor extends SvcLogicNodeExecutor {
- private static final Logger LOG = LoggerFactory
- .getLogger(UpdateNodeExecutor.class);
+ private static final Logger LOG = LoggerFactory.getLogger(UpdateNodeExecutor.class);
- @Override
- public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
+ @Override
+ public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx)
+ throws SvcLogicException {
- String plugin = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("plugin"), node, ctx);
- String resourceType = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("resource"), node, ctx);
- String key = SvcLogicExpressionResolver.evaluateAsKey(
- node.getAttribute("key"), node, ctx);
- String pfx = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("pfx"), node, ctx);
+ String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
+ String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx);
+ String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx);
+ String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx);
- Map<String, String> parmMap = new HashMap<String, String>();
+ Map<String, String> parmMap = new HashMap<String, String>();
- Set<Map.Entry<String, SvcLogicExpression>> parmSet = node
- .getParameterSet();
- boolean hasParms = false;
+ Set<Map.Entry<String, SvcLogicExpression>> parmSet = node.getParameterSet();
+ boolean hasParms = false;
- for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = parmSet
- .iterator(); iter.hasNext();) {
- hasParms = true;
- Map.Entry<String, SvcLogicExpression> curEnt = iter.next();
- String curName = curEnt.getKey();
- SvcLogicExpression curExpr = curEnt.getValue();
- if (curExpr != null) {
- String curExprValue = SvcLogicExpressionResolver.evaluate(
- curExpr, node, ctx);
+ for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = parmSet.iterator(); iter.hasNext();) {
+ hasParms = true;
+ Map.Entry<String, SvcLogicExpression> curEnt = iter.next();
+ String curName = curEnt.getKey();
+ SvcLogicExpression curExpr = curEnt.getValue();
+ if (curExpr != null) {
+ String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx);
- LOG.debug("Parameter " + curName + " = "
- + curExpr.asParsedExpr() + " resolves to "
- + curExprValue);
+ LOG.debug("Parameter " + curName + " = " + curExpr.asParsedExpr() + " resolves to " + curExprValue);
- parmMap.put(curName, curExprValue);
- }
- }
+ parmMap.put(curName, curExprValue);
+ }
+ }
- String outValue = "failure";
+ String outValue = "failure";
- if (LOG.isDebugEnabled()) {
- LOG.debug("save node encountered - looking for resource class "
- + plugin);
- }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("save node encountered - looking for resource class " + plugin);
+ }
SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
- if (resourcePlugin != null) {
-
- try {
- switch (resourcePlugin.update(resourceType, key,
- parmMap, pfx, ctx)) {
- case SUCCESS:
- outValue = "success";
- break;
- case NOT_FOUND:
- outValue = "not-found";
- break;
- case FAILURE:
- default:
- outValue = "failure";
- }
- } catch (SvcLogicException e) {
- LOG.error("Caught exception from resource plugin", e);
- outValue = "failure";
- }
- } else {
- LOG.warn("Could not find SvcLogicResource object for plugin "
- + plugin);
- }
-
- SvcLogicNode nextNode = node.getOutcomeValue(outValue);
- if (nextNode != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("about to execute " + outValue + " 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 "+outValue+" or Other branch found");
- }
- }
- return (nextNode);
- }
+ if (resourcePlugin != null) {
+
+ try {
+ switch (resourcePlugin.update(resourceType, key, parmMap, pfx, ctx)) {
+ case SUCCESS:
+ outValue = "success";
+ break;
+ case NOT_FOUND:
+ outValue = "not-found";
+ break;
+ case FAILURE:
+ default:
+ outValue = "failure";
+ }
+ } catch (SvcLogicException e) {
+ LOG.error("Caught exception from resource plugin", e);
+ outValue = "failure";
+ }
+ } else {
+ LOG.warn("Could not find SvcLogicResource object for plugin " + plugin);
+ }
+ return (getNextNode(node, outValue));
+ }
}