diff options
author | Decheng Zhang <decheng.zhang@huawei.com> | 2021-04-16 17:51:15 -0400 |
---|---|---|
committer | Decheng Zhang <decheng.zhang@huawei.com> | 2021-04-21 14:34:36 -0400 |
commit | 70ac2b906e4e80f817185542a649f188fc9178b0 (patch) | |
tree | f3e81f796cb41fc3617dbaad221e1a9f113bd93b /core/sliPluginUtils/provider/src/main | |
parent | 43228cc2a7f06d5e1b6e398023684c80d9ed1270 (diff) |
Fix context memory reading issue in sliPluginUtils.SliTopologyUtils;
Moving the fix from SliTopologyutils to sli-common/SvcLogicContext,
and reorgnizing methods in SvcLogicContext.
recheck
Issue-ID: CCSDK-3270
Signed-off-by: Decheng Zhang <decheng.zhang@huawei.com>
Change-Id: I423f13b72bd02c77b3a652def276f49d298245ab
Signed-off-by: Decheng Zhang <decheng.zhang@huawei.com>
Diffstat (limited to 'core/sliPluginUtils/provider/src/main')
-rw-r--r-- | core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliTopologyUtils.java | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliTopologyUtils.java b/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliTopologyUtils.java index 5760bdfd4..131db9019 100644 --- a/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliTopologyUtils.java +++ b/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliTopologyUtils.java @@ -35,9 +35,7 @@ import org.onap.ccsdk.sli.core.slipluginutils.slitopologyutils.topology.LogicalL import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import java.util.*; public class SliTopologyUtils implements SvcLogicJavaPlugin { private static final Logger LOG = LoggerFactory.getLogger(SliTopologyUtils.class); @@ -66,14 +64,17 @@ public class SliTopologyUtils implements SvcLogicJavaPlugin { * @throws SvcLogicException */ public static String computePath(Map<String, String> parameters, SvcLogicContext ctx ) throws SvcLogicException { - try{ - LOG.debug( "ENTERING Execute Node \"computePath\"" ); + LOG.debug( "ENTERING Execute Node \"computePath\"" ); + boolean outputFullPath = false; + Graph<Pnf, LogicalLink> graph; + Pnf src; + Pnf dst; + + try{ // Validate, Log, & read parameters checkParameters(parameters, new String[]{ "pnfs-pfx", "links-pfx", "src-node", "dst-node", "response-pfx"}, LOG); - - boolean outputFullPath = false; String outputEndToEnd = parameters.get("output-end-to-end-path"); if (outputEndToEnd != null && outputEndToEnd.equals("true")){ @@ -81,8 +82,8 @@ public class SliTopologyUtils implements SvcLogicJavaPlugin { LOG.debug( "OutputEndToEndPath enabled"); } - String pnfsStr = ctx.toJsonString(parameters.get("pnfs-pfx")); - String lkStr = ctx.toJsonString(parameters.get("links-pfx")); + String pnfsStr = ctx.toJsonString( parameters.get("pnfs-pfx")); + String lkStr = ctx.toJsonString( parameters.get("links-pfx")); if (pnfsStr.isEmpty()){ LOG.warn("Pnf Array attributes are empty"); @@ -109,27 +110,33 @@ public class SliTopologyUtils implements SvcLogicJavaPlugin { JsonArray pnfArr = ((JsonObject) jp.parse(pnfsStr)).getAsJsonArray("pnf"); JsonArray lkArr = ((JsonObject) jp.parse(lkStr)).getAsJsonArray("logical-link"); LOG.debug("Creating graph with {} pnf(s) and {} link(s)", pnfArr.size(), lkArr.size()); - Graph<Pnf, LogicalLink> graph = buildGraph(pnfArr, lkArr); + graph = buildGraph(pnfArr, lkArr); - Pnf src = new Pnf(srcNodeStr); - Pnf dst = new Pnf(dstNodeStr); + src = new Pnf(srcNodeStr); + dst = new Pnf(dstNodeStr); if (!graph.getVertexes().contains(src) || !graph.getVertexes().contains(dst)){ LOG.warn("Src or Dst node doesn't exist"); throw new Exception("Src or Dst node doesn't exist"); } + } catch( Exception e ) { + throw new SvcLogicException( "An error occurred in the computePath Execute node; failed to process the" + + "given params for path computation", e ); + } + + try { DijkstraGraphSearch.Result result = - new DijkstraGraphSearch<Pnf, LogicalLink>().search(graph, src, dst,null, -1); + new DijkstraGraphSearch<Pnf, LogicalLink>().search(graph, src, dst, null, -1); LOG.debug("Path Computing results: {}", result.paths().toString()); - if (result.paths().size() > 0){ + if (result.paths().size() > 0) { JsonObject root = new JsonObject(); JsonArray solnList = new JsonArray(); Path<Pnf, LogicalLink> path = (Path<Pnf, LogicalLink>) result.paths().iterator().next(); for (LogicalLink logicalLink : path.edges()) { - if ( ((OtnLink) logicalLink.underlayLink()).isInnerDomain() && !outputFullPath ){ + if (!outputFullPath && ((OtnLink) logicalLink.underlayLink()).isInnerDomain()) { //Ignore inner domain links } else { JsonObject curLink = new JsonObject(); @@ -164,11 +171,11 @@ public class SliTopologyUtils implements SvcLogicJavaPlugin { LOG.debug("SliTopologyUtils: no valid path found."); return NOT_FOUND_CONSTANT; } - - } catch( Exception e ) { - throw new SvcLogicException( "An error occurred in the computePath Execute node", e ); + } catch (Exception e){ + throw new SvcLogicException( "An error occurred in the computePath Execute node; failed to execute the graph " + + "computation", e ); } finally { - LOG.debug( "EXITING Execute Node \"computePath\"" ); + LOG.debug( "Exiting Execute Node \"computePath\"" ); } } @@ -223,7 +230,7 @@ public class SliTopologyUtils implements SvcLogicJavaPlugin { } } - if (pnfNameStrList.size() == 2 && pnfNameStrList.size() == 2){ + if (pnfNameStrList.size() == 2 && pInterfaceStrList.size() == 2){ String pnf1NameStr = pnfNameStrList.get(0); String pnf2NameStr = pnfNameStrList.get(1); String pI1NameStr = pInterfaceStrList.get(0); |