From 812cf9a5f6ae7140be475342f19833a2e213c1ae Mon Sep 17 00:00:00 2001 From: decheng zhang Date: Thu, 21 Jul 2022 17:16:58 -0400 Subject: [sli/core/sliPlutinUtils] Adding Extra Constraint Filtering on ShortestPathCompute Issue-ID: CCSDK-3730 Signed-off-by: decheng zhang Change-Id: I9a9899b235903c5a306edfdc155dd730a580e11d --- .../slitopologyutils/graph/DijkstraGraphSearch.java | 1 + .../sli/core/slipluginutils/slitopologyutils/graph/Edge.java | 6 ++++++ .../sli/core/slipluginutils/slitopologyutils/topology/Link.java | 6 ++++++ .../slipluginutils/slitopologyutils/topology/LogicalLink.java | 9 +++++++++ .../core/slipluginutils/slitopologyutils/topology/OtnLink.java | 1 + .../slipluginutils/slitopologyutils/topology/PInterface.java | 4 ++++ .../onap/ccsdk/sli/core/slipluginutils/SliTopologyUtilsTest.java | 6 +++--- 7 files changed, 30 insertions(+), 3 deletions(-) diff --git a/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/graph/DijkstraGraphSearch.java b/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/graph/DijkstraGraphSearch.java index 11611346b..23b34f8d2 100644 --- a/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/graph/DijkstraGraphSearch.java +++ b/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/graph/DijkstraGraphSearch.java @@ -332,6 +332,7 @@ public class DijkstraGraphSearch> { // If the vertex is reachable, relax all its egress edges. for (E e : graph.getEdgesFrom(nearest)) { + if (!e.isPermitted(src, dst)) continue; result.relaxEdge(e, cost, weigher, true); } } diff --git a/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/graph/Edge.java b/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/graph/Edge.java index b178072c2..cf96e7d0c 100644 --- a/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/graph/Edge.java +++ b/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/graph/Edge.java @@ -16,4 +16,10 @@ public interface Edge { */ V dst(); + /** + * Returns true if edge is permissable + */ + default boolean isPermitted(V src, V dst){ + return true; + } } diff --git a/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/Link.java b/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/Link.java index fe6ec1c4f..0ace9de5d 100644 --- a/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/Link.java +++ b/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/Link.java @@ -6,4 +6,10 @@ public interface Link { OTN, ETH } + + PInterface src(); + + PInterface dst(); + + boolean isInnerDomain(); } diff --git a/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/LogicalLink.java b/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/LogicalLink.java index 47b43e849..9a9c95798 100644 --- a/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/LogicalLink.java +++ b/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/LogicalLink.java @@ -32,6 +32,15 @@ public class LogicalLink implements Edge { return dst; } + @Override + public boolean isPermitted(Pnf src, Pnf dst) { + String curSrcName = src().toString(); + String curDstName = dst().toString(); + return link.isInnerDomain() + || !curSrcName.equals(src.toString()) && !curDstName.equals(dst.toString()) + && !curSrcName.equals(dst.toString()) && !curDstName.equals(src.toString()); + } + @Override public int hashCode() { return link.hashCode(); diff --git a/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/OtnLink.java b/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/OtnLink.java index 553a9bd26..6a0fe3cee 100644 --- a/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/OtnLink.java +++ b/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/OtnLink.java @@ -29,6 +29,7 @@ public class OtnLink implements Link{ return linkName; } + @Override public boolean isInnerDomain(){ if (src != null && dst != null){ if (src.pInterfaceName() != null && dst.pInterfaceName() != null){ diff --git a/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/PInterface.java b/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/PInterface.java index 6b111871d..20aee11a7 100644 --- a/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/PInterface.java +++ b/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/PInterface.java @@ -16,6 +16,10 @@ public class PInterface { return pInterfaceName; } + public String pnfName() { + return pnfName; + } + @Override public int hashCode(){ return Objects.hash(pnfName, pInterfaceName); diff --git a/core/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliTopologyUtilsTest.java b/core/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliTopologyUtilsTest.java index 5937e2330..2a009fecb 100644 --- a/core/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliTopologyUtilsTest.java +++ b/core/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliTopologyUtilsTest.java @@ -56,10 +56,10 @@ public class SliTopologyUtilsTest { param.put("pnfs-pfx", "ccsdkTopopnfs"); param.put("links-pfx", "ccsdkTopologicalLinks"); param.put("response-pfx", "prefix"); - param.put("output-end-to-end-path", "false"); + param.put("output-end-to-end-path", "true"); - param.put("src-node","networkId-providerId-30-clientId-0-topologyId-1-nodeId-10.3.1.1" ); - param.put("dst-node", "networkId-providerId-50-clientId-0-topologyId-1-nodeId-10.5.1.4"); + param.put("src-node","networkId-providerId-30-clientId-0-topologyId-1-nodeId-10.3.1.3" ); + param.put("dst-node", "networkId-providerId-50-clientId-0-topologyId-1-nodeId-10.5.1.2"); SliTopologyUtils.computePath(param, ctx); //SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.INFO); -- cgit 1.2.3-korg